blob: c68119fef43ba0ca348ed023a7027eb5e789bbf2 [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2019 Robert Bosch GmbH and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
* *******************************************************************************
*/
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
@Inject CallGraphTransformer callGraphTransformer
@Inject ModeTransformer modeTransformer
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)
amltSwModel?.modes?.forEach[amltMode|{
inchronModel.globalModeGroups.add(modeTransformer.createModeGroup(amltMode))
}]
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 |
if(amltProcess.callGraph!==null)
{
callGraphTransformer.transformCallGraph(amltProcess.callGraph,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)
]
]
}
}