Commit 832f5d22 authored by Liana Soima's avatar Liana Soima
Browse files

Merge branch 'master' of https://git.fortiss.org/af3/af3.git into 3976

parents 5768c4b6 b47c281c
......@@ -164,6 +164,7 @@
<!-- Model connection compositors -->
<!--===============================-->
<extension point="org.fortiss.tooling.kernel.modelConnectionCompositor">
<!-- Port to interface (same level), Port to export (port at container level of export) -->
<modelConnectionCompositor modelConnectionCompositor="org.fortiss.af3.platform.hierarchic.compose.connections.PortInterfaceExportConnectionCompositor">
<source>
......@@ -545,6 +546,62 @@
</target>
</modelConnectionCompositor>
<!-- Power and clock distribution accross layers. The explicit specification of In and Out
Connectors is required for not triggering the default connection compositor. -->
<modelConnectionCompositor modelConnectionCompositor="org.fortiss.af3.platform.hierarchic.compose.connections.ClockPowerConnectionCompositor">
<source>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.ClockIn"/>
</source>
<target>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.ClockIn"/>
</target>
</modelConnectionCompositor>
<modelConnectionCompositor modelConnectionCompositor="org.fortiss.af3.platform.hierarchic.compose.connections.ClockPowerConnectionCompositor">
<source>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.PowerIn"/>
</source>
<target>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.PowerIn"/>
</target>
</modelConnectionCompositor>
<modelConnectionCompositor modelConnectionCompositor="org.fortiss.af3.platform.hierarchic.compose.connections.ClockPowerConnectionCompositor">
<source>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.PowerOut"/>
</source>
<target>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.PowerIn"/>
</target>
</modelConnectionCompositor>
<modelConnectionCompositor modelConnectionCompositor="org.fortiss.af3.platform.hierarchic.compose.connections.ClockPowerConnectionCompositor">
<source>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.PowerIn"/>
</source>
<target>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.PowerOut"/>
</target>
</modelConnectionCompositor>
<modelConnectionCompositor modelConnectionCompositor="org.fortiss.af3.platform.hierarchic.compose.connections.ClockPowerConnectionCompositor">
<source>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.ClockIn"/>
</source>
<target>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.ClockOut"/>
</target>
</modelConnectionCompositor>
<modelConnectionCompositor modelConnectionCompositor="org.fortiss.af3.platform.hierarchic.compose.connections.ClockPowerConnectionCompositor">
<source>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.ClockOut"/>
</source>
<target>
<modelElementClass modelElementClass="org.fortiss.af3.platform.hierarchic.model.electronics.ClockIn"/>
</target>
</modelConnectionCompositor>
<!--
Note that due to the required registration to handle the special case (Tile, WatchDog, Clock)
also all other connections involving Tiles to be explicitly registered.
......
ConnectionCompositorBase.java 14c859c7d3c19c25edb8884b21f8f2915c644b3d GREEN
GenericPlatformSourceTargetConnectorConnectionCompositorBase.java 656a00deecd529d1b22f168b779fafd660b1aa96 GREEN
GenericPlatformSourceTargetConnectorConnectionCompositorBase.java 1c996511209871a2b1c5fa52f3230abbefa4ca26 GREEN
IArchitectureDomainDependant.java f7fef7e058ed9dcbaad3dbf5872f69d5fe508861 GREEN
IPlatformHierarchicalCompositionRules.java 648d414616d6413c44909d2bdd92e2936905c0e9 GREEN
PlatformArchitectureCompositorBase.java a0fc2716f45ea31bbed8e43ae02243cd83194ff1 GREEN
......
......@@ -37,6 +37,11 @@ public abstract class GenericPlatformSourceTargetConnectorConnectionCompositorBa
public boolean canConnect(S source, T target, IHierarchicElement parent,
IConnectionCompositionContext context) {
// Only use this compositor for elements of the same level.
if(source.eContainer().eContainer() != target.eContainer().eContainer()) {
return false;
}
@SuppressWarnings("unchecked") Class<? extends IArchitectureDomain> sourceClass =
(Class<? extends IArchitectureDomain>)source.getClass();
......
BusMemoryConnectionCompositor.java 81d8b07214b5ff6c56055ad6ea30a6bece1d0f0a GREEN
ClockPowerConnectionCompositor.java e5ee6052819f467c3becda7fb16292344187e6bf GREEN
ClockTileConnectionCompositor.java 201d93eff305d57eb3db2b0170b6ad272a7126d0 GREEN
ClockWatchDogConnectionCompositor.java d8ce5b4bdccadbca14a679c988b241ebd768c90f GREEN
GenericPlatformSourceTargetConnectorConnectionCompositor.java fbd6381d55534fe3e2ca4c782c75e7c36d352805 GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2014 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.hierarchic.compose.connections;
import org.fortiss.af3.platform.hierarchic.compose.HierarchicalCompositionRules;
import org.fortiss.af3.platform.hierarchic.compose.base.GenericPlatformSourceTargetConnectorConnectionCompositorBase;
import org.fortiss.af3.platform.hierarchic.compose.base.IPlatformHierarchicalCompositionRules;
import org.fortiss.af3.platform.hierarchic.model.electronics.ClockIn;
import org.fortiss.af3.platform.hierarchic.model.electronics.ClockOut;
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;
/**
* Specific connection compositor for connecting {@link PowerIn}/{@link PowerOut}s or
* {@link ClockIn}/{@link ClockOut}s. It supports connections from an upper layer to the current
* one. Used to model power and clock distribution networks.
*
* @author barner
*/
public class ClockPowerConnectionCompositor<S extends PlatformConnectorUnit & IArchitectureDomain, T extends PlatformConnectorUnit & IArchitectureDomain>
extends GenericPlatformSourceTargetConnectorConnectionCompositorBase<S, T> {
/** {@inheritDoc} */
@Override
public IPlatformHierarchicalCompositionRules getPlatformCompositionRules() {
return HierarchicalCompositionRules.INSTANCE;
}
/** {@inheritDoc} */
@Override
public boolean canConnect(S source, T target, IHierarchicElement parent,
IConnectionCompositionContext context) {
boolean portsSameLayer =
source.eContainer().eContainer() == target.eContainer().eContainer();
// 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 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;
}
/**
* 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} */
@Override
public Class<? extends IArchitectureDomain> getArchitectureDomain() {
// TODO Auto-generated method stub
return null;
}
}
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