added OS and Mapping transformers
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/Amlt2InchronTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/Amlt2InchronTransformer.xtend
index 83322fb..caed363 100644
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/Amlt2InchronTransformer.xtend
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/Amlt2InchronTransformer.xtend
@@ -15,7 +15,9 @@
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.ResourceSet
import templates.HWTransformer
+import templates.m2m.os.OSTransformer
import templates.utils.AmltCacheModel
+import templates.m2m.mapping.MappingTransformer
public class Amlt2InchronTransformer extends Model2ModelRootTransformer {
@@ -26,6 +28,11 @@
@Inject extension templates.m2m.hw.HWTransformer hwTransformer
+ @Inject extension OSTransformer osTransformer
+
+ @Inject extension MappingTransformer mappingTransformer
+
+
override m2mTransformation(ResourceSet inputResourceSet, ResourceSet outputResourceSet) {
/*- Associating CacheModel to the transformation.
* Note: This is a cummulative cache of all the elements from various input AMALTHEA model files.
@@ -98,7 +105,10 @@
transformMetaInfo(amalthea, it)
hwTransformer.transfromHWModel(amalthea.hwModel,it)
-
+
+ osTransformer.transfromOSModel(amalthea.osModel,it)
+
+ mappingTransformer.transfromMappingModel(amalthea.mappingModel, it)
}
/**
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/mapping/MappingTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/mapping/MappingTransformer.xtend
new file mode 100644
index 0000000..0726a8f
--- /dev/null
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/mapping/MappingTransformer.xtend
@@ -0,0 +1,111 @@
+package templates.m2m.mapping
+
+import com.inchron.realtime.root.model.Model
+import com.inchron.realtime.root.model.Scheduler
+import org.eclipse.app4mc.amalthea.model.MappingModel
+import org.eclipse.app4mc.amalthea.model.TaskScheduler
+import templates.AbstractAmaltheaInchronTransformer
+import templates.utils.AmltCacheModel
+
+class MappingTransformer extends AbstractAmaltheaInchronTransformer{
+
+
+ public def transfromMappingModel(MappingModel amltMappingModel, Model inchronModel) {
+
+ this.inchronModel=inchronModel
+
+ val AmltCacheModel cacheModel=customObjsStore.getInstance(AmltCacheModel)
+
+ //building cache
+ cacheModel.buildProcesses_SchedulerAllocationMap(amltMappingModel)
+
+ val rootTaskSchedulers = amltMappingModel?.schedulerAllocation?.map [ amltSchedulerAllocation |
+
+ if (amltSchedulerAllocation.scheduler instanceof TaskScheduler) {
+ return (amltSchedulerAllocation.scheduler as TaskScheduler).rootScheduler
+ }
+
+ ].toSet.filter[it != null]
+
+
+ //group elements based on the OS
+
+ var amltOsTaskSchedulersMap=cacheModel.groupTaskSchdulers(rootTaskSchedulers);
+
+ for(amltOS : amltOsTaskSchedulersMap.keySet){
+
+ var amlRootTaskSchedulers=amltOsTaskSchedulersMap.get(amltOS)
+
+ val Scheduler inchronRootIsrScheduler = inchronModelFactory.createScheduler
+
+ //Adding Root ISR scheduler to RTOSConfig
+ cacheModel.getInchronRtosConfig(amltOS.name)?.schedulables.add(inchronRootIsrScheduler)
+
+ if(amltOS.interruptControllers.size== 0){
+
+ inchronRootIsrScheduler.name=amltOS.name+"_ISRDummy"
+
+ //TODO: Migration rule -> considering responsibility from the first TaskScheduler of this OS
+
+ var amltSchedulerAllocation=cacheModel.taskScheduler_SchedulerAllocationMap.get(amlRootTaskSchedulers.get(0))
+
+ amltSchedulerAllocation.responsibility.forEach[amltProcessingUnit|{
+ inchronRootIsrScheduler.cpuCores.add(cacheModel.getInchronCpuCore(amltProcessingUnit.name))
+ }]
+
+
+
+ }else if(amltOS.interruptControllers.size== 1){
+
+ inchronRootIsrScheduler.name=amltOS.interruptControllers.get(0).name
+
+ var amltSchedulerAllocation=cacheModel.taskScheduler_SchedulerAllocationMap.get( amltOS.interruptControllers.get(0))
+
+ amltSchedulerAllocation.responsibility.forEach[amltProcessingUnit|{
+ inchronRootIsrScheduler.cpuCores.add(cacheModel.getInchronCpuCore(amltProcessingUnit.name))
+ }]
+
+ }else{
+ //todo: validation rule
+ }
+
+ //associating all the Root task schedulers to the ISR root scheduler
+ for(amltRootTaskScheduler : amlRootTaskSchedulers){
+
+ createInchronScheduler(amltRootTaskScheduler, inchronRootIsrScheduler, cacheModel)
+ }
+
+ }
+ }
+
+ protected def void createInchronScheduler(TaskScheduler amltTaskschduler, Scheduler parentISRScheduler, AmltCacheModel cacheModel) {
+ val Scheduler inchronScheduler = inchronModelFactory.createScheduler
+
+ inchronScheduler.name=amltTaskschduler.name
+
+ parentISRScheduler.schedulables.add(inchronScheduler)
+
+ var amltSchedulerAllocation=cacheModel.taskScheduler_SchedulerAllocationMap.get(amltTaskschduler)
+
+ amltSchedulerAllocation.responsibility.forEach[amltProcessingUnit|{
+ inchronScheduler.cpuCores.add(cacheModel.getInchronCpuCore(amltProcessingUnit.name))
+ }]
+
+ var amltChildTaskSchedulers=amltTaskschduler.childSchedulers
+
+ for (amltChildTaskScheduler : amltChildTaskSchedulers) {
+ createInchronScheduler(amltChildTaskScheduler,inchronScheduler,cacheModel )
+ }
+ }
+
+ /**
+ * This method is used to return the root TaskScheduler object
+ */
+ def TaskScheduler getRootScheduler(TaskScheduler sch) {
+
+ if (sch.parentScheduler == null) {
+ return sch
+ }
+ return getRootScheduler(sch.parentScheduler)
+ }
+}
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/os/OSTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/os/OSTransformer.xtend
new file mode 100644
index 0000000..81d37b2
--- /dev/null
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/m2m/os/OSTransformer.xtend
@@ -0,0 +1,46 @@
+package templates.m2m.os
+
+import com.inchron.realtime.root.model.Model
+import org.eclipse.app4mc.amalthea.model.OSModel
+import templates.AbstractAmaltheaInchronTransformer
+import templates.utils.AmltCacheModel
+
+class OSTransformer extends AbstractAmaltheaInchronTransformer{
+
+
+ public def transfromOSModel(OSModel amltHWModel, Model inchronModel) {
+
+ this.inchronModel=inchronModel
+
+ val AmltCacheModel cacheModel=customObjsStore.getInstance(AmltCacheModel)
+
+ amltHWModel.operatingSystems.forEach[amltOS|
+ {
+ var inchronSystem=inchronModelFactory.createGenericSystem
+
+ inchronSystem.name=amltOS.name+"_SYSTEM"
+
+ var inchronRtosConfig=inchronModelFactory.createRtosConfig
+
+ inchronRtosConfig.name=amltOS.name
+
+ inchronSystem.rtosConfig=inchronRtosConfig
+
+ //RtosModel with default attributes
+ var inchronRtosModel=inchronModelFactory.createRtosModel
+
+ inchronRtosModel.name="generic"
+ inchronRtosModel.returnType="void"
+
+ inchronSystem.rtosModel=inchronRtosModel
+
+ //Adding Inchron System object to Model
+ inchronModel.systems.add(inchronSystem)
+
+ cacheModel.addInchronRtosConfig(inchronSystem.rtosConfig)
+ }
+ ]
+
+
+ }
+}
\ No newline at end of file
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 36ee47c..bb4d960 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
@@ -22,6 +22,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.OperatingSystem;
import org.eclipse.app4mc.amalthea.model.Process;
import org.eclipse.app4mc.amalthea.model.Scheduler;
import org.eclipse.app4mc.amalthea.model.SchedulerAllocation;
@@ -34,6 +35,7 @@
import com.inchron.realtime.root.model.Clock;
import com.inchron.realtime.root.model.CpuCore;
import com.inchron.realtime.root.model.GenericSystem;
+import com.inchron.realtime.root.model.RtosConfig;
import com.inchron.realtime.root.model.Semaphore;
import com.inchron.realtime.root.model.memory.Memory;
@@ -45,6 +47,8 @@
private Map<String,Memory> inchronMemoriesMap = new HashMap<>();
private Map<String,CpuCore> inchronCpuCoresMap = new HashMap<>();
+
+ private Map<String,RtosConfig> inchronRtosConfigMap = new HashMap<>();
@@ -226,6 +230,23 @@
}
+ public Map<OperatingSystem, List<TaskScheduler>> groupTaskSchdulers(Iterable<TaskScheduler> rootTaskSchedulers){
+
+ Map<OperatingSystem, List<TaskScheduler>> map=new HashMap<>();
+
+ for (TaskScheduler taskScheduler : rootTaskSchedulers) {
+
+ List<TaskScheduler> list = map.get(taskScheduler.eContainer() );
+
+ if(list ==null) {
+ list=new ArrayList<TaskScheduler>();
+ map.put((OperatingSystem)taskScheduler.eContainer(), list);
+ }
+ list.add(taskScheduler);
+ }
+ return map;
+ }
+
public void addInchronClock(Clock obj) {
inchronClocksMap.put(obj.getName(), obj);
}
@@ -236,6 +257,15 @@
+ public void addInchronRtosConfig(RtosConfig obj) {
+ inchronRtosConfigMap.put(obj.getName(), obj);
+ }
+
+ public RtosConfig getInchronRtosConfig(String name) {
+ return inchronRtosConfigMap.get(name);
+ }
+
+
public void addInchronMemory(Memory inchronMemory) {
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.product/.gitignore b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.product/.gitignore
index 8190ce6..e180425 100644
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.product/.gitignore
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.product/.gitignore
@@ -2,4 +2,4 @@
/target/
/xtend-gen/
/output
-/input/Obfuscated_Model.amxmi
\ No newline at end of file
+/input/*/Obfuscated_Model.amxmi
\ No newline at end of file