diff --git a/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/blackbox/VSLUtils.java b/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/blackbox/VSLUtils.java index 25943114d0235321ebcf692c4ce86d85f8556036..95fcb7f0ba7126b4410b71f1281b8770bfe09f71 100644 --- a/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/blackbox/VSLUtils.java +++ b/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/blackbox/VSLUtils.java @@ -43,6 +43,7 @@ import org.eclipse.uml2.uml.ValueSpecification; import org.polarsys.chess.chessmlprofile.Core.IdentifInstance; import org.polarsys.chess.chessmlprofile.Core.IdentifSlot; import org.polarsys.chess.chessmlprofile.Predictability.DeploymentConfiguration.HardwareBaseline.CH_HwProcessor; +import org.polarsys.chess.chessmlprofile.Predictability.RTComponentModel.CHRtPortSlot; public class VSLUtils { @@ -520,6 +521,69 @@ public class VSLUtils { return list; } + @Operation(kind = Kind.HELPER, contextual = true, withExecutionContext = true) + public static EList<Slot> getSlotInstances(IContext context, + org.eclipse.uml2.uml.Comment self, + org.eclipse.uml2.uml.Package inst, + org.eclipse.uml2.uml.Package instFull) { + EList<Slot> list = new BasicEList<Slot>(); + + Assign ass = getStereotypeApplication(self, Assign.class); + Slot slotInst = extractFirstSlot(ass.getFrom()); + + InstanceSpecification originatingInst = slotInst.getOwningInstance(); + + if (slotInst == null) + return list; + + if (!inst.allOwnedElements().contains(slotInst)) + return list; + + + + int[] bounds = getBounds(self); + + if (bounds != null) + for (Element el : instFull.allOwnedElements()) { + + IdentifInstance id = getStereotypeApplication(el, + IdentifInstance.class); + + if (el instanceof InstanceSpecification && id != null) { + if (isInBounds(id.getId(), bounds) + && id.getSourceInstanceSpec() == originatingInst){ + + for (Element e : el.getOwnedElements()) { + if (!(e instanceof Slot)) continue; + Slot slot = (Slot) e; + if(slot.getDefiningFeature().equals(slotInst.getDefiningFeature())){ + list.add((Slot) e); + break; + } + } + } + } + } + else + for (Element el : instFull.allOwnedElements()) { + IdentifInstance id = getStereotypeApplication(el, + IdentifInstance.class); + if (el instanceof InstanceSpecification && id != null + && id.getSourceInstanceSpec() == originatingInst) { + for (Element e : el.getOwnedElements()) { + if (!(e instanceof Slot)) continue; + Slot slot = (Slot) e; + if(slot.getDefiningFeature().equals(slotInst.getDefiningFeature())){ + list.add((Slot) e); + break; + } + } + } + } + + return list; + } + @Operation(kind = Kind.HELPER, contextual = true, withExecutionContext = true) public static EList<InstanceSpecification> getInstances(IContext context, org.eclipse.uml2.uml.Comment self, @@ -528,7 +592,7 @@ public class VSLUtils { EList<InstanceSpecification> list = new BasicEList<InstanceSpecification>(); Assign ass = getStereotypeApplication(self, Assign.class); - InstanceSpecification originatingInst = (InstanceSpecification) ass.getFrom().get(0); + InstanceSpecification originatingInst = extractFirstInstance(ass.getFrom()); if (originatingInst == null) return list; @@ -578,6 +642,26 @@ public class VSLUtils { // return list; // } + private static Slot extractFirstSlot(EList<Element> from) { + for (Element element : from) { + if (element instanceof Slot) { + Slot sl = (Slot) element; + return sl; + } + } + return null; + } + + private static InstanceSpecification extractFirstInstance(EList<Element> from) { + for (Element element : from) { + if (element instanceof InstanceSpecification) { + InstanceSpecification is = (InstanceSpecification) element; + return is; + } + } + return null; + } + @Operation(kind = Kind.HELPER, contextual = true, withExecutionContext = true) public static Boolean isReferringId(IContext context, org.eclipse.uml2.uml.Comment self, Integer id) { diff --git a/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/transformations/AbstractTransformation.java b/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/transformations/AbstractTransformation.java index bdbeb11f03c178046cc60292cf1357bb84009c3d..3b487c7e177bfeea534533b9639f639c1ef3bc8a 100644 --- a/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/transformations/AbstractTransformation.java +++ b/plugins/org.polarsys.chess.m2m/src/org/polarsys/chess/m2m/transformations/AbstractTransformation.java @@ -18,6 +18,7 @@ import org.polarsys.chess.m2m.TransformationResultsData; public abstract class AbstractTransformation { + private static final boolean DEBUG = false; private String folder = TransUtil.TRANSFORMATIONS_DIR; private IFolder transDir; protected Map<String, String> configProperty; @@ -78,8 +79,10 @@ public abstract class AbstractTransformation { //Execute the various steps of the transformations // Remove the package with the multi instances, if any - //TO COMMENT FOR DEBUG - QVToTransformation.launchRemoveMultiInstance(modelCopy, monitor); + //TO COMMENT FOR DEBUG + if(!DEBUG){ + QVToTransformation.launchRemoveMultiInstance(modelCopy, monitor); + } QVToTransformation.launchBuildMultiInstance(modelCopy, monitor); build1(monitor, modelCopy); diff --git a/plugins/org.polarsys.chess.m2m/transformations/CHESS_PIM2PSM_Inst_full_VERDE.qvto b/plugins/org.polarsys.chess.m2m/transformations/CHESS_PIM2PSM_Inst_full_VERDE.qvto index 4e6d126b6ce470bd820d7e62bdece4f956d949d2..afadbf06fbd2dbdd3661b08b6fb8690a7d2d1799 100644 --- a/plugins/org.polarsys.chess.m2m/transformations/CHESS_PIM2PSM_Inst_full_VERDE.qvto +++ b/plugins/org.polarsys.chess.m2m/transformations/CHESS_PIM2PSM_Inst_full_VERDE.qvto @@ -69,6 +69,8 @@ property currentSlot : Slot = null; property currentProcessor : InstanceSpecification = null; property currentCore : String = null; property currentHost : MARTE::SAM::SaExecHost = null; + +property slotinAssigns = false; //property currentSharedRes : MARTE::SAM::SaSharedResource = null; main() { @@ -230,6 +232,9 @@ mapping Package::CHGaResourcePlatform2SaAnalysisContext(saAnalysisCtx : MARTE::S //TODO assumption: one annotatedElement per Assign var list := ass.getInstances(instSpecPackage, instSpecFullPackage); + if(list->size()>0){ + + slotinAssigns := false; list->forEach(e){ var id := e.getMetaclass("CHESS::Core::IdentifInstance").oclAsType(CHESS::Core::IdentifInstance); slotInstances += e.slot->select(owningInstance.classifier <> null and isCHRtPortSlotCorrect())->asSet(); @@ -238,6 +243,13 @@ mapping Package::CHGaResourcePlatform2SaAnalysisContext(saAnalysisCtx : MARTE::S /*it is a partition*/ }; } + } else { + slotinAssigns := true; + var slotList := ass.getSlotInstances(instSpecPackage, instSpecFullPackage); + slotInstances += slotList; + + } + }; log("Slot list(" + slotInstances->size().toString()+"):"); @@ -560,8 +572,15 @@ mapping InstanceSpecification::Instance2SwSchedulableResource(chrt : Comment, sl if(currentHost <> null){ sr.host := currentHost;//currentProcessor.getHost(currentCore); } else { - var hostClassifier := getAssignToFrom_MemoryPartition(slot.owningInstance); - sr.host := hostClassifier.getHost(getAssignedCoreFrom_MemoryPartition(slot.owningInstance)); + + + if(slotinAssigns){ + var hostClassifier := getAssignToFrom_MemoryPartition(slot); + sr.host := hostClassifier.getHost(getAssignedCoreFrom_MemoryPartition(slot)); + } else { + var hostClassifier := getAssignToFrom_MemoryPartition(slot.owningInstance); + sr.host := hostClassifier.getHost(getAssignedCoreFrom_MemoryPartition(slot.owningInstance)); + } }; assert fatal (sr.host <> null) with log("Null Host for SwSchedulableResource '" +result.name+ "'."); @@ -1586,6 +1605,10 @@ query getAssignForInstance(p : InstanceSpecification) : MARTE::Alloc::Assign { return assigns->selectOne(isAssignForInstance(p)).getMetaclass(AssignQN).oclAsType(MARTE::Alloc::Assign); } +query getAssignForInstance(p : Slot) : MARTE::Alloc::Assign { + return assigns->selectOne(isAssignForInstance(p)).getMetaclass(AssignQN).oclAsType(MARTE::Alloc::Assign); +} + query InstanceSpecification::getComponentsOfPartition() : Set(InstanceSpecification) { return partitionAssigns->select(isAssignForPartition(self)).getMetaclass(AssignQN).oclAsType(MARTE::Alloc::Assign)._from.oclAsType(InstanceSpecification)->asSet(); } @@ -1615,6 +1638,11 @@ query Comment::isAssignForInstance(spec : InstanceSpecification) : Boolean { return ass._from![InstanceSpecification] = spec.getSourceInstanceSpec() and self.isReferringId(spec.getId()); } +query Comment::isAssignForInstance(spec : Slot) : Boolean { + var ass := self.getMetaclass(AssignQN).oclAsType(MARTE::Alloc::Assign); + return ass._from![Slot].definingFeature = spec.definingFeature; +} + query Comment::isAssignForPartition(p : InstanceSpecification) : Boolean { var ass := self.getMetaclass(AssignQN).oclAsType(MARTE::Alloc::Assign); return ass.to![InstanceSpecification] = p; @@ -1625,6 +1653,38 @@ query Comment::isAssignForPartition(p : Classifier) : Boolean { return ass.to![InstanceSpecification].classifier![Classifier] = p; } +query getAssignToFrom_MemoryPartition(p : Slot) : InstanceSpecification { + var ass := getAssignForInstance(p); + var toInstance := ass.to![InstanceSpecification]; + var toClass := toInstance.classifier![Classifier]; + if toClass.isStereotyped(MemoryPartitionQN) then { + var a := assigns -> selectOne(isAssignedFrom(toInstance)); + var asg := a.getMetaclass(AssignQN).oclAsType(MARTE::Alloc::Assign); + return asg.to![InstanceSpecification]; + } else //it is an hardware component + return ass.to![InstanceSpecification] + endif; + + return null; +} + +query getAssignedCoreFrom_MemoryPartition(p : Slot) : String { + + //TODO how do we get a core if there is a memory partition? + var ass := getAssignForInstance(p); + var toInstance := ass.to![InstanceSpecification]; + var toClass := toInstance.classifier![Classifier]; + if toClass.isStereotyped(MemoryPartitionQN) then { + var a := assigns -> selectOne(isAssignedFrom(toInstance)); + var asg := a.getMetaclass(AssignQN).oclAsType(MARTE::Alloc::Assign); + return asg.base_Comment.getCoreFromContraint(); + } else //it is an hardware component + return ass.base_Comment.getCoreFromContraint() + endif; + + return null; +} + query getAssignToFrom_MemoryPartition(p : InstanceSpecification) : InstanceSpecification { var ass := getAssignForInstance(p); var toInstance := ass.to![InstanceSpecification];