Commit c887e995 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Hier. Plat.: Fixed connection composition logic

Issue-Ref: 3981
Issue-Url: https://af3-developer.fortiss.org/issues/3981

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 40524105
BusMemoryConnectionCompositor.java 81d8b07214b5ff6c56055ad6ea30a6bece1d0f0a GREEN
ClockPowerConnectionCompositor.java ce6d7e98364a0167e7c3341b0391d75a6c8821ec YELLOW
ClockPowerConnectionCompositor.java e5ee6052819f467c3becda7fb16292344187e6bf YELLOW
ClockTileConnectionCompositor.java 201d93eff305d57eb3db2b0170b6ad272a7126d0 GREEN
ClockWatchDogConnectionCompositor.java d8ce5b4bdccadbca14a679c988b241ebd768c90f GREEN
GenericPlatformSourceTargetConnectorConnectionCompositor.java fbd6381d55534fe3e2ca4c782c75e7c36d352805 GREEN
......
......@@ -24,6 +24,8 @@ import org.fortiss.af3.platform.hierarchic.model.electronics.PowerIn;
import org.fortiss.af3.platform.hierarchic.model.electronics.PowerOut;
import org.fortiss.af3.platform.model.IArchitectureDomain;
import org.fortiss.af3.platform.model.PlatformConnectorUnit;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.extension.data.IConnectionCompositionContext;
......@@ -48,32 +50,72 @@ public class ClockPowerConnectionCompositor<S extends PlatformConnectorUnit & IA
public boolean canConnect(S source, T target, IHierarchicElement parent,
IConnectionCompositionContext context) {
// Only allow one input per power and clock receiver.
boolean sourceIsInput = source instanceof PowerIn || source instanceof ClockIn;
boolean targetIsInput = target instanceof PowerIn || target instanceof ClockIn;
boolean sourceConnected =
!(source.getIncoming().isEmpty() && source.getOutgoing().isEmpty());
boolean targetConnected =
!(target.getIncoming().isEmpty() && target.getOutgoing().isEmpty());
if((sourceIsInput && sourceConnected) || (targetIsInput && targetConnected)) {
return false;
}
boolean portsSameLayer =
source.eContainer().eContainer() == target.eContainer().eContainer();
boolean powerInputConnectors = source instanceof PowerIn && target instanceof PowerIn;
boolean clockInputConnectors = source instanceof ClockIn && target instanceof ClockIn;
boolean oneIsUpperLayer = (source.eContainer() == target.eContainer().eContainer()) ||
(target.eContainer() == source.eContainer().eContainer());
boolean upperLayerConnection =
oneIsUpperLayer && (powerInputConnectors || clockInputConnectors);
// Helpers to determine the number of attached connections in the same layers.
boolean sourceHasSameLayerConnection =
source.getIncoming().stream().anyMatch(c -> isSameLayer(c, parent)) ||
source.getOutgoing().stream().anyMatch(c -> isSameLayer(c, parent));
boolean targetHasSameLayerConnection =
target.getIncoming().stream().anyMatch(c -> isSameLayer(c, parent)) ||
target.getOutgoing().stream().anyMatch(c -> isSameLayer(c, parent));
boolean sourceInputHasSameLayerConnection =
(source instanceof PowerIn || source instanceof ClockIn) &&
sourceHasSameLayerConnection;
boolean targetInputHasSameLayerConnection =
(target instanceof PowerIn || target instanceof ClockIn) &&
targetHasSameLayerConnection;
//
// Same-layer logic.
//
// For connectors attached to elements of the same layer, only allow connections between
// outs and ins.
boolean powerInToOutConnection = source instanceof PowerIn && target instanceof PowerOut ||
source instanceof PowerOut && target instanceof PowerIn;
boolean clockInToOutConnection = source instanceof ClockIn && target instanceof ClockOut ||
source instanceof ClockOut && target instanceof ClockIn;
boolean sameLayerCOnnection =
!oneIsUpperLayer && (powerInToOutConnection || clockInToOutConnection);
boolean validSameLayerConnectorTypes =
portsSameLayer && (powerInToOutConnection || clockInToOutConnection);
// Only allow one connection input per power and clock receiver. This holds only for the
// same layer since multiple connections may exist through layers for distributing power or
// clocks to child elements.
boolean isSameLayerInputUnconnected =
!sourceInputHasSameLayerConnection && !targetInputHasSameLayerConnection;
boolean isValidSameLayerConnection =
portsSameLayer && validSameLayerConnectorTypes && isSameLayerInputUnconnected;
//
// Cross-layer logic.
//
// For power/clock distribution to child elements, we must connect the Ins of a "parent
// layer port" to Ins of the elements of the current layer.
boolean sourceIsInput = source instanceof PowerIn || source instanceof ClockIn;
boolean targetIsInput = target instanceof PowerIn || target instanceof ClockIn;
boolean validUpperLayerTypes = !portsSameLayer && (sourceIsInput && targetIsInput);
// Handle different allowed connections counts for cross-layer connections:
// * 1 parent --> n children
// * 1 child --> 1 parent
boolean sourceIsUpperLayer = source.eContainer() == target.eContainer().eContainer();
boolean targetIsUpperLayer = target.eContainer() == source.eContainer().eContainer();
boolean isValidCrossLayerConnectionCount =
(targetIsUpperLayer && !sourceInputHasSameLayerConnection) ||
(sourceIsUpperLayer && !targetInputHasSameLayerConnection);
boolean isValidCrossLayerConnection =
validUpperLayerTypes && isValidCrossLayerConnectionCount;
return isValidSameLayerConnection || isValidCrossLayerConnection;
}
return upperLayerConnection || sameLayerCOnnection;
/**
* Determines whether the given {@link IConnection} and {@link IConnector} belong to the same
* layer of an hierarchical architecture.
*/
private boolean isSameLayer(IConnection connection, IHierarchicElement parent) {
return connection.getOwner() == parent;
}
/** {@inheritDoc} */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment