Skip to content
Snippets Groups Projects
Commit a51f7977 authored by Simon Barner's avatar Simon Barner
Browse files

Deprecate ResourceLink: AllocationTables should be used instead.

- Delete unused utility methods that reference this type
- Move GPIOLinkingValueProvider and GPIOPinNumberValueProvider to af3.platform.pikeos.

refs 3261
parent b9ded55c
No related branches found
No related tags found
No related merge requests found
AF3Utils.java bbb1d95274ec4d8ae298193e195e81fc2a3aa74a RED
AF3Utils.java 21464822e84d3084af72ad0248bac03033989041 RED
DesignSpaceExplorationModelElementFactory.java 9dc330973f132c4b936e4dc7ee8407614faf2ff6 RED
ExplorationAlgDebugUtils.java 06116a61e99717a59b7b01e4e2865bf044a8a0e2 RED
ExplorationAlgUtils.java 1deb317ed1d276e778fb64d207a1784a4919518b RED
ExplorationAlgUtils.java 2cf411c8d8404d7319d7bc836dd74b5927375711 RED
ExplorationEcoreUtils.java 48ed07aec3cd93e66d37abc10d50636d591f1c71 RED
GraphUtils.java 8b25592f30645f7709af527c72551f038a163833 RED
TransformationUtils.java d26cb8932c3dc81e7c75694241496b96214fdb9f RED
......@@ -53,10 +53,10 @@ import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IModelElementAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding;
import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry;
......@@ -292,16 +292,17 @@ public class AF3Utils {
throws InvalidPlatformModelException {
// By the method signature, we know the instance type is a IConnector class.
@SuppressWarnings("unchecked") ConnectionType connectionTypeSource =
systemModelAdapter.getConnectionType(
(Class<? extends IConnector>)sourceConnector.eClass().getInstanceClass());
systemModelAdapter.getConnectionType((Class<? extends IConnector>)sourceConnector
.eClass().getInstanceClass());
@SuppressWarnings("unchecked") ConnectionType connectionTypeTarget =
systemModelAdapter.getConnectionType(
(Class<? extends IConnector>)targetConnector.eClass().getInstanceClass());
systemModelAdapter.getConnectionType((Class<? extends IConnector>)targetConnector
.eClass().getInstanceClass());
// assert (connectionTypeSource != null && connectionTypeTarget != null) :
// "Could not identify the type of one of the connection targets.";
if((connectionTypeSource == INCOMING && connectionTypeTarget == INCOMING) ||
(connectionTypeSource == OUTGOING && connectionTypeTarget == OUTGOING)) {
throw new InvalidPlatformModelException((PlatformConnectorUnit)sourceConnector,
throw new InvalidPlatformModelException(
(PlatformConnectorUnit)sourceConnector,
"A platform port or interface (see above) for incoming or outgoing traffic is connected to an port or interface of the same type. This is not allowed.");
}
......@@ -335,8 +336,8 @@ public class AF3Utils {
SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) {
// By the method signature, we know the instance type is a IConnector class.
@SuppressWarnings("unchecked") ConnectionType connectionTypeSource =
systemModelAdapter.getConnectionType(
(Class<? extends IConnector>)sourceConnector.eClass().getInstanceClass());
systemModelAdapter.getConnectionType((Class<? extends IConnector>)sourceConnector
.eClass().getInstanceClass());
return connectionTypeSource != null ? connectionTypeSource : BIDIRECTIONAL;
}
......@@ -344,8 +345,8 @@ public class AF3Utils {
* Predicate whether the subject {@link PlatformConnectorUnit} is a connector of the given
* {@link IModelElementAdapter}.
*/
public static boolean isConnectorOf(PlatformConnectorUnit pConn,
IModelElementAdapter<?> element) {
public static boolean
isConnectorOf(PlatformConnectorUnit pConn, IModelElementAdapter<?> element) {
return pConn.getOwner() == element.getObject();
}
......@@ -364,16 +365,18 @@ public class AF3Utils {
* {@link PlatformConnectorUnit} for the device-internal communication of the given
* {@link IModelElementAdapter}.
*/
public static boolean isDeviceInternalPredecessor(PlatformConnectorUnit connCandidate,
IModelElementAdapter<?> element,
DirectedGraph<PlatformConnectorUnit, DefaultEdge> route) {
public static boolean
isDeviceInternalPredecessor(PlatformConnectorUnit connCandidate,
IModelElementAdapter<?> element,
DirectedGraph<PlatformConnectorUnit, DefaultEdge> route) {
// The following rules apply for device internal communication:
// - Sender Port is on the same device OR
// - its reference port is one layer "below", e.g. Gateway -> Router AND
// - the sender connector must have been traversed (natural for path walking a multicast
// message.
if(route.containsVertex(connCandidate) && (isConnectorOf(connCandidate, element) ||
isContainedInResource(connCandidate, element))) {
if(route.containsVertex(connCandidate) &&
(isConnectorOf(connCandidate, element) || isContainedInResource(connCandidate,
element))) {
return true;
}
return false;
......@@ -431,12 +434,9 @@ public class AF3Utils {
* Checks whether any parent {@link IPlatformResource} of the given {@code element} is a
* deployment target defined by the set of deployment targets ({@code deploymentTargets}).
* If any parent element has been found that is a deployment target, {@code true} is returned.
* The method considers parents in the following order:
* <li>Check the direct parent (container).
* </li>
* <li>Check all referenced resources as defined in the {@link ResourceLink} annotation.</li>
* <li>Go to the parent resource and run the same checks.</li>
* <li>Run the above checks for all
* The method considers parents in the following order: <li>Check the direct parent (container).
* </li> <li>Check all referenced resources as defined in the {@link ResourceLink} annotation.</li>
* <li>Go to the parent resource and run the same checks.</li> <li>Run the above checks for all
* references Resources as given by the {@link ResourceLink} annotations.</>
*
* @param element
......@@ -484,8 +484,8 @@ public class AF3Utils {
public static <T extends IPlatformResource & IHierarchicElement> boolean
isAnyChildDeploymentTarget(IPlatformResource element, Collection<T> deploymentTargets,
Class<T> targetType) {
return getChildrenWithType(element, targetType).stream()
.anyMatch(child -> deploymentTargets.contains(child));
return getChildrenWithType(element, targetType).stream().anyMatch(
child -> deploymentTargets.contains(child));
}
/**
......@@ -499,9 +499,11 @@ public class AF3Utils {
* thereby establish a "communication link" between both platforms.
* @return Map representing the "inverse" 1:1 references of {@link ResourceLink}s.
*/
public static Map<IModelElement, IModelElement> getInverseIntraPlatformReferences(
PlatformArchitecture referencingPlatformArchitecture,
Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> interPlatformConnectingElements) {
public static
Map<IModelElement, IModelElement>
getInverseIntraPlatformReferences(
PlatformArchitecture referencingPlatformArchitecture,
Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> interPlatformConnectingElements) {
if(interPlatformConnectingElements == null) {
return Collections.emptyMap();
}
......@@ -520,33 +522,6 @@ public class AF3Utils {
return invElementReferences;
}
/**
* Returns a map containing the inverse references represented by {@link ResourceLink}s between
* {@link IModelElement}s of {@link PlatformArchitecture}s.
*
* @param af3Deployment
* {@link Deployment} for whose linked {@link PlatformArchitecture} the inverse
* {@link ResourceLink} references have to be found.
* @param interPlatformConnectingElements
* {@link Pair} of {@link IModelElement} classes identifying those element types that
* reference (first element) another element of another platform (second element) and
* thereby establish a "communication link" between both platforms.
* @return The inverse {@link ResourceLink} references, or an empty map if none were identified.
*/
public static Map<IModelElement, IModelElement> getInverseIntraPlatformReferences(
Deployment af3Deployment,
Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> interPlatformConnectingElements) {
IModelElement platformReference =
af3Deployment.getPlatformArchitectureReference().getReference();
PlatformArchitecture af3PlatformArchitecture = null;
if(platformReference instanceof PlatformArchitecture) {
af3PlatformArchitecture = (PlatformArchitecture)platformReference;
return getInverseIntraPlatformReferences(af3PlatformArchitecture,
interPlatformConnectingElements);
}
return Collections.emptyMap();
}
/**
* Searches the given {@link ComponentArchitecture} for {@link ComponentDiverseImplRef}s and
* returns all referenced {@link Component}s (representing an implementation of the referencing
......@@ -581,12 +556,12 @@ public class AF3Utils {
* @return Set of {@link ComponentMultiAllocationConstraint}s with the same references as the
* {@link ComponentAllocation}s.
*/
public static Collection<ComponentMultiAllocationConstraint>
createConstraintsFromDeployment(Deployment deployment) {
public static Collection<ComponentMultiAllocationConstraint> createConstraintsFromDeployment(
Deployment deployment) {
Collection<ComponentAllocation> allocatedComponents = deployment.getComponentAllocations();
Function<ComponentAllocation, ComponentMultiAllocationConstraint> mapper =
ca -> createComponentMultiAllocationConstraint(ca.getComponent(),
new BasicEList<>(Arrays.asList(ca.getExecutionUnit())));
ca -> createComponentMultiAllocationConstraint(ca.getComponent(), new BasicEList<>(
Arrays.asList(ca.getExecutionUnit())));
return allocatedComponents.stream().map(mapper)
.map(ComponentMultiAllocationConstraint.class::cast).collect(Collectors.toList());
}
......@@ -604,8 +579,10 @@ public class AF3Utils {
* @return The {@link ComponentArchitecture} identified as the <i>Component Pool</i> or
* {@code null} if none is found.
*/
public static ComponentArchitecture getFirstComponentPool(
IMappingEncoding<ITaskAdapter<?>, IResourceAdapter<?>, IMappingEntry<ITaskAdapter<?>, IResourceAdapter<?>>> mapping) {
public static
ComponentArchitecture
getFirstComponentPool(
IMappingEncoding<ITaskAdapter<?>, IResourceAdapter<?>, IMappingEntry<ITaskAdapter<?>, IResourceAdapter<?>>> mapping) {
for(ITaskAdapter<?> deployableComponent : mapping.getRequesters()) {
if(deployableComponent.isInstantiation()) {
// TODO: Avoid casting: Parameterize the IModelElementAdapter to use EObject-derived
......@@ -695,8 +672,9 @@ public class AF3Utils {
EList<Component> parentElements = getParentsWithType(startElement, Component.class);
for(Component parentComponent : parentElements) {
AbstractTaskMappingEntry entry = (AbstractTaskMappingEntry)encEntryModelElemAssoc
.inverse().get(parentComponent, AbstractTaskMappingEntry.class);
AbstractTaskMappingEntry entry =
(AbstractTaskMappingEntry)encEntryModelElemAssoc.inverse().get(parentComponent,
AbstractTaskMappingEntry.class);
if(entry != null) {
return true;
}
......@@ -731,8 +709,7 @@ public class AF3Utils {
}
}
if(systemModelAdapter.isDeployableComponent(deployComponent) ||
(!isAnyParentComponentDeployable(deployComponent, systemModelAdapter) &&
isAtomicComponent(deployComponent))) {
(!isAnyParentComponentDeployable(deployComponent, systemModelAdapter) && isAtomicComponent(deployComponent))) {
return true;
}
return false;
......
......@@ -51,12 +51,10 @@ import org.fortiss.af3.exploration.model.ExplorationTarget;
import org.fortiss.af3.exploration.model.IProblemDimension;
import org.fortiss.af3.platform.model.IPlatformResource;
import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement;
import org.fortiss.af3.platform.model.annotation.ResourceLink;
import org.fortiss.af3.platform.utils.PlatformArchitectureUtils;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import com.google.common.collect.Multimap;
......@@ -82,8 +80,8 @@ public class ExplorationAlgUtils {
// FIXME: Remove this method, it is unsafe and cannot be used with instances of EList which have
// parameterized constructors (Factory pattern).
@SuppressWarnings("unchecked")
public static <C extends Collection<T>, T, CR extends Collection<? super T>> CR
castToRawColl(C origCollection) {
public static <C extends Collection<T>, T, CR extends Collection<? super T>> CR castToRawColl(
C origCollection) {
CR castedCollection = (CR)Collections.emptySet();
if(origCollection != null && !origCollection.isEmpty()) {
try {
......@@ -113,8 +111,8 @@ public class ExplorationAlgUtils {
// FIXME: Remove this method, it is unsafe and cannot be used with instances of EList which have
// parameterized constructors (Factory pattern).
@SuppressWarnings("unchecked")
public static <C extends Collection<T>, T, CR extends Collection<? super T>> CR
castToRawColl(C origCollection, Class<CR> castedCollType) {
public static <C extends Collection<T>, T, CR extends Collection<? super T>> CR castToRawColl(
C origCollection, Class<CR> castedCollType) {
CR castedCollection = (CR)Collections.emptySet();
if(origCollection != null && !origCollection.isEmpty()) {
try {
......@@ -192,10 +190,10 @@ public class ExplorationAlgUtils {
for(OutputPort currentOutputPort : allOutputPortsInArch) {
// Filter out ports that represent the transition through a hierarchic hull.
if(currentOutputPort.getIncoming().isEmpty() /*
* &&
* !isAnyParentComponentDeployable(
* currentOutputPort.getComponent())
*/) {
* &&
* !isAnyParentComponentDeployable(
* currentOutputPort.getComponent())
*/) {
// FIXME: HERE
sourcePortList.add(currentOutputPort);
}
......@@ -211,8 +209,8 @@ public class ExplorationAlgUtils {
* Collection of all {@link OutputPort}s of 'deployable' {@link Component}s.
* @return List of 'deployable' {@link OutputPort}s or an empty list if none can be identified.
*/
public static EList<OutputPort>
getDeployableOutputPorts(Collection<Component> deployableComponents) {
public static EList<OutputPort> getDeployableOutputPorts(
Collection<Component> deployableComponents) {
EList<OutputPort> sourcePortList = new BasicEList<OutputPort>();
for(Component component : deployableComponents) {
......@@ -343,9 +341,8 @@ public class ExplorationAlgUtils {
public static boolean isPlatformTargetResource(IPlatformResource element,
Collection<IPlatformResource> targetResources) {
if(!isAnyParentDeploymentTarget(element, targetResources) &&
(element instanceof IHierarchicElementContainer &&
((IHierarchicElementContainer)element).getContainedElements().isEmpty()) ||
targetResources.contains(element)) {
(element instanceof IHierarchicElementContainer && ((IHierarchicElementContainer)element)
.getContainedElements().isEmpty()) || targetResources.contains(element)) {
return true;
}
return false;
......@@ -415,66 +412,6 @@ public class ExplorationAlgUtils {
return (Collections.disjoint(selfAndParentElements, virtualizedResources)) ? false : true;
}
/**
* Collects and returns all {@link IModelElementSpecification}s of the given type which are
* contained in the specification list of the elements and their children which are referenced
* by a {@link ResourceLink} {@link IModelElementSpecification} of the given
* {@link IModelElement}. If no {@link ResourceLink} is specified for the given
* {@link IModelElement} or if no referenced {@link IModelElement} or one of its children
* contains a {@link IModelElementSpecification} of the given type, an empty list is returned.
*
* @param specType
* The {@link IModelElementSpecification} type to search for.
* @param modelElement
* {@link IModelElement} containing a {@link ResourceLink} to other
* {@link IModelElement}s.
* @return List of {@link IModelElementSpecification}s contained in the referenced
* {@link IModelElement}s or one of its children.
*/
public static <T extends IModelElementSpecification> List<T>
getAllReferencedSpecificationsWithType(Class<T> specType, IModelElement modelElement) {
List<T> specifications = new ArrayList<T>();
if(modelElement == null) {
return specifications;
}
Collection<IHierarchicElement> referencedElements =
getReferencedElementsWithType(modelElement, IHierarchicElement.class);
for(IHierarchicElement refElement : referencedElements) {
specifications.addAll(getChildrenWithType(refElement, specType));
}
return specifications;
}
/**
* Returns the {@link ResourceLink} {@link IModelElementSpecification} of the given
* {@link IModelElement} or the {@link ResourceLink} or the {@link ResourceLink} of the parent
* {@link IModelElement} that is "closest" to the given {@link IModelElement} regarding the
* hierarchy.
*
* @param element
* The {@link IModelElement} which a matching (see above) {@link ResourceLink} shall
* be found.
* @return {@link ResourceLink} {@link IModelElementSpecification}, or <code>null</code> if
* neither the given {@link IModelElement}, nor any of its containing elements contains
* a {@link ResourceLink} {@link IModelElementSpecification}.
*/
public static ResourceLink getSelfOrAnyParentResourceLink(IModelElement element) {
ResourceLink resourceLink =
pickFirstInstanceOf(ResourceLink.class, element.getSpecifications());
if(resourceLink == null) {
List<ResourceLink> parentResourceLinks =
getParentsWithType(element, ResourceLink.class);
if(!parentResourceLinks.isEmpty()) {
// List is ordered from the element itself to the top element -> find "closest"
// resource link of the given element.
resourceLink = parentResourceLinks.get(0);
}
}
return resourceLink;
}
/**
* Determines whether the given {@link IHierarchicElement}s are contained within the
* same (parent) {@link IHierarchicElement}.
......@@ -761,6 +698,6 @@ public class ExplorationAlgUtils {
*/
@SuppressWarnings("unchecked")
public static <T extends Exception> RuntimeException rethrow(Exception exception) throws T {
throw(T)exception; // rely on vacuous cast
throw (T)exception; // rely on vacuous cast
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment