Commit d44da2f7 authored by Simon Barner's avatar Simon Barner
Browse files

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



Conflicts:
	org.fortiss.af3.exploration/src/org/fortiss/af3/exploration/util/.ratings
	org.fortiss.af3.task/src/org/fortiss/af3/task/util/.ratings
Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parents ad4387ee 666de4d8
......@@ -3,7 +3,7 @@ DashboardWizardRootElementSelectionBase.java 1fe550598f11da4cdcf1ecc02173dfc2b99
DashboardWizardSelectAllocation.java 1a9a0db43c3d8e2247804be2de6eccbd0a9aa48c GREEN
DashboardWizardSelectComponentArchitecture.java 26ee0bd9412f05dfad0903d86bda159b0629b722 GREEN
DashboardWizardSelectDataDictionary.java 8322cfbd0c0b0019b67de766303137f2fab77a2d GREEN
DashboardWizardSelectPlatformArchitecture.java c5aadd59e7904d8d7c12a6827abb7357bc3904a2 GREEN
DashboardWizardSelectPlatformArchitecture.java be7a3b016564cf2cd16f14efbe75c58aca3dbc79 GREEN
DashboardWizardSelectProjectSource.java 9463d2a5fc69c015ae487606fa529b888b4f9e7c GREEN
DashboardWizardSelectReqirements.java d6bf47af1bcdea062d58f653c1cc1c99f7f790de GREEN
DashboardWizardSelectTaskArchitecture.java 8e52e852435047dba0f68d8dc454a8eb3159e461 GREEN
......
......@@ -16,9 +16,9 @@
package org.fortiss.af3.exploration.ui.perspective.dashboard.projectwizard;
import static org.fortiss.af3.exploration.util.ModelSnapshotExtractUtils.createPlatformArchitectureSnapshot;
import static org.fortiss.af3.exploration.util.ModelSnapshotExtractUtils.getExecutionUnits;
import static org.fortiss.af3.exploration.util.ModelSnapshotExtractUtils.getGatewayUnits;
import static org.fortiss.af3.exploration.util.ModelSnapshotExtractUtils.getTransmissionUnits;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAllGatewayUnits;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAtomicTransmissionUnits;
import static org.fortiss.af3.task.util.TaskArchitectureUtils.findTargetExecutionUnits;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
......@@ -49,15 +49,16 @@ public class DashboardWizardSelectPlatformArchitecture
PlatformArchitecture pa = getParentElement(element, PlatformArchitecture.class, false);
// Highlight relevant structural elements
return getExecutionUnits(pa).contains(element) || getGatewayUnits(pa).contains(element) ||
getTransmissionUnits(pa).contains(element);
return findTargetExecutionUnits(pa).contains(element) ||
findAllGatewayUnits(pa).contains(element) ||
findAtomicTransmissionUnits(pa).contains(element);
}
/** {@inheritDoc} */
@Override
protected boolean isRelevantRootElement(PlatformArchitecture platformArchitecture) {
// We need at least one ExecutionUnit
return !getExecutionUnits(platformArchitecture).isEmpty();
return !findTargetExecutionUnits(platformArchitecture).isEmpty();
}
/** {@inheritDoc} */
......
......@@ -5,5 +5,5 @@ DSMLUtils.java c07eeef09787cea9db98533d346e3e384a232593 GREEN
ExplorationModelElementFactory.java bb48b2d09b92efcb1b2d3e382555089bb7ed5db5 GREEN
ExplorationReflectionUtils.java 62731e1cef32fe93f2c2017f93f5ba1f054d5197 GREEN
ExplorationUtils.java cd48d4910a1a6668d8c39cbd93c220e1b87bdef4 YELLOW
ModelSnapshotExtractUtils.java dde8b42c5a7228478ffe8c67820bcac91e875562 GREEN
ModelSnapshotExtractUtils.java 940c5f0e2859519522ae8edfda63e05112870776 GREEN
PatternFactoryUtils.java bcb1d325aecfef12d29d4eb53b28fe59dbd20e9a GREEN
......@@ -19,16 +19,19 @@ import static java.util.Arrays.asList;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createModelSnapshot;
import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createSuperSet;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createSuperSetMap;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAllGatewayUnits;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAllMemoryUnits;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAllTransmissionConnections;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAtomicTransmissionUnits;
import static org.fortiss.af3.platform.utils.RouteUtils.extractRoutes;
import static org.fortiss.af3.task.util.TaskArchitectureUtils.findTargetExecutionUnits;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateMissingIDs;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.getLargestID;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.fortiss.af3.allocation.IAllocationService;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
......@@ -57,7 +60,6 @@ import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationEntry;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationTable;
import org.fortiss.af3.task.model.allocation.TaskWcetTable;
import org.fortiss.af3.timing.model.TimingSpecification;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
/**
......@@ -107,16 +109,17 @@ public class ModelSnapshotExtractUtils {
* {@link TransmissionConnection}s and {@link Route}s.
*/
public static ModelSnapshot createPlatformArchitectureSnapshot(PlatformArchitecture platArch) {
SuperSet<ExecutionUnit> exUnits =
createSuperSet(getExecutionUnits(platArch), "ExecUnits", ExecutionUnit.class);
SuperSet<TransmissionUnit> tmUnits = createSuperSet(getTransmissionUnits(platArch),
SuperSet<ExecutionUnit> exUnits = createSuperSet(findTargetExecutionUnits(platArch),
"ExecUnits", ExecutionUnit.class);
SuperSet<TransmissionUnit> tmUnits = createSuperSet(findAtomicTransmissionUnits(platArch),
"TransUnits", TransmissionUnit.class);
SuperSet<GatewayUnit> gwUnits =
createSuperSet(getGatewayUnits(platArch), "GWUnits", GatewayUnit.class);
createSuperSet(findAllGatewayUnits(platArch), "GWUnits", GatewayUnit.class);
SuperSet<MemoryUnit> memUnits =
createSuperSet(getMemoryUnits(platArch), "MemUnits", MemoryUnit.class);
SuperSet<TransmissionConnection> platConnections = createSuperSet(
getTransmissionConnection(platArch), "Connections", TransmissionConnection.class);
createSuperSet(findAllMemoryUnits(platArch), "MemUnits", MemoryUnit.class);
SuperSet<TransmissionConnection> platConnections =
createSuperSet(findAllTransmissionConnections(platArch), "Connections",
TransmissionConnection.class);
// If the platform already contains routes, they are used to define the respective super
// set. Otherwise, a new set of routes extracted.
......@@ -140,48 +143,6 @@ public class ModelSnapshotExtractUtils {
return createModelSnapshot(platArch, superSetMap);
}
/**
* Returns all relevant {@link ExecutionUnit}s of the given {@link PlatformArchitecture}, i.e.
* the {@link ExecutionUnit}s to which {@link Task}s can be allocated using
* {@link TaskToExecutionUnitAllocationEntry}s.
*/
@SuppressWarnings("unchecked")
public static List<ExecutionUnit> getExecutionUnits(PlatformArchitecture platArch) {
// Returns
List<ExecutionUnit> rval = new ArrayList<>();
for(Class<? extends IModelElement> executionUnitType : IAllocationService.getInstance()
.getTargetEntityTypes(TaskToExecutionUnitAllocationEntry.class)) {
rval.addAll((List<ExecutionUnit>)getChildrenWithType(platArch, executionUnitType));
}
return rval;
}
/** Returns all relevant {@link TransmissionUnit}s of the given {@link PlatformArchitecture} */
public static List<TransmissionUnit> getTransmissionUnits(PlatformArchitecture platArch) {
return getChildrenWithType(platArch, TransmissionUnit.class);
}
/** Returns all relevant {@link GatewayUnit}s of the given {@link PlatformArchitecture} */
public static List<GatewayUnit> getGatewayUnits(PlatformArchitecture platArch) {
return getChildrenWithType(platArch, GatewayUnit.class);
}
/** Returns all relevant {@link MemoryUnit}s of the given {@link PlatformArchitecture} */
public static List<MemoryUnit> getMemoryUnits(PlatformArchitecture platArch) {
return getChildrenWithType(platArch, MemoryUnit.class);
}
/**
* Returns all relevant {@link TransmissionConnection}s of the given
* {@link PlatformArchitecture}
*/
public static List<TransmissionConnection>
getTransmissionConnection(PlatformArchitecture platArch) {
return getChildrenWithType(platArch, TransmissionConnection.class);
}
/**
* Creates a {@link ModelSnapshot} of a {@link DataDictionary} that may be required when a
* {@link ComponentArchitecture} is imported (references to functions and data types).
......
......@@ -7,7 +7,8 @@ Bundle-Version: 2.16.0.qualifier
Bundle-Activator: org.fortiss.af3.platform.ui.AF3PlatformUIActivator
Require-Bundle: org.fortiss.af3.platform;visibility:=reexport,
org.fortiss.af3.component.ui;visibility:=reexport,
org.fortiss.af3.allocation.ui;visibility:=reexport
org.fortiss.af3.allocation.ui;visibility:=reexport,
org.fortiss.af3.task;visibility:=reexport
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Vendor: fortiss GmbH
......
......@@ -80,6 +80,9 @@
<extension point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
<contextMenuContribution contributor="org.fortiss.af3.platform.ui.generator.BareMetalGeneratorEasyStartMenu"/>
</extension>
<extension point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
<contextMenuContribution contributor="org.fortiss.af3.platform.ui.menu.RouteGeneratorStartMenu" />
</extension>
<!-- Property sections -->
<extension
......
RouteGeneratorStartMenu.java 6bba3930d0fe55a77747a9023940333546e4a3d1 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2019 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.ui.menu;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.askQuestion;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo;
import static org.eclipse.emf.ecore.util.EcoreUtil.deleteAll;
import static org.fortiss.af3.platform.ui.AF3PlatformUIActivator.getImageDescriptor;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAllGatewayUnits;
import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.findAtomicTransmissionUnits;
import static org.fortiss.af3.platform.utils.RouteUtils.extractRoutes;
import static org.fortiss.af3.task.util.TaskArchitectureUtils.findTargetExecutionUnits;
import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.BOTTOM_MOST_MENU_SECTION_ID;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getAllReferences;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.computeFullyQualifiedName;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.runAsCommand;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateMissingIDs;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.getLargestID;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.GatewayUnit;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.Route;
import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
/**
* Crates a context menu entry to generate the {@link Route}s for the selected
* {@link PlatformArchitecture};
*
* @author munaro
*/
public class RouteGeneratorStartMenu implements IContextMenuContributor {
/** References the selected {@link PlatformArchitecture}. */
private PlatformArchitecture platformArchitecture;
/** String appearing in the context menu. */
private static final String MENU_NAME = "Extract routes";
/** {@inheritDoc} */
@Override
public List<IContributionItem> getContributedItems(EObject selection,
ContextMenuContextProvider contextProvider) {
if(selection instanceof PlatformArchitecture) {
platformArchitecture = (PlatformArchitecture)selection;
return asList(new IContributionItem[] {
new ActionContributionItem(new RouteGenerationAction())});
}
return emptyList();
}
/** {@inheritDoc} */
@Override
public String getMenuSectionID() {
return BOTTOM_MOST_MENU_SECTION_ID;
}
/** Returns the icon that is visible in the context menu for this entry. */
protected ImageDescriptor getActionIcon() {
return getImageDescriptor("icons/componentarchitecture.gif");
}
/** Action for generating the set of {@link Route}s. */
protected class RouteGenerationAction extends Action {
/** Constructor. */
public RouteGenerationAction() {
super(MENU_NAME, getActionIcon());
}
/** {@inheritDoc} */
@Override
public void run() {
// Check for existing routes
Collection<Route> existingRoutes = platformArchitecture.getRoutes();
if(!existingRoutes.isEmpty()) {
// Retrieve all objects referencing the existing routes
Collection<EObject> referencingObjects = existingRoutes.stream()
.flatMap(route -> getAllReferences(route).stream()).collect(toSet());
// If there are objects referencing the existing set of routes ask the user whether
// to delete them and extract new routes or abort the operation.
if(!referencingObjects.isEmpty()) {
Collection<INamedElement> namedContainers =
getNamedContainers(referencingObjects);
if(askQuestion("Existing routes found!", buildQuestion(namedContainers))) {
runAsCommand(platformArchitecture, () -> {
deleteAll(referencingObjects, false);
});
} else {
return;
}
}
}
// Extract required units
Collection<ExecutionUnit> executionUnits =
findTargetExecutionUnits(platformArchitecture);
Collection<TransmissionUnit> transmissionUnits =
findAtomicTransmissionUnits(platformArchitecture);
Collection<GatewayUnit> gatewayUnits = findAllGatewayUnits(platformArchitecture);
// Generate routes
Collection<Route> extractedRoutes =
extractRoutes(executionUnits, transmissionUnits, gatewayUnits);
// Idempotent update of routes
runAsCommand(platformArchitecture, () -> {
// Remove existing routes as there is no reason to keep out-dated ones
platformArchitecture.getRoutes().clear();
// Add generated routes
platformArchitecture.getRoutes().addAll(extractedRoutes);
// Generate new IDs
generateMissingIDs(platformArchitecture, getLargestID(platformArchitecture));
});
// Give feedback
showInfo("Routes generated!",
"The routes for the selected platform architecture have been successfully generated!");
}
/**
* Retrieves the first {@link INamedElement} container of each {@link EObject} in the given
* {@link Collection} and returns a {@link Collection} with unique ones only.
*/
private Collection<INamedElement>
getNamedContainers(Collection<EObject> referencingObjects) {
return referencingObjects.stream()
.map(object -> getFirstParentWithType(object, INamedElement.class)).distinct()
.collect(toList());
}
/**
* Builds a {@link String} asking the user whether to delete the objects referencing
* existing {@link Route}s and extract new ones. The names of the {@link INamedElement}s in
* the given {@link Collection} are listed to inform the user about the specific artefacts
* to be removed.
*/
private String buildQuestion(Collection<INamedElement> namedContainers) {
String artefactNames = namedContainers.stream()
.map(container -> " " + computeFullyQualifiedName(container, false))
.collect(joining(",\n"));
String question = "The selected platform architecture already contains routes, " +
"some of which are being referenced in the following artefacts:\n\n" +
artefactNames + "\n\n" +
"Would you like to delete the respective references within those models " +
"and extract new routes?";
return question;
}
}
}
PlatformArchitectureUtils.java a54183fc29e9a95f5167729079bccb6f583827eb GREEN
PlatformArchitectureUtils.java a4273866965f2e06b21d356f3c4b30be5ec103c9 GREEN
PlatformModelElementFactory.java 63c5751a04d702fb78962e98b316b4f221e55a54 GREEN
ResourceConnection.java f950c531580d4c427067cf83f469657c1bb9ecb1 GREEN
RouteUtils.java 2805209c3c2fd458f620ada41c906f57cffc406e GREEN
......@@ -43,6 +43,7 @@ import org.fortiss.af3.expression.model.definitions.Structure;
import org.fortiss.af3.expression.model.definitions.StructureMember;
import org.fortiss.af3.expression.model.types.TDefinedType;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.GatewayUnit;
import org.fortiss.af3.platform.model.IArchitectureDomain;
import org.fortiss.af3.platform.model.ICommunicationMaster;
import org.fortiss.af3.platform.model.ICommunicationRole;
......@@ -57,13 +58,12 @@ import org.fortiss.af3.platform.model.IPlatformInterface;
import org.fortiss.af3.platform.model.IPlatformPort;
import org.fortiss.af3.platform.model.ISoftwarePlatformArchitectureElement;
import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement;
import org.fortiss.af3.platform.model.MemoryUnit;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.PlatformConnectorUnit;
import org.fortiss.af3.platform.model.Receiver;
import org.fortiss.af3.platform.model.Transceiver;
import org.fortiss.af3.platform.model.TransmissionConnection;
import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.af3.platform.model.Transmitter;
import org.fortiss.af3.platform.model.allocation.IAllocationTypeExecutiveLayer;
import org.fortiss.af3.platform.model.allocation.IAllocationTypeHardwareLayer;
import org.fortiss.af3.platform.model.allocation.IAllocationTypePlatformUnit;
......@@ -97,59 +97,64 @@ public class PlatformArchitectureUtils {
}
/**
* Returns the list of atomic execution units in the given platform
* architecture.
* Returns the list of all gateway units in a given platform architecture.
*
* @param pa
* the platform architecture
* @return the list of execution units
* @return the list of gateway units
*/
public static List<ExecutionUnit> findAtomicExecutionUnits(PlatformArchitecture pa) {
return findAtomicElements(pa, ExecutionUnit.class);
public static List<GatewayUnit> findAllGatewayUnits(PlatformArchitecture pa) {
return getChildrenWithType(pa, GatewayUnit.class);
}
/**
* Returns the list of all execution units in a given platform architecture.
* Returns the list of all memory units in a given platform architecture.
*
* @param pa
* the platform architecture
* @return the list of execution units (including non atomic)
* @return the list of memory units
*/
public static List<ExecutionUnit> findAllExecutionUnits(PlatformArchitecture pa) {
return getChildrenWithType(pa, ExecutionUnit.class);
public static List<MemoryUnit> findAllMemoryUnits(PlatformArchitecture pa) {
return getChildrenWithType(pa, MemoryUnit.class);
}
/**
* Returns the list of all transceivers of atomic execution units.
* Returns the list of all transmission connections in a given platform architecture.
*
* @param pa
* the platform architecture
* @return the list of transceiver elements
* @return the list of transmission connections
*/
public static List<Transceiver> findAtomicExecutionUnitTransceivers(PlatformArchitecture pa) {
return findAtomicConnectors(pa, Transceiver.class, ExecutionUnit.class);
public static List<TransmissionConnection>
findAllTransmissionConnections(PlatformArchitecture pa) {
return getChildrenWithType(pa, TransmissionConnection.class);
}
/**
* Returns the list of all transmitters of atomic execution units.
* <p>
* Returns the list of all execution units in a given platform architecture.
* </p>
* <b>See also</b>:
* {@code TaskArchitectureUtils#findTargetExecutionUnits(PlatformArchitecture)}.
*
* @param pa
* the platform architecture
* @return the list of transmitter elements
* @return the list of execution units (including non atomic)
*
*/
public static List<Transmitter> findAtomicExecutionUnitTransmitters(PlatformArchitecture pa) {
return findAtomicConnectors(pa, Transmitter.class, ExecutionUnit.class);
public static List<ExecutionUnit> findAllExecutionUnits(PlatformArchitecture pa) {
return getChildrenWithType(pa, ExecutionUnit.class);
}
/**
* Returns the list of all receivers of atomic execution units.
* Returns the list of all transceivers of atomic execution units.
*
* @param pa
* the platform architecture
* @return the list of receiver elements
* @return the list of transceiver elements
*/
public static List<Receiver> findAtomicExecutionUnitReceivers(PlatformArchitecture pa) {
return findAtomicConnectors(pa, Receiver.class, ExecutionUnit.class);
public static List<Transceiver> findAtomicExecutionUnitTransceivers(PlatformArchitecture pa) {
return findAtomicConnectors(pa, Transceiver.class, ExecutionUnit.class);
}
/**
......@@ -164,18 +169,6 @@ public class PlatformArchitectureUtils {
return getChildrenWithType(pa, IPlatformArchitectureElement.class);
}
/**
* Returns the list of all transceivers of atomic transmission units.
*
* @param pa
* the platform architecture
* @return the list of atomic transceiver elements
*/
public static List<Transceiver>
findAtomicTransmissionUnitTransceivers(PlatformArchitecture pa) {
return findAtomicConnectors(pa, Transceiver.class, TransmissionUnit.class);
}
/**
* Searches atomic hierarchic elements of the given class.
*
......
ComponentToTaskArchitectureTransformation.java 08b738ccce02094f65aef08b9ca18c629621ccca GREEN
TaskArchitectureUtils.java 85db8aa115e5f85c91d47149ac6066923182dc6c GREEN
TaskArchitectureUtils.java d2f78c9f4b30863fb63210a128fecef0f14d56ce GREEN
TaskModelElementFactory.java b952e3600d8366378ceec5626b368680a9f1605a YELLOW
......@@ -19,6 +19,7 @@ import static org.eclipse.core.runtime.Assert.isNotNull;
import static org.fortiss.af3.allocation.utils.AllocationModelElementFactory.createAllocationTableCollection;
import static org.fortiss.af3.allocation.utils.AllocationUtils.addAllocationEntry;
import static org.fortiss.af3.allocation.utils.AllocationUtils.getOrCreateAllocationTable;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
......@@ -27,6 +28,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.fortiss.af3.allocation.IAllocationService;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
......@@ -56,6 +58,7 @@ import org.fortiss.af3.task.model.allocation.TaskOutputPortToTransmitterAllocati
import org.fortiss.af3.task.model.allocation.TaskPortToTransceiverAllocationEntry;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationEntry;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationTable;
import org.fortiss.tooling.base.model.element.IModelElement;
/**
* Utility methods for handling {@link TaskArchitecture}s and its sub elements.
......@@ -216,4 +219,22 @@ public class TaskArchitectureUtils {
return ta2hw;
}
/**
* Returns all {@link ExecutionUnit}s of the given {@link PlatformArchitecture} to which
* {@link Task}s can be allocated using {@link TaskToExecutionUnitAllocationEntry}instances.
*
* @param platformArchitecture
* The {@link PlatformArchitecture} to search through
* @return {@link List} of {@link ExecutionUnit}s
*/
@SuppressWarnings("unchecked")
public static List<ExecutionUnit> findTargetExecutionUnits(PlatformArchitecture platformArchitecture) {
List<ExecutionUnit> executionUnits = new ArrayList<>();
for(Class<? extends IModelElement> executionUnitType : IAllocationService.getInstance()
.getTargetEntityTypes(TaskToExecutionUnitAllocationEntry.class)) {
executionUnits.addAll((List<ExecutionUnit>)getChildrenWithType(platformArchitecture, executionUnitType));
}
return executionUnits;
}
}
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