added transformation for CustomEventTrigger
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/CustomEventTriggerTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/CustomEventTriggerTransformer.xtend
new file mode 100644
index 0000000..90c67c7
--- /dev/null
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/CustomEventTriggerTransformer.xtend
@@ -0,0 +1,130 @@
+package templates.m2m.sw
+
+import com.google.inject.Inject
+import com.inchron.realtime.root.model.ActivationConnection
+import com.inchron.realtime.root.model.Component
+import com.inchron.realtime.root.model.FunctionCall
+import java.util.LinkedHashMap
+import org.eclipse.app4mc.amalthea.model.CustomEventTrigger
+import org.eclipse.app4mc.amalthea.model.EventStimulus
+import org.eclipse.app4mc.amalthea.model.Process
+import templates.AbstractAmaltheaInchronTransformer
+import templates.utils.AmaltheaModelNagivationUtils
+import templates.utils.AmltCacheModel
+
+class CustomEventTriggerTransformer extends AbstractAmaltheaInchronTransformer {
+
+ var AmltCacheModel cacheModel
+
+ @Inject ModeValueDisjunctionTransformer modeValueDisjunctionTransformer
+
+ public def FunctionCall transformCustomEventTrigger(Component inchronComponent, Process amltTask,
+ CustomEventTrigger amltCustomEventTrigger){
+
+ cacheModel = customObjsStore.getInstance(AmltCacheModel)
+
+ val amltCustomEvent= amltCustomEventTrigger.event
+
+ val amltStimulusInchronActivationConnectionsMap=new LinkedHashMap<EventStimulus, ActivationConnection>
+
+ if(amltCustomEvent !==null){
+ val amltCustomEventBackReferences=AmaltheaModelNagivationUtils.getBackReferences(amltCustomEvent,true);
+
+ for (amltCustomEventBackReference : amltCustomEventBackReferences) {
+
+ if(amltCustomEventBackReference instanceof EventStimulus){
+ //listing the tasks which are stimulated by EventStimulus
+ val inchronActivationConnection=createActivationConnection(amltCustomEventBackReference)
+
+ amltStimulusInchronActivationConnectionsMap.put(amltCustomEventBackReference, inchronActivationConnection)
+
+ }
+ }
+ }
+
+
+ val inchronDummyFunction=inchronModelFactory.createFunction
+
+ inchronDummyFunction.name="Dummy_CustomEventTriggerFunction_"+amltCustomEventTrigger.hashCode
+ //Adding Function to Inchron Component
+ inchronComponent.functions.add(inchronDummyFunction)
+
+ val inchronCallGraph=inchronModelFactory.createCallGraph
+
+ inchronDummyFunction.callGraph=inchronCallGraph
+
+ val inchronModeSwitch=inchronModelFactory.createModeSwitch
+
+ //Adding ModeSwitch
+ inchronCallGraph.graphEntries.add(inchronModeSwitch)
+
+ //Transforming mode entries with condition
+
+
+ //############# now creating ActivationItem and associating ActivationConnection objects
+
+ amltStimulusInchronActivationConnectionsMap.forEach[amltEventStimulus, inchronActivationConnection|
+
+ val inchronModeSwitchEntry=inchronModelFactory.createModeSwitchEntry
+
+ //Adding entry with condition
+ inchronModeSwitch.entries.add(inchronModeSwitchEntry)
+
+ var amltCondition=amltEventStimulus.enablingModeValueList
+
+ if(amltCondition!==null){
+ var inchronConditon=modeValueDisjunctionTransformer.createModeCondition(amltCondition,amltTask)
+
+ inchronModeSwitchEntry.condition = inchronConditon
+
+ if(inchronConditon.eContainer===null){
+ //Adding ModeCondition to the Inchron Model
+ cacheModel.inchronModel.globalModeConditions.add(inchronConditon)
+ }
+ }
+
+ val inchronCallSequence=inchronModelFactory.createCallSequence
+
+ val inchronActivationItem=inchronModelFactory.createActivationItem
+
+ inchronActivationItem.connection=inchronActivationConnection
+
+ inchronCallSequence.calls.add(inchronActivationItem)
+
+ //Adding callSequence to default entry
+ inchronModeSwitchEntry.graphEntries.add(inchronCallSequence)
+
+ ]
+
+
+ var FunctionCall inchronFunctionCall=inchronModelFactory.createFunctionCall
+
+ inchronFunctionCall.function=inchronDummyFunction
+
+ inchronFunctionCall.name="call_"+inchronDummyFunction.name
+
+ return inchronFunctionCall
+
+ }
+
+ protected def create inchronModelFactory.createActivationConnection createActivationConnection(EventStimulus amltCustomEventBackReference) {
+ val amltTasks=amltCustomEventBackReference.affectedProcesses
+
+
+ it.name = "EventStimulus_"+amltCustomEventBackReference.name
+
+ cacheModel.inchronModel.connections.add(it)
+
+ amltTasks.forEach[amltStimulatedTask|{
+ var inchronActivateProcess = inchronModelFactory.createActivateProcess
+
+ inchronActivateProcess.target = cacheModel.amltProcess_inchronProcessMap.get(amltStimulatedTask)
+
+ it.activations.add(inchronActivateProcess)
+ }]
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeLabelTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeLabelTransformer.xtend
new file mode 100644
index 0000000..0cba77c
--- /dev/null
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeLabelTransformer.xtend
@@ -0,0 +1,43 @@
+package templates.m2m.sw
+
+import com.inchron.realtime.root.model.ModeGroup
+import org.eclipse.app4mc.amalthea.model.ModeLabel
+import org.eclipse.app4mc.amalthea.model.ModeLiteral
+import templates.AbstractAmaltheaInchronTransformer
+import templates.utils.AmltCacheModel
+
+class ModeLabelTransformer extends AbstractAmaltheaInchronTransformer {
+
+ var AmltCacheModel cacheModel
+
+
+ public def create inchronModelFactory.createModeGroup createModeGroup(ModeLabel amltModeLabel){
+
+ cacheModel = customObjsStore.getInstance(AmltCacheModel)
+
+ it.name=amltModeLabel.name
+
+ var amltModeLiteralInitialValue= amltModeLabel.initialValue
+
+
+ amltModeLiteralInitialValue?.containingMode?.literals?.forEach[literal, index|{
+ createMode(literal,index, it)
+ }]
+
+ it.initialMode = cacheModel.amltModeLiteralInchronModeMap.get(amltModeLiteralInitialValue)
+
+ cacheModel.addInchronModeGroup(it)
+ }
+
+
+
+ public def create inchronModelFactory.createMode createMode(ModeLiteral amltModeLiteral, int index, ModeGroup inchronModeGroup){
+
+ it.name=amltModeLiteral.name
+ it.value=index
+
+ inchronModeGroup.modes.add(it)
+
+ cacheModel.amltModeLiteralInchronModeMap.put(amltModeLiteral, it)
+ }
+}
\ No newline at end of file
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeTransformer.xtend
deleted file mode 100644
index 99d054b..0000000
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeTransformer.xtend
+++ /dev/null
@@ -1,31 +0,0 @@
-package templates.m2m.sw
-
-import org.eclipse.app4mc.amalthea.model.Mode
-import org.eclipse.app4mc.amalthea.model.ModeLiteral
-import templates.AbstractAmaltheaInchronTransformer
-import templates.utils.AmltCacheModel
-
-class ModeTransformer extends AbstractAmaltheaInchronTransformer {
-
- var AmltCacheModel cacheModel
-
- public def create inchronModelFactory.createModeGroup createModeGroup(Mode amltMode){
-
- cacheModel = customObjsStore.getInstance(AmltCacheModel)
-
- it.name=amltMode.name
-
- amltMode?.literals?.forEach[amltModeLiteral, index|{
- it.modes.add(createMode(amltModeLiteral,index))
- }]
-
- cacheModel.addInchronModeGroup(it)
- }
-
-
- public def create inchronModelFactory.createMode createMode(ModeLiteral amltModeLiteral, int index){
-
- it.name=amltModeLiteral.name
- it.value=index
- }
-}
\ No newline at end of file
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeValueDisjunctionTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeValueDisjunctionTransformer.xtend
index 8e678a1..cbf5ecd 100644
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeValueDisjunctionTransformer.xtend
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/ModeValueDisjunctionTransformer.xtend
@@ -34,7 +34,7 @@
val amltModeLiteral=amltModeValueDisjunctionEntry.value
var amltModeValueProvider=amltModeValueDisjunctionEntry.valueProvider
//Adding Mode
- inchronModeConjunction.modes.add(getInchronMode(amltModeLiteral ))
+ inchronModeConjunction.modes.add(cacheModel.amltModeLiteralInchronModeMap.get(amltModeLiteral ))
}else if(amltModeValueDisjunctionEntry instanceof ModeValueConjunction){
@@ -43,7 +43,7 @@
var amltModeLiteral=amltModeValueEntry.value
var amltModeValueProvider=amltModeValueEntry.valueProvider
//Adding Mode
- inchronModeConjunction.modes.add(getInchronMode(amltModeLiteral ))
+ inchronModeConjunction.modes.add(cacheModel.amltModeLiteralInchronModeMap.get(amltModeLiteral ))
}]
}
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/RunnableItemTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/RunnableItemTransformer.xtend
index 1317fca..1169dc4 100644
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/RunnableItemTransformer.xtend
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/RunnableItemTransformer.xtend
@@ -11,6 +11,7 @@
import com.inchron.realtime.root.model.CallSequenceItem
import org.eclipse.app4mc.amalthea.model.RunnableModeSwitch
import java.util.List
+import org.eclipse.app4mc.amalthea.model.CustomEventTrigger
class RunnableItemTransformer extends AbstractAmaltheaInchronTransformer{
@@ -19,6 +20,8 @@
@Inject TicksTransformer ticksTransformer
@Inject ModeSwitchTransformer modeSwitchTransformer
+
+ @Inject CustomEventTriggerTransformer customEventTriggerTransformer
def List<CallSequenceItem> transformRunnableItem(Component inchronComponent, org.eclipse.app4mc.amalthea.model.Process amltTask,
RunnableItem amltRunnableItem) {
@@ -42,7 +45,11 @@
var inchronFunctionCall = modeSwitchTransformer.transformRunnableModeSwitch(inchronComponent, amltTask,amltRunnableItem)
list.add(inchronFunctionCall)
- }
+ } else if(amltRunnableItem instanceof CustomEventTrigger){
+ var inchronFunctionCall = customEventTriggerTransformer.transformCustomEventTrigger(inchronComponent, amltTask,amltRunnableItem)
+
+ list.add(inchronFunctionCall)
+ }
return list
}
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/SWTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/SWTransformer.xtend
index c68119f..743e228 100644
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/SWTransformer.xtend
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/sw/SWTransformer.xtend
@@ -36,20 +36,27 @@
@Inject GraphEntryBaseTransformer graphEntryBaseTransformer
@Inject RunnableTransformer runnableTransformer
@Inject CallGraphTransformer callGraphTransformer
- @Inject ModeTransformer modeTransformer
+ @Inject ModeLabelTransformer modeLabelTransformer
- val Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap = new HashMap
def transformSWModel(SWModel amltSwModel, Model inchronModel) {
this.inchronModel = inchronModel
cacheModel = customObjsStore.getInstance(AmltCacheModel)
+
+ val Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap = new HashMap
- amltSwModel?.modes?.forEach[amltMode|{
- inchronModel.globalModeGroups.add(modeTransformer.createModeGroup(amltMode))
+ cacheModel.amltProcess_inchronProcessMap=amltProcess_inchronProcessMap
+
+ amltSwModel?.modeLabels?.forEach[amltModeLabel|{
+ inchronModel.globalModeGroups.add(modeLabelTransformer.createModeGroup(amltModeLabel))
}]
+
+// amltSwModel?.modes?.forEach[amltMode|{
+// inchronModel.globalModeGroups.add(modeTransformer.createModeGroup(amltMode))
+// }]
val inchronScheduler_amltSchedulerMap = cacheModel.getInchronScheduler_amltSchedulerMap()
@@ -112,11 +119,14 @@
val inchronActivationConnection = cacheModel.amltStimuli_inchronActivationConnectionMap.get(
amltStimuli.name)
- var inchronActivateProcess = inchronModelFactory.createActivateProcess
-
- inchronActivateProcess.target = amltProcess_inchronProcessMap.get(amltProcess)
-
- inchronActivationConnection?.activations?.add(inchronActivateProcess)
+ if(inchronActivationConnection!==null){
+ var inchronActivateProcess = inchronModelFactory.createActivateProcess
+
+ inchronActivateProcess.target = amltProcess_inchronProcessMap.get(amltProcess)
+
+ inchronActivationConnection?.activations?.add(inchronActivateProcess)
+ }
+
]
]
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/utils/AmaltheaModelNagivationUtils.java b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/utils/AmaltheaModelNagivationUtils.java
new file mode 100644
index 0000000..0ee0523
--- /dev/null
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/utils/AmaltheaModelNagivationUtils.java
@@ -0,0 +1,49 @@
+package templates.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.app4mc.amalthea.model.AmaltheaCrossReferenceAdapter;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+
+public class AmaltheaModelNagivationUtils {
+
+ public static synchronized AmaltheaCrossReferenceAdapter getOrCreateAmaltheaAdapter(final Notifier target) {
+ // Try to get Amalthea adapter
+ final EList<Adapter> adapters = target.eAdapters();
+ for (final Adapter adapter : adapters) {
+ if (adapter instanceof AmaltheaCrossReferenceAdapter) {
+ return (AmaltheaCrossReferenceAdapter) adapter;
+ }
+ }
+
+ // Create Amalthea adapter
+ final AmaltheaCrossReferenceAdapter amaltheaAdapter = new AmaltheaCrossReferenceAdapter();
+ adapters.add(amaltheaAdapter);
+ return amaltheaAdapter;
+ }
+
+ public static Collection<EObject> getBackReferences(EObject eObject, boolean resolve){
+
+ List<EObject> result=new ArrayList<EObject>();
+
+ Collection<Setting> references = getOrCreateAmaltheaAdapter(eObject).getNonNavigableInverseReferences(eObject, resolve);
+
+ for (Setting setting : references) {
+ EObject eObject2 = setting.getEObject();
+
+ if(result.contains(eObject2)==false) {
+ result.add(eObject2);
+ }
+ }
+ return result;
+
+ }
+
+
+}
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/utils/AmltCacheModel.java b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/utils/AmltCacheModel.java
index b597f52..547de23 100644
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/utils/AmltCacheModel.java
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/utils/AmltCacheModel.java
@@ -23,6 +23,7 @@
import org.eclipse.app4mc.amalthea.model.HwStructure;
import org.eclipse.app4mc.amalthea.model.InterruptController;
import org.eclipse.app4mc.amalthea.model.MappingModel;
+import org.eclipse.app4mc.amalthea.model.ModeLiteral;
import org.eclipse.app4mc.amalthea.model.OperatingSystem;
import org.eclipse.app4mc.amalthea.model.Process;
import org.eclipse.app4mc.amalthea.model.Scheduler;
@@ -37,6 +38,7 @@
import com.inchron.realtime.root.model.Component;
import com.inchron.realtime.root.model.CpuCore;
import com.inchron.realtime.root.model.GenericSystem;
+import com.inchron.realtime.root.model.Mode;
import com.inchron.realtime.root.model.ModeGroup;
import com.inchron.realtime.root.model.Model;
import com.inchron.realtime.root.model.RtosConfig;
@@ -57,7 +59,11 @@
private Map<String, ModeGroup> inchronModeGroupsMap = new HashMap<>();
+ private Map<ModeLiteral, Mode> amltModeLiteral_inchronModesMap = new HashMap<>();
+
private Map<Process, Component> amltProcess_InchronComponentMap = new HashMap<>();
+
+ private Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap = new HashMap<>();
private Model inchronModel;
@@ -261,6 +267,17 @@
public Map<String, Clock> getInchronClocksMap() {
return inchronClocksMap;
}
+ public Map<ModeLiteral, Mode> getAmltModeLiteralInchronModeMap() {
+ return amltModeLiteral_inchronModesMap;
+ }
+ public Map<Process, com.inchron.realtime.root.model.Process> getAmltProcess_inchronProcessMap() {
+ return amltProcess_inchronProcessMap;
+ }
+
+ public void setAmltProcess_inchronProcessMap(
+ Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap) {
+ this.amltProcess_inchronProcessMap = amltProcess_inchronProcessMap;
+ }
public void addInchronScheduler_amltSchedulerMap(com.inchron.realtime.root.model.Scheduler inchronScheduler,
Scheduler amltScheduler) {