diff --git a/org.fortiss.af3.exploration.alg/trunk/META-INF/MANIFEST.MF b/org.fortiss.af3.exploration.alg/trunk/META-INF/MANIFEST.MF index 2e0a6e044a08801272b404bba61ed358d04bea4c..0a0b3201e67f73dff1177fadbeec45de6a29cd21 100644 --- a/org.fortiss.af3.exploration.alg/trunk/META-INF/MANIFEST.MF +++ b/org.fortiss.af3.exploration.alg/trunk/META-INF/MANIFEST.MF @@ -39,7 +39,8 @@ Require-Bundle: org.fortiss.tooling.base.ui;visibility:=reexport, org.eclipse.ui.ide;visibility:=reexport, org.fortiss.af3.exploration.smt;bundle-version="2.11.0", org.fortiss.af3.platform.hierarchic, - org.fortiss.af3.task + org.fortiss.af3.task, + org.fortiss.af3.partition;visibility:=reexport Export-Package: com.google.common.annotations, com.google.common.base, com.google.common.base.internal, diff --git a/org.fortiss.af3.exploration.alg/trunk/plugin.xml b/org.fortiss.af3.exploration.alg/trunk/plugin.xml index e0c7a73ce4adbce07c7ea54b10e3bc5436ad6998..bca0988cee5a6576ab0ad085417b0d5e70777fc6 100644 --- a/org.fortiss.af3.exploration.alg/trunk/plugin.xml +++ b/org.fortiss.af3.exploration.alg/trunk/plugin.xml @@ -202,6 +202,18 @@ modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> </modelElementClass> </transformationModule> + <transformationModule + module="org.fortiss.af3.exploration.alg.dse.modeltransformation.partition.PartitionTransformer"> + <modelElementClass + modelElementClass="org.fortiss.af3.allocation.model.AllocationTableCollection"> + </modelElementClass> + </transformationModule> + <transformationModule + module="org.fortiss.af3.exploration.alg.dse.modeltransformation.partition.PartitionTransformationStrategy"> + <modelElementClass + modelElementClass="org.fortiss.af3.allocation.model.AllocationTableCollection"> + </modelElementClass> + </transformationModule> </extension> <extension id="org.fortiss.af3.exploration.alg.transformationModule" diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings index f4da2572aed974b30525f2c2d4241a01d485253b..c013b02fd1db17e9f39a3ca091f01a8d4863069e 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings @@ -1 +1 @@ -Opt4JDseBackend.java 1e40a39efe861ae007a3629c4955e5ccceee8a92 RED +Opt4JDseBackend.java 4f9559ae2dce6b0378ef936843f521d4b5993dde RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java index ed47533ce3cec1c92f8a45b9c97a3cccb40f8ba5..0360eb468e60f3b8f9491f1a1c53de7b554a932a 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java @@ -27,6 +27,7 @@ import java.util.Optional; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.widgets.Display; import org.fortiss.af3.component.model.ComponentArchitecture; import org.fortiss.af3.exploration.alg.dse.CompositeExplorationSolution; import org.fortiss.af3.exploration.alg.dse.Explorer; @@ -122,6 +123,8 @@ public class Opt4JDseBackend implements IDseBackend { explorer.explore(dseSpec, systemModelAdapter, solPhenotypeTypes, monitor, true); explorationSolution = expResult.convertToExplorationSolution(); explorationSolution.setExplorationSpec(expSpec); + + Display.getDefault().asyncExec(() -> plotResult(explorationSolution)); } catch(Exception ex) { // TODO: readd code to present the schedule which failed... Use the LoggingService from // the kernel. diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings index 1c1866f0c6cd98a5a077df25e821824a6603d27c..028a74cf75493ae601df0bcf890c01efdf1bf4cd 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings @@ -1,4 +1,4 @@ -CompositeExplorationSolution.java 80437fd1a7022e8718b8116533afdf12015e4398 RED +CompositeExplorationSolution.java 7a32ca49d7ae4aa4ddc83a3c70ecdcfa5b1376a0 RED DSEFactory.java 0a2f2cc6a197e760c1f8223339ffa5f16856b184 RED Explorer.java 4e23a668d0b0ad236e77eec2634efe2a0a6d0a23 RED ImplicitExplorationTargetFactory.java 0b10dc4e8385bbdee0217dac783203080eb723f0 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java index 02b6f64c552c9bf1f73d2cb57b2f53d80398cbce..b03ba9979934a6ce4d685bf940d9045b38e9224e 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java @@ -18,6 +18,7 @@ package org.fortiss.af3.exploration.alg.dse; import static org.fortiss.af3.allocation.utils.AllocationModelElementFactory.createAllocationEntry; import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createSuperSet; import static org.fortiss.af3.exploration.util.DesignSpaceExplorationModelElementFactory.createSingleExplorationSolution; +import static org.fortiss.af3.partition.util.PartitionModelElementFactory.createPartition; import static org.fortiss.tooling.common.util.LambdaUtils.getFirst; import java.util.HashMap; @@ -27,6 +28,7 @@ import java.util.Map.Entry; import org.fortiss.af3.component.model.Component; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.partitionmapping.Partition; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.partitionmapping.PartitionMappingEncoding; +import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.partitionmapping.PartitionMappingEntry; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEntry; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; @@ -41,7 +43,11 @@ import org.fortiss.af3.exploration.model.solutions.ExplorationSolution; import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution; import org.fortiss.af3.exploration.model.solutions.SolutionState; import org.fortiss.af3.exploration.model.solutions.SolutionsFactory; +import org.fortiss.af3.partition.model.allocation.PartitionToExecutionUnitAllocationEntry; +import org.fortiss.af3.partition.model.allocation.TaskToPartitionAllocationEntry; +import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.allocation.ComponentToExecutionUnitAllocationEntry; +import org.fortiss.af3.task.model.Task; import org.fortiss.tooling.base.model.element.IModelElement; import org.opt4j.core.Value; @@ -52,6 +58,9 @@ import org.opt4j.core.Value; * @author barner */ public class CompositeExplorationSolution<P extends Phenotype> { + /** Relates the internal partition representation with generated AF3 Partitions. */ + private Map<Partition, org.fortiss.af3.partition.model.Partition> partToAF3PartMap = + new HashMap<>(); /** * Map to store the {@link SolutionQuantification} for all pareto-optimal @@ -170,22 +179,14 @@ public class CompositeExplorationSolution<P extends Phenotype> { singleSolution.getSubSolution(InstantiatedTaskMappingEncoding.class); PartitionMappingEncoding pmEncoding = singleSolution.getSubSolution(PartitionMappingEncoding.class); - SuperSet<ComponentToExecutionUnitAllocationEntry> compExecUnitAllocs = createSuperSet( - "Optimized_Allocations", ComponentToExecutionUnitAllocationEntry.class); - for(Partition resource : tm.getResources()) { - for(ITaskAdapter<?> task : tm.getRequesters(resource)) { - Component af3Component = task.getAssignedComponent(); - ComponentToExecutionUnitAllocationEntry allocEntry = - createAllocationEntry(ComponentToExecutionUnitAllocationEntry.class); - allocEntry.getSourceElements().add(af3Component); - allocEntry.setTargetElement( - (IModelElement)getFirst(pmEncoding.getAllocatedResourcesFor(resource)) - .get().getObject()); - compExecUnitAllocs.getEntries().add(allocEntry); - } - } singleExpSolution.getSolutionSets().put(ComponentToExecutionUnitAllocationEntry.class, - compExecUnitAllocs); + createCompExecUnitAllocs(tm, pmEncoding)); + singleExpSolution.getSolutionSets().put(org.fortiss.af3.partition.model.Partition.class, + createPartitions(pmEncoding)); + singleExpSolution.getSolutionSets().put(PartitionToExecutionUnitAllocationEntry.class, + createPartitionToExecutionUnitAllocations(pmEncoding)); + singleExpSolution.getSolutionSets().put(TaskToPartitionAllocationEntry.class, + createTaskToExecutionUnitAllocations(tm)); // Invalid solutions are filtered before. singleExpSolution.setSolutionState(SolutionState.OPTIMIZED); @@ -201,4 +202,85 @@ public class CompositeExplorationSolution<P extends Phenotype> { return expSol; } + + /** + * Creates the {@link SuperSet} of {@link ComponentToExecutionUnitAllocationEntry} calculated by + * the DSE. + */ + private SuperSet<ComponentToExecutionUnitAllocationEntry> createCompExecUnitAllocs( + InstantiatedTaskMappingEncoding<InstantiatedTaskMappingEntry> tm, + PartitionMappingEncoding pmEncoding) { + SuperSet<ComponentToExecutionUnitAllocationEntry> compExecUnitAllocs = createSuperSet( + "Optimized_Allocations", ComponentToExecutionUnitAllocationEntry.class); + for(Partition resource : tm.getResources()) { + for(ITaskAdapter<?> task : tm.getRequesters(resource)) { + Component af3Component = task.getAssignedComponent(); + ComponentToExecutionUnitAllocationEntry allocEntry = + createAllocationEntry(ComponentToExecutionUnitAllocationEntry.class); + allocEntry.getSourceElements().add(af3Component); + allocEntry.setTargetElement( + (IModelElement)getFirst(pmEncoding.getAllocatedResourcesFor(resource)).get() + .getObject()); + compExecUnitAllocs.getEntries().add(allocEntry); + } + } + return compExecUnitAllocs; + } + + /** Creates the {@link SuperSet} of generated partitions by the DSE. */ + private SuperSet<org.fortiss.af3.partition.model.Partition> + createPartitions(PartitionMappingEncoding partMapping) { + SuperSet<org.fortiss.af3.partition.model.Partition> partitions = + createSuperSet("Partitions", org.fortiss.af3.partition.model.Partition.class); + int i = 0; + for(Partition internalPartition : partMapping.getRequesters()) { + org.fortiss.af3.partition.model.Partition af3Partition = + createPartition("Partition_" + i++); + partToAF3PartMap.put(internalPartition, af3Partition); + partitions.getEntries().add(af3Partition); + } + return partitions; + } + + /** + * Creates the {@link SuperSet} of {@link TaskToPartitionAllocationEntry}s calculated by the + * DSE. + */ + private SuperSet<TaskToPartitionAllocationEntry> createTaskToExecutionUnitAllocations( + InstantiatedTaskMappingEncoding<InstantiatedTaskMappingEntry> taskMapping) { + SuperSet<TaskToPartitionAllocationEntry> allocations = + createSuperSet("TaskToPart", TaskToPartitionAllocationEntry.class); + for(InstantiatedTaskMappingEntry entry : taskMapping.getMappingEntries()) { + org.fortiss.af3.partition.model.Partition af3Partition = + partToAF3PartMap.get(entry.getTarget()); + assert (af3Partition != null) : "Error in the mapping of internal Partitions --> AF3 Partitions."; + TaskToPartitionAllocationEntry af3AllocEntry = + createAllocationEntry(TaskToPartitionAllocationEntry.class); + af3AllocEntry.getSourceElements().add((Task)entry.getSource().getObject()); + af3AllocEntry.setTargetElement(af3Partition); + allocations.getEntries().add(af3AllocEntry); + } + return allocations; + } + + /** + * Creates the {@link SuperSet} of {@link PartitionToExecutionUnitAllocationEntry}s calculated + * by the DSE. + */ + private SuperSet<PartitionToExecutionUnitAllocationEntry> + createPartitionToExecutionUnitAllocations(PartitionMappingEncoding partMapping) { + SuperSet<PartitionToExecutionUnitAllocationEntry> allocations = + createSuperSet("PartToExU", PartitionToExecutionUnitAllocationEntry.class); + for(PartitionMappingEntry entry : partMapping.getMappingEntries()) { + org.fortiss.af3.partition.model.Partition af3Partition = + partToAF3PartMap.get(entry.getSource()); + assert (af3Partition != null) : "Error in the mapping of internal Partitions --> AF3 Partitions."; + PartitionToExecutionUnitAllocationEntry af3AllocEntry = + createAllocationEntry(PartitionToExecutionUnitAllocationEntry.class); + af3AllocEntry.setSourceElement(af3Partition); + af3AllocEntry.getTargetElements().add((ExecutionUnit)entry.getTarget().getObject()); + allocations.getEntries().add(af3AllocEntry); + } + return allocations; + } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationModule.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationModule.java index fbb7ed64e78d2b65a1669205a8e2eb5badda87a0..b541848e74685ac12ac3d175c35f03e4fdd50642 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationModule.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationModule.java @@ -28,6 +28,7 @@ import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationModule; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.tooling.kernel.service.base.IEObjectAware; import com.google.common.collect.Multimap; @@ -275,6 +276,7 @@ public interface ITransformationModule<T extends EObject> */ <N extends EObject, S extends EObject> T transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException; diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/.ratings index 9838e7afb3d73759652c14c3beac3651fee99dd1..71fb71cb0047d232942deec0ce77ecc3643e672c 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/.ratings @@ -1,4 +1,4 @@ -ElementTransformationModuleBase.java 860f7f24e6ce701ffb2c6d338e736c7ba3a57ddf RED -ElementTransformationStrategyBase.java f8a64f25ef3e1b2dddc2cb44c4e7f86186d702b3 RED +ElementTransformationModuleBase.java c533bd1998cfef5926e1e7be47611701f9e538bc RED +ElementTransformationStrategyBase.java 24c08064677ec7f793e6dda8ec329dbce7b8a443 RED TransformationModuleBase.java 31eb1ab26b606a8416f69203a0bfb6fd54450c66 RED -TransformationStrategyBase.java 2fab3ca16bfc04a990e9256f56471c000a63ad53 RED +TransformationStrategyBase.java 1b2ef090b47d89e2109d16dc16bfbf8e54123d72 YELLOW diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationModuleBase.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationModuleBase.java index 65506c820430da91552ce5ed96f73242e3a6f3e3..2a0cebe84af3a00529822638e430fec5eac4c45f 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationModuleBase.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationModuleBase.java @@ -20,24 +20,29 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; import java.util.Collection; import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; import org.fortiss.af3.exploration.alg.dse.modeltransformation.element.IElementTransformationModule; import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; +import org.fortiss.tooling.base.model.element.IModelElement; /** + * Base {@link ITransformationModule} to implement transformations of single {@link IModelElement}s. * * @author diewald */ -public abstract class ElementTransformationModuleBase<T extends EObject, O extends EObject> extends - TransformationModuleBase<T> implements IElementTransformationModule<T, O> { +public abstract class ElementTransformationModuleBase<T extends EObject, O extends EObject> + extends TransformationModuleBase<T> implements IElementTransformationModule<T, O> { /** {@inheritDoc} */ @Override public <N extends EObject, S extends EObject> T transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationStrategyBase.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationStrategyBase.java index 7019561688dbbaf1167229c5d158b268966a556e..b292bbf0bbd13178b801701223d7c87ecc101811 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationStrategyBase.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationStrategyBase.java @@ -34,6 +34,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.project.model.FileProject; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; @@ -51,6 +52,7 @@ public abstract class ElementTransformationStrategyBase<T extends EObject, O ext @Override public <N extends EObject, S extends EObject> T transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { @@ -67,9 +69,8 @@ public abstract class ElementTransformationStrategyBase<T extends EObject, O ext for(IElementTransformationModule<? extends EObject, O> subModule : execOrder) { if(subModule.getActivationStage() == state || subModule instanceof ElementTransformationStrategyBase) { - if(subModule.isOptional() && - !canExecuteModule(baseModels, transformedModels, explorationEncodings, - subModule)) { + if(subModule.isOptional() && !canExecuteModule(baseModels, transformedModels, + explorationEncodings, subModule)) { break; } @@ -84,9 +85,8 @@ public abstract class ElementTransformationStrategyBase<T extends EObject, O ext subModule.loadElementAssociations(encEntryModelElemAssoc, origToGenAssocMap, genToOrigAssocMap, genToGenAssocMap); - T transformedModel = - transformElements(subModule, baseModels, explorationEncodings, - transformedModels, tempCastedOutputModel); + T transformedModel = transformElements(subModule, baseModels, explorationEncodings, + transformedModels, tempCastedOutputModel); if(transformedModel == null) { throw new TransformationModuleException(subModule, "The submodule did not return the transformed model. It is required by the framework."); @@ -106,7 +106,7 @@ public abstract class ElementTransformationStrategyBase<T extends EObject, O ext executeSubModules( filterSet(getSubModules(), e -> !(e instanceof IElementTransformationModule<?, ?>)), - context, baseModels, explorationEncodings, transformedModels, state); + context, baseModels, superSets, explorationEncodings, transformedModels, state); @SuppressWarnings("unchecked") Class<N> tempTransformedModelType = (Class<N>)transformedModel.getClass().getInterfaces()[0]; @@ -134,9 +134,8 @@ public abstract class ElementTransformationStrategyBase<T extends EObject, O ext */ @SuppressWarnings("unchecked") protected void calculateModuleExecutionOrder() { - execOrder - .addAll((Collection<? extends IElementTransformationModule<EObject, O>>)filterList( - getSubModules(), e -> e instanceof IElementTransformationModule)); + execOrder.addAll((Collection<? extends IElementTransformationModule<EObject, O>>)filterList( + getSubModules(), e -> e instanceof IElementTransformationModule)); execOrder.sort(new ModuleExecOrderComp()); } @@ -151,8 +150,8 @@ public abstract class ElementTransformationStrategyBase<T extends EObject, O ext * {@link org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState} * which output elements of a given type to be executed before the current one. */ - protected class ModuleExecOrderComp implements - Comparator<IElementTransformationModule<EObject, O>> { + protected class ModuleExecOrderComp + implements Comparator<IElementTransformationModule<EObject, O>> { /** {@inheritDoc} */ @Override public int compare(IElementTransformationModule<EObject, O> arg0, @@ -200,8 +199,8 @@ public abstract class ElementTransformationStrategyBase<T extends EObject, O ext Collection<? extends EObject> typedElements = getChildrenWithType(outputModel, subModule.getElementClass()); for(EObject element : typedElements) { - subModule.transformElement(element, baseModels, explorationEncodings, - transformedModels, outputModel); + subModule.transformElement(element, baseModels, explorationEncodings, transformedModels, + outputModel); } @SuppressWarnings("unchecked") T castedOutputModel = (T)outputModel; diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationStrategyBase.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationStrategyBase.java index 1fc08afb75e698eebfe6385bae4f9890fea58c7b..a4ac3536d58b421e3baeaa2bdce5dd71d03609bc 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationStrategyBase.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationStrategyBase.java @@ -38,6 +38,9 @@ import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; import org.fortiss.af3.exploration.alg.service.internal.ExplorationTransformationService; +import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet; +import org.fortiss.af3.exploration.model.SuperSetMap; +import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution; import org.fortiss.af3.project.model.FileProject; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; @@ -50,8 +53,8 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService; * * @author diewald */ -public abstract class TransformationStrategyBase<T extends EObject> extends - TransformationModuleBase<T> implements ITransformationStrategy<T> { +public abstract class TransformationStrategyBase<T extends EObject> + extends TransformationModuleBase<T> implements ITransformationStrategy<T> { /** * Flag that determines whether {@code this} {@link ITransformationStrategy} shall be launched @@ -75,7 +78,9 @@ public abstract class TransformationStrategyBase<T extends EObject> extends /** Caches exceptions that are thrown in the model context. */ protected TransformationModuleException cachedException; - /** List of {@link EObject}s that were instantiated in previous generation/transformation steps. */ + /** + * List of {@link EObject}s that were instantiated in previous generation/transformation steps. + */ protected Collection<EObject> instantiatedElements = new ArrayList<>(); /** @@ -86,13 +91,15 @@ public abstract class TransformationStrategyBase<T extends EObject> extends new LinkedHashMap<>(); /** - * {@inheritDoc} </p> + * {@inheritDoc} + * </p> * This implementation follows the strategy pattern. * </p> */ @Override public <N extends EObject, S extends EObject> T transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { @@ -101,9 +108,8 @@ public abstract class TransformationStrategyBase<T extends EObject> extends "The map which will contain all transformed models must be passed."); } - transformedModel = - transformInternal(state, context, baseModels, explorationEncodings, - transformedModels); + transformedModel = transformInternal(state, context, baseModels, superSets, + explorationEncodings, transformedModels); if(launchedAsSubModule) { doSetModelName(); @@ -143,32 +149,19 @@ public abstract class TransformationStrategyBase<T extends EObject> extends * created instances) in the order that is given by the * {@link org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState} * s. + * <p/> + * Parameters are detailed in + * {@link ExplorationTransformationService#getTransformedModel(TransformationContext, ITopLevelElement, SingleExplorationSolution, SubClassToInstanceMap, + * SuperSetMap , Class , String )} + * . * - * @param state - * - * @param context - * see - * {@link ExplorationTransformationService#getTransformedModel(TransformationContext, ITopLevelElement, ExplorationEncodingMap, SubClassToInstanceMap, Class, String)} - * . - * @param baseModels - * see - * {@link ITransformationModule#transform(org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState, TransformationContext, SubClassToInstanceMap, ExplorationEncodingMap, SubClassToInstanceMap, EObject)} - * . - * @param explorationEncodings - * see - * {@link ITransformationModule#transform(org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState, TransformationContext, SubClassToInstanceMap, ExplorationEncodingMap, SubClassToInstanceMap, EObject)} - * . - * @param transformedModels - * see - * {@link ITransformationModule#transform(org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState, TransformationContext, SubClassToInstanceMap, ExplorationEncodingMap, SubClassToInstanceMap, EObject)} - * . - * @return The resulting transformed model. * @throws TransformationModuleException * if any of the sub modules fails during execution or produces no output. */ // TODO update doc "state" - protected <N extends EObject, S extends EObject> T transformInternal(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, + protected <N extends EObject, S extends EObject> T transformInternal( + @SuppressWarnings("unused") TransformationState state, TransformationContext context, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels) throws TransformationModuleException { @SuppressWarnings("unchecked") T castedTransformedBaseModel = @@ -186,7 +179,7 @@ public abstract class TransformationStrategyBase<T extends EObject> extends genToGenAssocMap.clear(); } - executeSubModules(getSubModules(), context, baseModels, explorationEncodings, + executeSubModules(getSubModules(), context, baseModels, superSets, explorationEncodings, transformedModels, currentState); } @@ -211,6 +204,8 @@ public abstract class TransformationStrategyBase<T extends EObject> extends * Whether or not to export the resulting models into the corresponding project. * @param baseModels * Input set of original models. + * @param superSets + * Map of {@link SuperSet}s generated by the DSE. * @param explorationEncodings * DSE internal encoding inputs for the transformation. * @param transformedModels @@ -224,6 +219,7 @@ public abstract class TransformationStrategyBase<T extends EObject> extends protected <N extends EObject, S extends EObject> void executeSubModules( Collection<ITransformationModule<? extends EObject>> subModules, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, TransformationState currentState) throws TransformationModuleException { @@ -236,10 +232,10 @@ public abstract class TransformationStrategyBase<T extends EObject> extends for(ITransformationModule<? extends EObject> subModule : subModules) { if(subModule.getActivationStage() == currentState || - (currentState.ordinal() >= subModule.getActivationStage().ordinal() && subModule instanceof ElementTransformationStrategyBase)) { - if(subModule.isOptional() && - !canExecuteModule(baseModels, transformedModels, explorationEncodings, - subModule)) { + (currentState.ordinal() >= subModule.getActivationStage().ordinal() && + subModule instanceof ElementTransformationStrategyBase)) { + if(subModule.isOptional() && !canExecuteModule(baseModels, transformedModels, + explorationEncodings, subModule)) { continue; } @@ -251,7 +247,7 @@ public abstract class TransformationStrategyBase<T extends EObject> extends subModule.loadElementAssociations(encEntryModelElemAssoc, origToGenAssocMap, genToOrigAssocMap, genToGenAssocMap); @SuppressWarnings("unchecked") T transformedModel = - (T)subModule.transform(currentState, context, baseModels, + (T)subModule.transform(currentState, context, baseModels, superSets, explorationEncodings, transformedModels, this.transformedModel); if(transformedModel == null) { throw new TransformationModuleException(subModule, @@ -287,8 +283,8 @@ public abstract class TransformationStrategyBase<T extends EObject> extends @SuppressWarnings("unchecked") Class<? extends IExplorationEncoding> explReqInput = (Class<? extends IExplorationEncoding>)reqInput; if(!(baseModels.keySet().stream().anyMatch(m -> m.isAssignableFrom(reqInput))) && - !(transformedModels.keySet().stream().anyMatch(m -> m - .isAssignableFrom(reqInput))) && + !(transformedModels.keySet().stream() + .anyMatch(m -> m.isAssignableFrom(reqInput))) && !(explorationEncodings.containsEncoding(explReqInput))) { return false; } @@ -309,8 +305,7 @@ public abstract class TransformationStrategyBase<T extends EObject> extends "Cannot add the transformed model to the AF3 Project without a model context. Please provide one."); } if(fp == null) { - throw new TransformationModuleException( - this, + throw new TransformationModuleException(this, "Cannot add the transformed model to the AF3 Project without without a referenced project. Please provide one."); } @@ -328,9 +323,9 @@ public abstract class TransformationStrategyBase<T extends EObject> extends private void doAddModelToProject(FileProject fp, IProjectRootElement transformedModel) { Runnable fpAdder = () -> { // prepareUniqueID(transformedModel, fp); - IElementCompositorService.getInstance().compose(fp, transformedModel, null); - fp.getRootElements().add(transformedModel); - }; + IElementCompositorService.getInstance().compose(fp, transformedModel, null); + fp.getRootElements().add(transformedModel); + }; modelContext.runAsCommand(fpAdder); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureFinalizer.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureFinalizer.java index d319d3c53606b4856bcf67ea8ab5c2ecad6a1bca..8c7f511c893fbc92d56a147403708f57e721fbcc 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureFinalizer.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureFinalizer.java @@ -34,6 +34,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.exploration.moea.model.ImplementsComponentRef; import org.fortiss.af3.exploration.moea.model.MoeaFactory; import org.fortiss.tooling.base.model.element.IModelElementSpecification; @@ -95,7 +96,7 @@ public class ComponentArchitectureFinalizer @Override public <N extends EObject, S extends EObject> ComponentArchitecture transform( TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInitializer.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInitializer.java index 9e37eca8cace8d1947caac0de09a0251ba3b2365..e2374411329a594fdd160e64847ea27cc79bd93b 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInitializer.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInitializer.java @@ -36,6 +36,7 @@ import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; import org.fortiss.af3.exploration.alg.util.ExplorationEcoreUtils; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.project.model.FileProject; import com.google.common.collect.HashMultimap; @@ -98,7 +99,7 @@ public class ComponentArchitectureInitializer @Override public <N extends EObject, S extends EObject> ComponentArchitecture transform( TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInserter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInserter.java index f41208ffc4344d1b5460b0f85bf802d845bb245d..7f6a18f2148d59761dd19d57a408668d05653d08 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInserter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInserter.java @@ -47,6 +47,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.platform.model.IPlatformResource; import org.fortiss.tooling.base.model.layout.Point; @@ -105,7 +106,7 @@ public class ComponentArchitectureInserter extends TransformationModuleBase<Comp @Override public <N extends EObject, S extends EObject> ComponentArchitecture transform( TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInstantiator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInstantiator.java index b7b4e6f4136d99e84addfea67640dd73d9e53687..7f30c41e76c788c0901e893dae491658b91e27f3 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInstantiator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInstantiator.java @@ -47,6 +47,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.tooling.base.model.element.IConnector; import org.fortiss.tooling.kernel.utils.EcoreUtils; @@ -107,7 +108,7 @@ public class ComponentArchitectureInstantiator @Override public <N extends EObject, S extends EObject> ComponentArchitecture transform( TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureReplicator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureReplicator.java index bb65d3f19f4a6461d6c44d4f48e149bc61fcb864..af050af0d6e0f0a65f5e73393639e61273b49f77 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureReplicator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureReplicator.java @@ -57,8 +57,8 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.ab import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; @@ -67,6 +67,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.IPlatformResource; import org.fortiss.tooling.kernel.model.INamedElement; @@ -86,8 +87,7 @@ public class ComponentArchitectureReplicator extends TransformationModuleBase<ComponentArchitecture> { /** Collection of {@link Component}s that can be allocated to {@link IPlatformResource}. */ - private Collection<ITaskAdapter<Component>> deployableComponentCollection = - new HashSet<>(); + private Collection<ITaskAdapter<Component>> deployableComponentCollection = new HashSet<>(); /** * Contains the allocation information between possibly replicated {@link Component}s and their @@ -143,7 +143,7 @@ public class ComponentArchitectureReplicator @Override public <N extends EObject, S extends EObject> ComponentArchitecture transform( TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java index 02d5f6919a04a60a78660b6dff645725c14cbfda..6631dae7efce651c6865165362fffeb90a5b3939 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java @@ -42,8 +42,8 @@ import org.fortiss.af3.deployment.utils.DeploymentModelElementFactory; import org.fortiss.af3.exploration.alg.dse.modeltransformation.EMFModelConcurrencyHandler; import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; @@ -51,6 +51,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.platform.model.ExecutionUnit; import org.fortiss.af3.platform.model.PlatformArchitecture; import org.fortiss.af3.project.model.FileProject; @@ -110,6 +111,7 @@ public class DeploymentFinalizer extends TransformationModuleBase<Deployment> { @Override public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentInitializer.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentInitializer.java index 908190b2a5374cee34bf92cfcbfc7a88c8cffa6e..79cbba58d47193560174e35f2941c6809314281f 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentInitializer.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentInitializer.java @@ -35,6 +35,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.platform.model.PlatformArchitecture; /** @@ -90,22 +91,21 @@ public class DeploymentInitializer extends TransformationModuleBase<Deployment> @Override public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { ComponentArchitecture originalCA = (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); if(originalCA == null) { - throw new TransformationModuleException( - this, + throw new TransformationModuleException(this, "Could not retrieve the original component architecture from the set of base models. Be sure to add it to the required input types."); } PlatformArchitecture originalPA = (PlatformArchitecture)baseModels.get(PlatformArchitecture.class); if(originalPA == null) { - throw new TransformationModuleException( - this, + throw new TransformationModuleException(this, "Could not retrieve the original platform architecture from the set of base models. Be sure to add it to the required input types."); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentReplicator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentReplicator.java index ece0f51b04cf7be9811c19d05c8b7bb2f168186f..11babfd6a32bf81d9a9317599c88949e4ab85925 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentReplicator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentReplicator.java @@ -31,6 +31,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.platform.model.PlatformArchitecture; /** @@ -87,22 +88,21 @@ public class DeploymentReplicator extends TransformationModuleBase<Deployment> { @Override public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { ComponentArchitecture originalCA = (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); if(originalCA == null) { - throw new TransformationModuleException( - this, + throw new TransformationModuleException(this, "Could not retrieve the original component architecture from the set of base models. Be sure to add it to the required input types."); } PlatformArchitecture originalPA = (PlatformArchitecture)baseModels.get(PlatformArchitecture.class); if(originalPA == null) { - throw new TransformationModuleException( - this, + throw new TransformationModuleException(this, "Could not retrieve the original platform architecture from the set of base models. Be sure to add it to the required input types."); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/ExplorationSolutionToDeployment.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/ExplorationSolutionToDeployment.java index 9bf003c74d2e9460aae9a75508d071720a2728e6..8305f86dbe619dfe258ee965e423bcd4a849f3a5 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/ExplorationSolutionToDeployment.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/ExplorationSolutionToDeployment.java @@ -38,6 +38,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.platform.model.PlatformArchitecture; /** @@ -88,6 +89,7 @@ public class ExplorationSolutionToDeployment extends TransformationStrategyBase< @Override public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, TransformationContext context, SubClassToInstanceMap<S> baseModels, + SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { @@ -107,8 +109,8 @@ public class ExplorationSolutionToDeployment extends TransformationStrategyBase< setArchModels(baseModels); } - return super.transform(state, context, baseModels, explorationEncodings, transformedModels, - outputModel); + return super.transform(state, context, baseModels, superSets, explorationEncodings, + transformedModels, outputModel); } /** diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/.ratings new file mode 100644 index 0000000000000000000000000000000000000000..bd6c2a8d1a39e2bcebde4176b9675c3fa153f612 --- /dev/null +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/.ratings @@ -0,0 +1,2 @@ +PartitionTransformationStrategy.java 220d5175ac8ff958f82c053a934095880540fcd3 YELLOW +PartitionTransformer.java 8e0cfe41579eea4c45d24ef768799f47e6751743 YELLOW diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/PartitionTransformationStrategy.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/PartitionTransformationStrategy.java new file mode 100644 index 0000000000000000000000000000000000000000..5d29815ba2e501a3423af8ceac831e4a2fd31e8e --- /dev/null +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/PartitionTransformationStrategy.java @@ -0,0 +1,76 @@ +/*-------------------------------------------------------------------------+ +| 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.exploration.alg.dse.modeltransformation.partition; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; + +import org.fortiss.af3.allocation.model.AllocationTableCollection; +import org.fortiss.af3.deployment.model.Deployment; +import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; +import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationStrategyBase; + +/** + * Responsible for generating a {@link Deployment} that is compatible with the Deployment-plugin. + * Thus, a Component -> Platform mapping resulting form the DSE can viewed and edited within the + * {@link Deployment} editor. + * + * @author diewald + */ +public class PartitionTransformationStrategy + extends TransformationStrategyBase<AllocationTableCollection> { + /** {@inheritDoc} */ + @Override + public Class<AllocationTableCollection> getOutputType() { + return AllocationTableCollection.class; + } + + /** {@inheritDoc} */ + @Override + public Collection<Class<?>> getRequiredTypes() { + Collection<Class<?>> inputTypes = new HashSet<>(); + // inputTypes.add(ComponentArchitecture.class); + // inputTypes.add(PlatformArchitecture.class); + // inputTypes.add(InstantiatedTaskMappingEncoding.class); + // inputTypes.add(PartitionMappingEncoding.class); + return inputTypes; + } + + /** {@inheritDoc} */ + @Override + public Collection<Class<?>> getOptionalTypes() { + return Collections.emptySet(); + } + + /** {@inheritDoc} */ + @Override + public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { + return Collections.emptySet(); + } + + /** {@inheritDoc} */ + @Override + public boolean isOptional() { + return false; + } + + /** {@inheritDoc} */ + @Override + public TransformationState getActivationStage() { + return TransformationState.INITIALIZING; + } +} diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/PartitionTransformer.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/PartitionTransformer.java new file mode 100644 index 0000000000000000000000000000000000000000..38ed01d461faf658eafb0be18cbcee6af29e7bfc --- /dev/null +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/partition/PartitionTransformer.java @@ -0,0 +1,206 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2016 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.exploration.alg.dse.modeltransformation.partition; + +import static org.fortiss.af3.allocation.utils.AllocationModelElementFactory.createAllocationTableCollection; +import static org.fortiss.af3.allocation.utils.AllocationUtils.addAllocationEntry; +import static org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState.INITIALIZING; +import static org.fortiss.af3.exploration.alg.util.TransformationUtils.getArchitectureOfAllocSuperSet; +import static org.fortiss.af3.partition.util.PartitionModelElementFactory.createTaskToPartitionAllocationTable; +import static org.fortiss.tooling.common.util.LambdaUtils.getFirst; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.allocation.model.AllocationTableCollection; +import org.fortiss.af3.component.model.ComponentArchitecture; +import org.fortiss.af3.deployment.model.Deployment; +import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; +import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; +import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; +import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; +import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; +import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet; +import org.fortiss.af3.exploration.model.SuperSetMap; +import org.fortiss.af3.partition.model.Partition; +import org.fortiss.af3.partition.model.PartitionArchitecture; +import org.fortiss.af3.partition.model.allocation.PartitionToExecutionUnitAllocationEntry; +import org.fortiss.af3.partition.model.allocation.PartitionToExecutionUnitAllocationTable; +import org.fortiss.af3.partition.model.allocation.TaskToPartitionAllocationEntry; +import org.fortiss.af3.partition.model.allocation.TaskToPartitionAllocationTable; +import org.fortiss.af3.partition.util.PartitionModelElementFactory; +import org.fortiss.af3.platform.model.PlatformArchitecture; +import org.fortiss.af3.project.model.FileProject; +import org.fortiss.af3.project.utils.ProjectUtils; +import org.fortiss.af3.task.model.Task; +import org.fortiss.af3.task.model.TaskArchitecture; +import org.fortiss.tooling.base.model.element.IHierarchicElement; +import org.fortiss.tooling.common.util.LambdaUtils; +import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; +import org.fortiss.tooling.kernel.service.IPersistencyService; + +/** + * Initializes a {@link Deployment} by creating a new model and setting its references to the given + * {@link ComponentArchitecture} and {@link PlatformArchitecture}. + * + * @author diewald + */ +public class PartitionTransformer extends TransformationModuleBase<AllocationTableCollection> { + /** Input {@link TaskArchitecture} passed to the DSE. */ + private TaskArchitecture taskArchitecture; + /** Input {@link PlatformArchitecture} passed to the DSE. */ + private PlatformArchitecture platfromArchitecture; + /** Generated {@link PartitionArchitecture} by the DSE. */ + private PartitionArchitecture partitionArchitecture; + /** + * Generated {@link AllocationTableCollection} containing task-to-partition and + * partition-to-execution-unit allocation tables. + */ + private AllocationTableCollection allocTableCollection; + + /** {@inheritDoc} */ + @Override + public <N extends EObject, S extends EObject> AllocationTableCollection transform( + TransformationState state, TransformationContext context, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, + ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, + SubClassToInstanceMap<N> transformedModels, EObject outputModel) { + platfromArchitecture = getArchitectureOfAllocSuperSet( + superSets.get(PartitionToExecutionUnitAllocationEntry.class), + PlatformArchitecture.class); + taskArchitecture = getArchitectureOfAllocSuperSet( + superSets.get(TaskToPartitionAllocationEntry.class), TaskArchitecture.class); + + SuperSet<PartitionToExecutionUnitAllocationEntry> partToExU = + superSets.get(PartitionToExecutionUnitAllocationEntry.class); + // Get a random entry to retrieve the model context. + PartitionToExecutionUnitAllocationEntry entry = + LambdaUtils.getFirst(partToExU.getEntries()).get(); + FileProject fp = + ProjectUtils.getFileProject(LambdaUtils.getFirst(entry.getTargetElements()).get()); + ITopLevelElement modelContext = IPersistencyService.getInstance().getTopLevelElementFor(fp); + + // TODO: The following step should be performed in a separate module. + createPartitionArchitecture(superSets.get(Partition.class), modelContext); + modelContext.runAsNonDirtyingCommand(() -> fp.getRootElements().add(platfromArchitecture)); + + // Create the allocations. + allocTableCollection = createAllocationTableCollection("Generated Allocations"); + TaskToPartitionAllocationTable taskExUTable = createTaskToExecutionUnitAllocationTable( + superSets.get(TaskToPartitionAllocationEntry.class)); + modelContext.runAsNonDirtyingCommand( + () -> allocTableCollection.getContainedElements().add(taskExUTable)); + PartitionToExecutionUnitAllocationTable partExUTable = + createPartitionToExecutionUnitAllocationTable( + superSets.get(PartitionToExecutionUnitAllocationEntry.class)); + modelContext.runAsNonDirtyingCommand( + () -> allocTableCollection.getContainedElements().add(partExUTable)); + + return allocTableCollection; + } + + /** Creates a {@link PartitionArchitecture} from the entries in the given {@link SuperSet}. */ + private void createPartitionArchitecture(SuperSet<Partition> partitions, + ITopLevelElement modelContext) { + partitionArchitecture = PartitionModelElementFactory + .createPartitionArchitecture("Generated Partition Architecture"); + EList<IHierarchicElement> partitionList = partitionArchitecture.getContainedElements(); + modelContext.runAsNonDirtyingCommand(() -> partitionList.addAll(partitions.getEntries())); + } + + /** + * Creates a {@link TaskToPartitionAllocationTable} from the corresponding entries in + * the given {@link SuperSet}. + */ + private TaskToPartitionAllocationTable createTaskToExecutionUnitAllocationTable( + SuperSet<TaskToPartitionAllocationEntry> taskExecUnitAllocs) { + TaskToPartitionAllocationTable table = + createTaskToPartitionAllocationTable("Generated Task->Part Table"); + table.setSourceView(taskArchitecture); + table.setTargetView(partitionArchitecture); + + for(TaskToPartitionAllocationEntry entry : taskExecUnitAllocs.getEntries()) { + Partition af3Partition = (Partition)entry.getTargetElement(); + // TODO: We assume single Tasks in this place. + addAllocationEntry(table, TaskToPartitionAllocationEntry.class, + (Task)getFirst(entry.getSourceElements()).get(), af3Partition); + } + return table; + } + + /** + * Creates a {@link PartitionToExecutionUnitAllocationTable} from the corresponding entries in + * the given {@link SuperSet}. + */ + private PartitionToExecutionUnitAllocationTable createPartitionToExecutionUnitAllocationTable( + SuperSet<PartitionToExecutionUnitAllocationEntry> partMapping) { + PartitionToExecutionUnitAllocationTable table = PartitionModelElementFactory + .createPartitionToExecutionUnitAllocationTable("Generated Part->ExU Table"); + table.setSourceView(partitionArchitecture); + table.setTargetView(platfromArchitecture); + + for(PartitionToExecutionUnitAllocationEntry entry : partMapping.getEntries()) { + Partition af3Partition = (Partition)entry.getSourceElement(); + // TODO: We assume single ExecutionUnits as allocation targets in this place. + addAllocationEntry(table, PartitionToExecutionUnitAllocationEntry.class, af3Partition, + getFirst(entry.getTargetElements()).get()); + } + return table; + } + + /** {@inheritDoc} */ + @Override + public Class<AllocationTableCollection> getOutputType() { + return AllocationTableCollection.class; + } + + /** {@inheritDoc} */ + @Override + public Collection<Class<?>> getRequiredTypes() { + Collection<Class<?>> inputTypes = new HashSet<>(); + return inputTypes; + } + + /** {@inheritDoc} */ + @Override + public Collection<Class<?>> getOptionalTypes() { + return Collections.emptySet(); + } + + /** {@inheritDoc} */ + @Override + public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { + Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); + parentModules.add(PartitionTransformationStrategy.class); + return parentModules; + } + + /** {@inheritDoc} */ + @Override + public boolean isOptional() { + return false; + } + + /** {@inheritDoc} */ + @Override + public TransformationState getActivationStage() { + return INITIALIZING; + } +} diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyChannelPortReplicator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyChannelPortReplicator.java index 6a5366a3273901dd6a616608d5262be918127cef..e5ee589a02d11de1357dfd637ef3f4aae315be39 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyChannelPortReplicator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyChannelPortReplicator.java @@ -39,6 +39,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; /** * @@ -70,7 +71,7 @@ public class SafetyChannelPortReplicator extends TransformationModuleBase<Compon @Override public <N extends EObject, S extends EObject> ComponentArchitecture transform( ITransformationModule.TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) { @SuppressWarnings("unchecked") SafetyFunctionArchEncoding<Component> sfaEnc = @@ -88,8 +89,8 @@ public class SafetyChannelPortReplicator extends TransformationModuleBase<Compon Collection<InputPort> connectedInputPorts = new HashSet<>(); for(OutputPort curOutPort : sfOutPorts) { - curOutPort.getOutgoingChannels().forEach( - ch -> connectedInputPorts.add((InputPort)ch.getTarget())); + curOutPort.getOutgoingChannels() + .forEach(ch -> connectedInputPorts.add((InputPort)ch.getTarget())); } Collection<InputPort> nonSfInputPorts = @@ -101,9 +102,8 @@ public class SafetyChannelPortReplicator extends TransformationModuleBase<Compon List<Channel> incomingChannels = inPort.getIncomingChannels(); for(int chIdx = 1; chIdx < incomingChannels.size(); chIdx++) { char suffix = (char)(chIdx - 1 + 'a'); - InputPort genPort = - replicateInputPortAndAttach(inPort, inPort.getComponent(), - inPort.getName() + "_" + suffix); + InputPort genPort = replicateInputPortAndAttach(inPort, inPort.getComponent(), + inPort.getName() + "_" + suffix); Channel curCh = incomingChannels.get(chIdx); curCh.setTarget(genPort); InputPort origPort = (InputPort)genToOrigAssocMap.get(inPort); diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyDiagUnitRemover.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyDiagUnitRemover.java index 79c3fd9e5f8d692c287df2cf2816dc9d3c8cc974..3a1b0e50831b057bf1e8c3042eafab8e4d094c1a 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyDiagUnitRemover.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyDiagUnitRemover.java @@ -35,6 +35,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; +import org.fortiss.af3.exploration.model.SuperSetMap; /** * Module that deletes diagnostic {@link Component}s from a generated {@link ComponentArchitecture} @@ -89,7 +90,7 @@ public class SafetyDiagUnitRemover extends TransformationModuleBase<ComponentArc @Override public <N extends EObject, S extends EObject> ComponentArchitecture transform( TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, SubClassToInstanceMap<N> transformedModels, EObject outputModel) throws TransformationModuleException { @@ -108,8 +109,8 @@ public class SafetyDiagUnitRemover extends TransformationModuleBase<ComponentArc for(SafetyFunctionArchEntry<Component> sfaEntry : sfaEnc.getAllEntries()) { if(!sfaEntry.isDiagnosicUnitPresent()) { - for(ITaskAdapter<Component> diagCompAdp : sfaEntry - .getSafetyFunctionAdapter().getDiagnosticComponents()) { + for(ITaskAdapter<Component> diagCompAdp : sfaEntry.getSafetyFunctionAdapter() + .getDiagnosticComponents()) { for(EObject genDiagComponent : origToGenAssocMap.get(diagCompAdp.getObject())) { if(!(genDiagComponent instanceof Component)) { throw new TransformationModuleException(this, "The generated element " + @@ -119,10 +120,10 @@ public class SafetyDiagUnitRemover extends TransformationModuleBase<ComponentArc // Get all channels connected to the current diagnostic Component. Collection<Channel> genChannels = new ArrayList<>(); - ((Component)genDiagComponent).getInputPorts().forEach( - p -> genChannels.addAll(p.getIncomingChannels())); - ((Component)genDiagComponent).getOutputPorts().forEach( - p -> genChannels.addAll(p.getOutgoingChannels())); + ((Component)genDiagComponent).getInputPorts() + .forEach(p -> genChannels.addAll(p.getIncomingChannels())); + ((Component)genDiagComponent).getOutputPorts() + .forEach(p -> genChannels.addAll(p.getOutgoingChannels())); // Remove all ports from Components which are connected to the diagnostic // Component. Can be included if needed. NOTE: Instantiated components will // introduce the "same" Port again. diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings index 360af31c6e3ccda36750b7aa1730b4309f9f29c0..98ccaf4e90bc2dda71d9220a9120799670998d7b 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings @@ -4,4 +4,4 @@ ScheduleLabelGenerator.java 0ceecedfec9802bbcaa33525d61e1a60a70d3841 RED SchedulePlotter.java 29b1156c9419d4ff3314c4b2c932aeb46f4749f8 RED ScheduleToolTipGenerator.java cedfa0dd7ebc7b48d7cc70e966eebaeee9636caf RED TaskSeriesCollectionFromSchedule.java b53b7af649c48980520ad572da8c7bbdbae0aed5 RED -XYPlotter.java 4ab3c02351dab5e78cea843dc6665ddee46a636c RED +XYPlotter.java bdea08cbfbaea8755a225c149a5aba8830a68549 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java index 280226ef257e2779bf90903196d77caf86bd4df1..f65690b5b24a8a98e86383ab27fee243ea289d6f 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java @@ -48,22 +48,24 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; import org.eclipse.emf.ecore.EObject; +import org.fortiss.af3.allocation.model.AllocationTableCollection; import org.fortiss.af3.component.model.ComponentArchitecture; import org.fortiss.af3.deployment.model.Deployment; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; import org.fortiss.af3.exploration.alg.guava.MutableSubClassToInstanceMap; import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService; +import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet; import org.fortiss.af3.exploration.model.ExplorationConstraint; import org.fortiss.af3.exploration.model.ExplorationSpecification; import org.fortiss.af3.exploration.model.ExplorationTarget; import org.fortiss.af3.exploration.model.solutions.ExplorationResult; import org.fortiss.af3.exploration.model.solutions.ExplorationSolution; import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution; -import org.fortiss.af3.platform.model.PlatformArchitecture; +import org.fortiss.af3.partition.model.allocation.PartitionToExecutionUnitAllocationEntry; import org.fortiss.af3.project.model.FileProject; +import org.fortiss.tooling.common.util.LambdaUtils; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.service.IPersistencyService; import org.jfree.chart.ChartFactory; @@ -164,9 +166,6 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe /** The overall exploration result */ private ExplorationSolution explorationResult; - /** The {@link SystemModelAdapter} that references the explored system. */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?, ?> exploredSystemModel; - /** * maps the names of the objectives to the GUI elements used to display the exact solution * values @@ -612,8 +611,9 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe * * @throws Exception */ - private Deployment transformSingleDeployment(SingleExplorationSolution solutionMap, - String deploymentName, boolean generateSCSpec) throws Exception { + private AllocationTableCollection transformSingleDeployment( + SingleExplorationSolution solutionMap, String deploymentName, boolean generateSCSpec) + throws Exception { // Deployment generation has NOT been cancelled. if(deploymentName.isEmpty()) { deploymentName = "_Deployment"; @@ -622,12 +622,12 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe SubClassToInstanceMap<EObject> baseModels = MutableSubClassToInstanceMap.create(); // TODO: instead of querying the systemModelAdapter here, we should use the // explorationResult -> input models. - ComponentArchitecture compArch = - (ComponentArchitecture)exploredSystemModel.getLogicalArchitecture().getObject(); - PlatformArchitecture platArch = - (PlatformArchitecture)exploredSystemModel.getPlatformArchitecture().getObject(); - baseModels.put(ComponentArchitecture.class, compArch); - baseModels.put(PlatformArchitecture.class, platArch); + // ComponentArchitecture compArch = + // (ComponentArchitecture)exploredSystemModel.getLogicalArchitecture().getObject(); + // PlatformArchitecture platArch = + // (PlatformArchitecture)exploredSystemModel.getPlatformArchitecture().getObject(); + // baseModels.put(ComponentArchitecture.class, compArch); + // baseModels.put(PlatformArchitecture.class, platArch); if(generateSCSpec) { // SafetyComplianceConstraint scConstr = // pickFirstInstanceOf(SafetyComplianceConstraint.class, dse @@ -638,20 +638,26 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe // TODO: The context must be an export here. In a future version, it must be // possible to specify, how the transformed model can be injected / exported. - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(compArch); + SuperSet<PartitionToExecutionUnitAllocationEntry> partToExU = + solutionMap.getSolutionSets().get(PartitionToExecutionUnitAllocationEntry.class); + PartitionToExecutionUnitAllocationEntry entry = + LambdaUtils.getFirst(partToExU.getEntries()).get(); + ITopLevelElement modelContext = IPersistencyService.getInstance() + .getTopLevelElementFor(LambdaUtils.getFirst(entry.getTargetElements()).get()); Collection<Class<? extends EObject>> solutionModelTypes = new HashSet<>(); - solutionModelTypes.add(Deployment.class); + // solutionModelTypes.add(Deployment.class); + solutionModelTypes.add(AllocationTableCollection.class); if(generateSCSpec) { // solutionModelTypes.add(SafetyComplianceSpecification.class); } - Deployment deployment = null; + AllocationTableCollection deployment = null; ClassToInstanceMap<EObject> solutionModels = getService(IExplorationTransformationService.class).getTransformedModels(EXPORT, - modelContext, solutionMap, baseModels, solutionModelTypes, deploymentName); - deployment = solutionModels.getInstance(Deployment.class); + modelContext, solutionMap, baseModels, solutionMap.getSolutionSets(), + solutionModelTypes, deploymentName); + deployment = solutionModels.getInstance(AllocationTableCollection.class); // Derive the ComponentType from the Voter Specification. // for(VoterType voterSpec : getChildrenWithType(compArch, VoterType.class)) { @@ -698,7 +704,7 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe private <S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> void generateAllDeployments(final String deploymentName, boolean generateSCSpec) throws Exception { - Collection<Deployment> transformedDeployments = new ArrayList<>(); + Collection<AllocationTableCollection> transformedDeployments = new ArrayList<>(); Integer deploymentNumber = 1; for(SingleExplorationSolution solution : explorationResult.getSolutions()) { @@ -709,13 +715,25 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe // Defer the injection of deployments such that a failure in the transformation does not // inject deployments corresponding to a subset of the solutions to the parent AF3 project. - for(Deployment curDeployment : transformedDeployments) { + for(AllocationTableCollection curDeployment : transformedDeployments) { ITopLevelElement modelContext = IPersistencyService.getInstance().getTopLevelElementFor(expSpec); - modelContext.runAsCommand(() -> addDeploymentToProject(curDeployment)); + modelContext.runAsCommand(() -> addAllocationTablesToProject(curDeployment)); } } + /** + * Actually generates the an AF3 deployment model from a given solution in the provided model + * context and registers the resulting deployment (and a possibly generated + * {@link ComponentArchitecture}) in the {@link FileProject} of the DSE. + */ + private <S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> + void addAllocationTablesToProject(AllocationTableCollection deployment) { + FileProject fp = getFileProject(expSpec); + fp.getRootElements().add(deployment); + fp.getRootElements().add(deployment); + } + /** * Actually generates the an AF3 deployment model from a given solution in the provided model * context and registers the resulting deployment (and a possibly generated diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/.ratings index 17d25d2445e099ecda648f3f35b5ec617453dc60..986a963e8581ea09f30af2abafe4ef521bfda393 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/.ratings @@ -8,5 +8,5 @@ IExplorationModule.java 8990c654e649f043fa9813b8bf9113ac7bd42d27 RED IExplorationRepairService.java e923c43c49e0c83daef71707d5fdb66444f859f8 RED IExplorationService.java 891b8c4ce01e40ab31bf69231a63fd61c57ac98e RED IExplorationTargetEvaluator.java 9b39b44f64ad8195583b00f8e3852bbc912f75fc RED -IExplorationTransformationService.java cb6f6f17d0def73ec680af98f30aa0f391723227 RED +IExplorationTransformationService.java e0b50a382efcb1f84841ed4693077e8427031816 YELLOW IRepairModule.java 498a5b0ff519482af41db2916b1eefd1142cc9df RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTransformationService.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTransformationService.java index 2214e1f1ce40c0536ca6f875e701bbc662adf21c..49c98f5ea43325cd930e86c7ac61e7857cc31d2f 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTransformationService.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/IExplorationTransformationService.java @@ -24,6 +24,8 @@ import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationMo import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationStrategy; import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.internal.ExplorationTransformationService; +import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; @@ -84,7 +86,7 @@ public interface IExplorationTransformationService /** * Generates models of the requested types ({@code transformedModelTypes}) using the set of - * solution models contained in the given {@link SingleExplorationSolutionMap} and the + * solution models contained in the given {@link SingleExplorationSolution} and the * collection of given {@code baseModel}s. * * @param context @@ -93,9 +95,11 @@ public interface IExplorationTransformationService * @param modelContext * Model context in which the transformed models would be stored. * @param solution - * {@link SingleExplorationSolutionMap} containing the solution models. + * {@link SingleExplorationSolution} containing the solution models. * @param baseModels * EMF models used as a basis to generate the transformed model. + * @param superSets + * {@link SuperSet}s (= "models") calculated by the DSE. * @param transformedModelTypes * Type of the transformed models that shall be returned. * @param transformedModelName @@ -108,12 +112,12 @@ public interface IExplorationTransformationService <U extends EObject, S extends EObject> ClassToInstanceMap<U> getTransformedModels( TransformationContext context, ITopLevelElement modelContext, SingleExplorationSolution solution, SubClassToInstanceMap<S> baseModels, - Collection<Class<? extends EObject>> transformedModelTypes, String transformedModelName) - throws Exception; + SuperSetMap superSets, Collection<Class<? extends EObject>> transformedModelTypes, + String transformedModelName) throws Exception; /** * Generates a model of the requested type ({@code transformedModelType}) using the set of - * solution models contained in the given {@link SingleExplorationSolutionMap} and the + * solution models contained in the given {@link SingleExplorationSolution} and the * collection of given {@code baseModel}s. * * @param context @@ -122,9 +126,11 @@ public interface IExplorationTransformationService * @param modelContext * Model context in which the transformed models would be stored. * @param solution - * {@link SingleExplorationSolutionMap} containing the solution models. + * {@link SingleExplorationSolution} containing the solution models. * @param baseModels * EMF models used as a basis to generate the transformed model. + * @param superSets + * {@link SuperSet}s (= "models") calculated by the DSE. * @param transformedModelType * Type of the transformed model. * @param transformedModelName @@ -136,12 +142,12 @@ public interface IExplorationTransformationService */ <U extends EObject, S extends EObject> U getTransformedModel(TransformationContext context, ITopLevelElement modelContext, SingleExplorationSolution solution, - SubClassToInstanceMap<S> baseModels, Class<U> transformedModelType, - String transformedModelName) throws Exception; + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, + Class<U> transformedModelType, String transformedModelName) throws Exception; /** * Generates models of the requested types ({@code transformedModelTypes}) using the set of - * solution models contained in the given {@link SingleExplorationSolutionMap} and the + * solution models contained in the given {@link SingleExplorationSolution} and the * collection of given {@code baseModel}s. * * @param context @@ -150,9 +156,11 @@ public interface IExplorationTransformationService * @param modelContext * Model context in which the transformed models would be stored. * @param encodings - * {@link SingleExplorationSolutionMap} containing the solution models. + * {@link SingleExplorationSolution} containing the solution models. * @param baseModels * EMF models used as a basis to generate the transformed model. + * @param superSets + * {@link SuperSet}s (= "models") calculated by the DSE. * @param transformedModelTypes * Type of the transformed models that shall be returned. * @param transformedModelName @@ -165,7 +173,7 @@ public interface IExplorationTransformationService <U extends EObject, S extends EObject> ClassToInstanceMap<U> getTransformedModels( TransformationContext context, ITopLevelElement modelContext, ExplorationEncodingMap<IExplorationEncoding> encodings, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, Collection<Class<? extends EObject>> transformedModelTypes, String transformedModelName) throws Exception; @@ -180,9 +188,11 @@ public interface IExplorationTransformationService * @param modelContext * Model context in which the transformed models would be stored. * @param encodings - * {@link SingleExplorationSolutionMap} containing the solution models. + * {@link SingleExplorationSolution} containing the solution models. * @param baseModels * EMF models used as a basis to generate the transformed model. + * @param superSets + * {@link SuperSet}s (= "models") calculated by the DSE. * @param transformedModelType * Type of the transformed model. * @param transformedModelName @@ -194,8 +204,8 @@ public interface IExplorationTransformationService */ <U extends EObject, S extends EObject> U getTransformedModel(TransformationContext context, ITopLevelElement modelContext, ExplorationEncodingMap<IExplorationEncoding> encodings, - SubClassToInstanceMap<S> baseModels, Class<U> transformedModelType, - String transformedModelName) throws Exception; + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, + Class<U> transformedModelType, String transformedModelName) throws Exception; /** * Resets the lists of {@link ITransformationModule}s registered at {@code this} diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/.ratings index f24f97799ffcf9dccc96f075d8017441bdc3bd52..6b6be46fb560c97dbebd427478030eb6d65f7327 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/.ratings @@ -1,4 +1,4 @@ ExplorationConstraintTransformationService.java 80031ad626c327df10bc00859a4036844544553b RED ExplorationEvaluationService.java 259ace09d86990428fb2ff9cfbff552cb4a69be8 RED ExplorationRepairService.java ac50a5e53792c6793ff4b8ad5aa9812141990f5c RED -ExplorationTransformationService.java 8ef2e60c6ef1372cee5e2e7afe7408c409744b2a RED +ExplorationTransformationService.java e9dae52c7d57d7e694f5696a4808b6eacbab1b96 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java index e8931f0f2340599edada928ca4599adaae1d4f5a..f442e61955ab8c5a7f278502758ff707e9aef952 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -41,6 +40,7 @@ import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService; +import org.fortiss.af3.exploration.model.SuperSetMap; import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution; import org.fortiss.af3.project.model.FileProject; import org.fortiss.af3.project.utils.ProjectUtils; @@ -196,11 +196,12 @@ public class ExplorationTransformationService<T extends ITransformationModule<?> public <U extends EObject, S extends EObject> U getTransformedModel( TransformationContext context, ITopLevelElement modelContext, SingleExplorationSolution solution, SubClassToInstanceMap<S> baseModels, - Class<U> transformedModelType, String transformedModelName) throws Exception { + SuperSetMap superSets, Class<U> transformedModelType, String transformedModelName) + throws Exception { Collection<Class<? extends EObject>> reqType = new ArrayList<>(); reqType.add(transformedModelType); ClassToInstanceMap<U> retMap = getTransformedModels(context, modelContext, solution, - baseModels, reqType, transformedModelName); + baseModels, superSets, reqType, transformedModelName); return retMap.getInstance(transformedModelType); } @@ -215,8 +216,8 @@ public class ExplorationTransformationService<T extends ITransformationModule<?> public <U extends EObject, S extends EObject> ClassToInstanceMap<U> getTransformedModels( TransformationContext context, ITopLevelElement modelContext, SingleExplorationSolution solution, SubClassToInstanceMap<S> baseModels, - Collection<Class<? extends EObject>> transformedModelTypes, String transformedModelName) - throws Exception { + SuperSetMap superSets, Collection<Class<? extends EObject>> transformedModelTypes, + String transformedModelName) throws Exception { // First, collect all transformation modules which would generate the requested output. Collection<ITransformationModule<?>> topLvlModules = new HashSet<>(); for(Class<? extends EObject> tModelType : transformedModelTypes) { @@ -270,22 +271,12 @@ public class ExplorationTransformationService<T extends ITransformationModule<?> setUpdateEnabled(false); SubClassToInstanceMap<U> transformedModels = MutableSubClassToInstanceMap.create(); - moduleInstance.transform(TransformationState.INITIALIZING, context, baseModels, + moduleInstance.transform(TransformationState.INITIALIZING, context, baseModels, superSets, solutionEncodings, transformedModels, null); if(context == TransformationContext.EXPORT && moduleInstance instanceof ITransformationStrategy) { - // Derive the file project from any of the base models - if(baseModels.isEmpty()) { - throw new Exception( - "Cannot add the transformed model to the parent project. No base model has been given by which the project is determined."); - } - - FileProject fp = null; - Iterator<S> bMit = baseModels.values().iterator(); - while(bMit.hasNext() && fp == null) { - fp = ProjectUtils.getFileProject(bMit.next()); - } + FileProject fp = ProjectUtils.getFileProject(modelContext.getRootModelElement()); ((ITransformationStrategy<?>)moduleInstance).addModelToProject(fp, modelContext); } @@ -308,12 +299,12 @@ public class ExplorationTransformationService<T extends ITransformationModule<?> public <U extends EObject, S extends EObject> U getTransformedModel( TransformationContext context, ITopLevelElement modelContext, ExplorationEncodingMap<IExplorationEncoding> phenotypes, - SubClassToInstanceMap<S> baseModels, Class<U> transformedModelType, - String transformedModelName) throws Exception { + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, + Class<U> transformedModelType, String transformedModelName) throws Exception { Collection<Class<? extends EObject>> reqType = new ArrayList<>(); reqType.add(transformedModelType); ClassToInstanceMap<U> retMap = getTransformedModels(context, modelContext, phenotypes, - baseModels, reqType, transformedModelName); + baseModels, superSets, reqType, transformedModelName); return retMap.getInstance(transformedModelType); } @@ -322,7 +313,7 @@ public class ExplorationTransformationService<T extends ITransformationModule<?> public <U extends EObject, S extends EObject> ClassToInstanceMap<U> getTransformedModels( TransformationContext context, ITopLevelElement modelContext, ExplorationEncodingMap<IExplorationEncoding> phenotypes, - SubClassToInstanceMap<S> baseModels, + SubClassToInstanceMap<S> baseModels, SuperSetMap superSets, Collection<Class<? extends EObject>> transformedModelTypes, String transformedModelName) throws Exception { // First, collect all transformation modules which would generate the requested output. @@ -374,7 +365,7 @@ public class ExplorationTransformationService<T extends ITransformationModule<?> SubClassToInstanceMap<U> transformedModels = MutableSubClassToInstanceMap.create(); @SuppressWarnings("unchecked") U transformedModel = (U)moduleInstance.transform(TransformationState.INITIALIZING, context, baseModels, - encodings, transformedModels, null); + superSets, encodings, transformedModels, null); if(transformedModel instanceof INamedElement) { ((INamedElement)transformedModel).setName(transformedModelName); diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/.ratings index b09aa57089ce4134c6ade4336adb9748cf939f0a..e3052f3c43c72aa41865924324cbad7a60d3d5b2 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/.ratings @@ -4,4 +4,4 @@ ExplorationAlgDebugUtils.java 06116a61e99717a59b7b01e4e2865bf044a8a0e2 RED ExplorationAlgUtils.java 2cf411c8d8404d7319d7bc836dd74b5927375711 RED ExplorationEcoreUtils.java 48ed07aec3cd93e66d37abc10d50636d591f1c71 RED GraphUtils.java 8b25592f30645f7709af527c72551f038a163833 RED -TransformationUtils.java d26cb8932c3dc81e7c75694241496b96214fdb9f RED +TransformationUtils.java 9b424a20d117a601f9c6a4a4a4ee9e4879c29195 YELLOW diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java index 9d65c136afeaccb0f8394ecbcf702095ce6d9b6b..71f17505a2b3b7084193309b3da6345b25f5a03e 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java @@ -16,7 +16,9 @@ package org.fortiss.af3.exploration.alg.util; import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createChannelAndAttach; +import static org.fortiss.tooling.common.util.LambdaUtils.getFirst; import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; +import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType; import java.util.ArrayList; import java.util.Collection; @@ -30,6 +32,10 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.fortiss.af3.allocation.model.AllocationEntry; +import org.fortiss.af3.allocation.model.ManyToOneAllocationEntry; +import org.fortiss.af3.allocation.model.OneToManyAllocationEntry; +import org.fortiss.af3.allocation.model.OneToOneAllocationEntry; import org.fortiss.af3.component.model.Channel; import org.fortiss.af3.component.model.Component; import org.fortiss.af3.component.model.ComponentArchitecture; @@ -44,7 +50,9 @@ import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationMo import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; +import org.fortiss.af3.exploration.dsl_v2.model.expression.SuperSet; import org.fortiss.af3.platform.model.PlatformArchitecture; +import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.base.model.layout.Dimension; import org.fortiss.tooling.base.model.layout.EOrientation; import org.fortiss.tooling.base.model.layout.ILayoutData; @@ -52,6 +60,7 @@ import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; import org.fortiss.tooling.base.model.layout.Point; import org.fortiss.tooling.base.utils.OffsetOrientationUtils; import org.fortiss.tooling.kernel.model.INamedElement; +import org.fortiss.tooling.kernel.model.IProjectRootElement; import com.google.common.collect.Multimap; @@ -66,6 +75,61 @@ public class TransformationUtils { private TransformationUtils() { } + /** + * Returns the architecture of the given type that contains one of the elements referenced by an + * {@link AllocationEntry} of the given {@link SuperSet}. + * + * @param superSet + * containing allocations with references to elements of an architecture of the given + * type. + * @param architectureType + * type of the containing architecture. + * @return The containing architecture, or {@code null} if the set references only elements that + * are contained in no {@link IProjectRootElement} or an architecture of a different + * type. + */ + @SuppressWarnings("unchecked") + public static <T extends IProjectRootElement> T getArchitectureOfAllocSuperSet( + SuperSet<? extends AllocationEntry> superSet, Class<T> architectureType) { + AllocationEntry entry = getFirst(superSet.getEntries()).orElse(null); + if(entry == null) { + return null; + } + + IProjectRootElement architectureModel = null; + + if(entry instanceof OneToOneAllocationEntry) { + IModelElement element = ((OneToOneAllocationEntry)entry).getSourceElement(); + architectureModel = getFirstParentWithType(element, architectureType); + if(architectureModel != null) { + return (T)architectureModel; + } + element = ((OneToOneAllocationEntry)entry).getTargetElement(); + architectureModel = getFirstParentWithType(element, architectureType); + return (T)architectureModel; + } else if(entry instanceof OneToManyAllocationEntry) { + IModelElement element = ((OneToManyAllocationEntry)entry).getSourceElement(); + architectureModel = getFirstParentWithType(element, architectureType); + if(architectureModel != null) { + return (T)architectureModel; + } + element = getFirst(((OneToManyAllocationEntry)entry).getTargetElements()).orElse(null); + architectureModel = getFirstParentWithType(element, architectureType); + return (T)architectureModel; + } else if(entry instanceof ManyToOneAllocationEntry) { + IModelElement element = + getFirst(((ManyToOneAllocationEntry)entry).getSourceElements()).orElse(null); + architectureModel = getFirstParentWithType(element, architectureType); + if(architectureModel != null) { + return (T)architectureModel; + } + element = ((ManyToOneAllocationEntry)entry).getTargetElement(); + architectureModel = getFirstParentWithType(element, architectureType); + return (T)architectureModel; + } + return null; + } + /** * Returns a list of target ports within the given {@link ComponentArchitecture}. Target ports * are defined as ports that do not have direct outputs.