| package templates.m2m.sw |
| |
| import com.google.inject.Inject |
| import com.inchron.realtime.root.model.Model |
| import java.util.HashMap |
| import java.util.Map |
| import org.eclipse.app4mc.amalthea.model.InterruptController |
| import org.eclipse.app4mc.amalthea.model.OperatingSystem |
| import org.eclipse.app4mc.amalthea.model.Process |
| import org.eclipse.app4mc.amalthea.model.SWModel |
| import org.eclipse.app4mc.amalthea.model.TaskScheduler |
| import templates.AbstractAmaltheaInchronTransformer |
| import templates.utils.AmltCacheModel |
| |
| class SWTransformer extends AbstractAmaltheaInchronTransformer { |
| |
| var AmltCacheModel cacheModel |
| |
| @Inject TaskTransformer taskTransformer |
| @Inject ISRTransformer isrTransformer |
| @Inject GraphEntryBaseTransformer graphEntryBaseTransformer |
| @Inject RunnableTransformer runnableTransformer |
| |
| 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 inchronScheduler_amltSchedulerMap = cacheModel.getInchronScheduler_amltSchedulerMap() |
| |
| inchronScheduler_amltSchedulerMap.forEach [ inchronScheduler, amltScheduler | |
| |
| if (amltScheduler !== null) { |
| |
| var amltOS = amltScheduler.eContainer as OperatingSystem |
| val inchronComponent = cacheModel.getInchronComponent(amltOS.name + "_SWC") |
| |
| if (amltScheduler instanceof TaskScheduler) { |
| amltScheduler.taskAllocations.forEach [ amltTaskAllocation | |
| |
| var amltTask = amltTaskAllocation.task |
| |
| val inchronProcess = taskTransformer.createProcess(amltTask, inchronComponent) |
| |
| amltProcess_inchronProcessMap.put(amltTask, inchronProcess) |
| |
| amltTaskAllocation.affinity.forEach [ amltPU | |
| { |
| var inchronCpuCore = cacheModel.getInchronCpuCore(amltPU.name) |
| if (inchronCpuCore !== null) { |
| inchronProcess.cpuCores.add(inchronCpuCore) |
| } |
| } |
| ] |
| |
| inchronScheduler.schedulables.add(inchronProcess) |
| ] |
| } else if (amltScheduler instanceof InterruptController) { |
| |
| amltScheduler.isrAllocations.forEach [ amltISRAllocation | |
| var amltISR = amltISRAllocation.isr |
| val inchronProcess = isrTransformer.createProcess(amltISR, inchronComponent) |
| |
| amltProcess_inchronProcessMap.put(amltISR, inchronProcess) |
| |
| inchronScheduler.schedulables.add(inchronProcess) |
| ] |
| } |
| } |
| ] |
| |
| amltProcess_inchronProcessMap.forEach [ amltProcess, inchronProcess | |
| |
| amltProcess?.callGraph?.graphEntries?.forEach [ amltGraphEntry | |
| graphEntryBaseTransformer.transformGraphEntryBase(amltGraphEntry, amltProcess, |
| amltProcess_inchronProcessMap) |
| ] |
| |
| amltProcess?.stimuli?.forEach [ amltStimuli | |
| val inchronActivationConnection = cacheModel.amltStimuli_inchronActivationConnectionMap.get( |
| amltStimuli.name) |
| |
| var inchronActivateProcess = inchronModelFactory.createActivateProcess |
| |
| inchronActivateProcess.target = amltProcess_inchronProcessMap.get(amltProcess) |
| |
| inchronActivationConnection?.activations?.add(inchronActivateProcess) |
| ] |
| |
| ] |
| } |
| |
| } |