blob: c68119fef43ba0ca348ed023a7027eb5e789bbf2 [file] [log] [blame]
Harald Mackamulca6c8b62019-02-14 16:41:16 +01001/**
2 * *******************************************************************************
3 * Copyright (c) 2019 Robert Bosch GmbH and others.
4 *
5 * This program and the accompanying materials are made
6 * available under the terms of the Eclipse Public License 2.0
7 * which is available at https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * Robert Bosch GmbH - initial API and implementation
13 * *******************************************************************************
14 */
15
Zakir Meer57246092019-02-12 17:13:44 +010016package templates.m2m.sw
17
18import com.google.inject.Inject
19import com.inchron.realtime.root.model.Model
Harald Mackamul505789c2019-02-14 14:28:17 +010020import java.util.HashMap
21import java.util.Map
Zakir Meer80da4952019-02-13 10:26:09 +010022import org.eclipse.app4mc.amalthea.model.InterruptController
Zakir Meer695e2922019-02-13 13:10:06 +010023import org.eclipse.app4mc.amalthea.model.OperatingSystem
Harald Mackamul505789c2019-02-14 14:28:17 +010024import org.eclipse.app4mc.amalthea.model.Process
Zakir Meer3c1a57c2019-02-13 17:03:03 +010025import org.eclipse.app4mc.amalthea.model.SWModel
26import org.eclipse.app4mc.amalthea.model.TaskScheduler
27import templates.AbstractAmaltheaInchronTransformer
28import templates.utils.AmltCacheModel
Zakir Meer57246092019-02-12 17:13:44 +010029
30class SWTransformer extends AbstractAmaltheaInchronTransformer {
Harald Mackamul505789c2019-02-14 14:28:17 +010031
Zakir Meer57246092019-02-12 17:13:44 +010032 var AmltCacheModel cacheModel
Harald Mackamul505789c2019-02-14 14:28:17 +010033
Zakir Meer57246092019-02-12 17:13:44 +010034 @Inject TaskTransformer taskTransformer
Zakir Meer80da4952019-02-13 10:26:09 +010035 @Inject ISRTransformer isrTransformer
Zakir Meer3c1a57c2019-02-13 17:03:03 +010036 @Inject GraphEntryBaseTransformer graphEntryBaseTransformer
Zakir Meer101a61f2019-02-13 18:22:49 +010037 @Inject RunnableTransformer runnableTransformer
Zakir Meerbbbbdfe2019-02-21 14:22:47 +010038 @Inject CallGraphTransformer callGraphTransformer
39 @Inject ModeTransformer modeTransformer
Zakir Meer101a61f2019-02-13 18:22:49 +010040
Zakir Meerbbbbdfe2019-02-21 14:22:47 +010041
Harald Mackamul505789c2019-02-14 14:28:17 +010042 val Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap = new HashMap
Zakir Meer695e2922019-02-13 13:10:06 +010043
Harald Mackamul505789c2019-02-14 14:28:17 +010044 def transformSWModel(SWModel amltSwModel, Model inchronModel) {
Zakir Meer3c1a57c2019-02-13 17:03:03 +010045
Harald Mackamul505789c2019-02-14 14:28:17 +010046 this.inchronModel = inchronModel
47
48 cacheModel = customObjsStore.getInstance(AmltCacheModel)
Zakir Meerbbbbdfe2019-02-21 14:22:47 +010049
50 amltSwModel?.modes?.forEach[amltMode|{
51 inchronModel.globalModeGroups.add(modeTransformer.createModeGroup(amltMode))
52 }]
Harald Mackamul505789c2019-02-14 14:28:17 +010053
54 val inchronScheduler_amltSchedulerMap = cacheModel.getInchronScheduler_amltSchedulerMap()
55
Harald Mackamulf5d17b62019-02-14 14:57:58 +010056 inchronScheduler_amltSchedulerMap.forEach [ inchronScheduler, amltScheduler |
Harald Mackamul505789c2019-02-14 14:28:17 +010057
Harald Mackamulf5d17b62019-02-14 14:57:58 +010058 if (amltScheduler !== null) {
Harald Mackamul505789c2019-02-14 14:28:17 +010059
Harald Mackamulf5d17b62019-02-14 14:57:58 +010060 var amltOS = amltScheduler.eContainer as OperatingSystem
61 val inchronComponent = cacheModel.getInchronComponent(amltOS.name + "_SWC")
Harald Mackamul505789c2019-02-14 14:28:17 +010062
Harald Mackamulf5d17b62019-02-14 14:57:58 +010063 if (amltScheduler instanceof TaskScheduler) {
64 amltScheduler.taskAllocations.forEach [ amltTaskAllocation |
Harald Mackamul505789c2019-02-14 14:28:17 +010065
Harald Mackamulf5d17b62019-02-14 14:57:58 +010066 var amltTask = amltTaskAllocation.task
Harald Mackamul505789c2019-02-14 14:28:17 +010067
Harald Mackamulf5d17b62019-02-14 14:57:58 +010068 val inchronProcess = taskTransformer.createProcess(amltTask, inchronComponent)
Harald Mackamul505789c2019-02-14 14:28:17 +010069
Harald Mackamulf5d17b62019-02-14 14:57:58 +010070 amltProcess_inchronProcessMap.put(amltTask, inchronProcess)
Harald Mackamul505789c2019-02-14 14:28:17 +010071
Harald Mackamulf5d17b62019-02-14 14:57:58 +010072 amltTaskAllocation.affinity.forEach [ amltPU |
73 {
74 var inchronCpuCore = cacheModel.getInchronCpuCore(amltPU.name)
75 if (inchronCpuCore !== null) {
76 inchronProcess.cpuCores.add(inchronCpuCore)
Harald Mackamul505789c2019-02-14 14:28:17 +010077 }
Harald Mackamulf5d17b62019-02-14 14:57:58 +010078 }
Harald Mackamul505789c2019-02-14 14:28:17 +010079 ]
Harald Mackamul505789c2019-02-14 14:28:17 +010080
Harald Mackamulf5d17b62019-02-14 14:57:58 +010081 inchronScheduler.schedulables.add(inchronProcess)
82 ]
83 } else if (amltScheduler instanceof InterruptController) {
Harald Mackamul505789c2019-02-14 14:28:17 +010084
Harald Mackamulf5d17b62019-02-14 14:57:58 +010085 amltScheduler.isrAllocations.forEach [ amltISRAllocation |
86 var amltISR = amltISRAllocation.isr
87 val inchronProcess = isrTransformer.createProcess(amltISR, inchronComponent)
Harald Mackamul505789c2019-02-14 14:28:17 +010088
Harald Mackamulf5d17b62019-02-14 14:57:58 +010089 amltProcess_inchronProcessMap.put(amltISR, inchronProcess)
90
91 inchronScheduler.schedulables.add(inchronProcess)
92 ]
Harald Mackamul505789c2019-02-14 14:28:17 +010093 }
94 }
Harald Mackamul505789c2019-02-14 14:28:17 +010095 ]
96
Harald Mackamulf5d17b62019-02-14 14:57:58 +010097 amltProcess_inchronProcessMap.forEach [ amltProcess, inchronProcess |
Harald Mackamul505789c2019-02-14 14:28:17 +010098
Zakir Meerbbbbdfe2019-02-21 14:22:47 +010099
100
101 if(amltProcess.callGraph!==null)
102 {
103 callGraphTransformer.transformCallGraph(amltProcess.callGraph,amltProcess,amltProcess_inchronProcessMap)
104
105 }
106
107
108
109
Harald Mackamul505789c2019-02-14 14:28:17 +0100110
111 amltProcess?.stimuli?.forEach [ amltStimuli |
112 val inchronActivationConnection = cacheModel.amltStimuli_inchronActivationConnectionMap.get(
113 amltStimuli.name)
114
115 var inchronActivateProcess = inchronModelFactory.createActivateProcess
116
117 inchronActivateProcess.target = amltProcess_inchronProcessMap.get(amltProcess)
118
119 inchronActivationConnection?.activations?.add(inchronActivateProcess)
Harald Mackamul505789c2019-02-14 14:28:17 +0100120 ]
121
Harald Mackamulf5d17b62019-02-14 14:57:58 +0100122 ]
Zakir Meer57246092019-02-12 17:13:44 +0100123 }
Harald Mackamulf5d17b62019-02-14 14:57:58 +0100124
Harald Mackamul505789c2019-02-14 14:28:17 +0100125}