Harald Mackamul | ca6c8b6 | 2019-02-14 16:41:16 +0100 | [diff] [blame] | 1 | /** |
| 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 Meer | 5724609 | 2019-02-12 17:13:44 +0100 | [diff] [blame] | 16 | package templates.m2m.sw |
| 17 | |
| 18 | import com.google.inject.Inject |
| 19 | import com.inchron.realtime.root.model.Model |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 20 | import java.util.HashMap |
| 21 | import java.util.Map |
Zakir Meer | 80da495 | 2019-02-13 10:26:09 +0100 | [diff] [blame] | 22 | import org.eclipse.app4mc.amalthea.model.InterruptController |
Zakir Meer | 695e292 | 2019-02-13 13:10:06 +0100 | [diff] [blame] | 23 | import org.eclipse.app4mc.amalthea.model.OperatingSystem |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 24 | import org.eclipse.app4mc.amalthea.model.Process |
Zakir Meer | 3c1a57c | 2019-02-13 17:03:03 +0100 | [diff] [blame] | 25 | import org.eclipse.app4mc.amalthea.model.SWModel |
| 26 | import org.eclipse.app4mc.amalthea.model.TaskScheduler |
| 27 | import templates.AbstractAmaltheaInchronTransformer |
| 28 | import templates.utils.AmltCacheModel |
Zakir Meer | 5724609 | 2019-02-12 17:13:44 +0100 | [diff] [blame] | 29 | |
| 30 | class SWTransformer extends AbstractAmaltheaInchronTransformer { |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 31 | |
Zakir Meer | 5724609 | 2019-02-12 17:13:44 +0100 | [diff] [blame] | 32 | var AmltCacheModel cacheModel |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 33 | |
Zakir Meer | 5724609 | 2019-02-12 17:13:44 +0100 | [diff] [blame] | 34 | @Inject TaskTransformer taskTransformer |
Zakir Meer | 80da495 | 2019-02-13 10:26:09 +0100 | [diff] [blame] | 35 | @Inject ISRTransformer isrTransformer |
Zakir Meer | 3c1a57c | 2019-02-13 17:03:03 +0100 | [diff] [blame] | 36 | @Inject GraphEntryBaseTransformer graphEntryBaseTransformer |
Zakir Meer | 101a61f | 2019-02-13 18:22:49 +0100 | [diff] [blame] | 37 | @Inject RunnableTransformer runnableTransformer |
Zakir Meer | bbbbdfe | 2019-02-21 14:22:47 +0100 | [diff] [blame^] | 38 | @Inject CallGraphTransformer callGraphTransformer |
| 39 | @Inject ModeTransformer modeTransformer |
Zakir Meer | 101a61f | 2019-02-13 18:22:49 +0100 | [diff] [blame] | 40 | |
Zakir Meer | bbbbdfe | 2019-02-21 14:22:47 +0100 | [diff] [blame^] | 41 | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 42 | val Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap = new HashMap |
Zakir Meer | 695e292 | 2019-02-13 13:10:06 +0100 | [diff] [blame] | 43 | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 44 | def transformSWModel(SWModel amltSwModel, Model inchronModel) { |
Zakir Meer | 3c1a57c | 2019-02-13 17:03:03 +0100 | [diff] [blame] | 45 | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 46 | this.inchronModel = inchronModel |
| 47 | |
| 48 | cacheModel = customObjsStore.getInstance(AmltCacheModel) |
Zakir Meer | bbbbdfe | 2019-02-21 14:22:47 +0100 | [diff] [blame^] | 49 | |
| 50 | amltSwModel?.modes?.forEach[amltMode|{ |
| 51 | inchronModel.globalModeGroups.add(modeTransformer.createModeGroup(amltMode)) |
| 52 | }] |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 53 | |
| 54 | val inchronScheduler_amltSchedulerMap = cacheModel.getInchronScheduler_amltSchedulerMap() |
| 55 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 56 | inchronScheduler_amltSchedulerMap.forEach [ inchronScheduler, amltScheduler | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 57 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 58 | if (amltScheduler !== null) { |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 59 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 60 | var amltOS = amltScheduler.eContainer as OperatingSystem |
| 61 | val inchronComponent = cacheModel.getInchronComponent(amltOS.name + "_SWC") |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 62 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 63 | if (amltScheduler instanceof TaskScheduler) { |
| 64 | amltScheduler.taskAllocations.forEach [ amltTaskAllocation | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 65 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 66 | var amltTask = amltTaskAllocation.task |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 67 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 68 | val inchronProcess = taskTransformer.createProcess(amltTask, inchronComponent) |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 69 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 70 | amltProcess_inchronProcessMap.put(amltTask, inchronProcess) |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 71 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 72 | amltTaskAllocation.affinity.forEach [ amltPU | |
| 73 | { |
| 74 | var inchronCpuCore = cacheModel.getInchronCpuCore(amltPU.name) |
| 75 | if (inchronCpuCore !== null) { |
| 76 | inchronProcess.cpuCores.add(inchronCpuCore) |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 77 | } |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 78 | } |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 79 | ] |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 80 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 81 | inchronScheduler.schedulables.add(inchronProcess) |
| 82 | ] |
| 83 | } else if (amltScheduler instanceof InterruptController) { |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 84 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 85 | amltScheduler.isrAllocations.forEach [ amltISRAllocation | |
| 86 | var amltISR = amltISRAllocation.isr |
| 87 | val inchronProcess = isrTransformer.createProcess(amltISR, inchronComponent) |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 88 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 89 | amltProcess_inchronProcessMap.put(amltISR, inchronProcess) |
| 90 | |
| 91 | inchronScheduler.schedulables.add(inchronProcess) |
| 92 | ] |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 93 | } |
| 94 | } |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 95 | ] |
| 96 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 97 | amltProcess_inchronProcessMap.forEach [ amltProcess, inchronProcess | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 98 | |
Zakir Meer | bbbbdfe | 2019-02-21 14:22:47 +0100 | [diff] [blame^] | 99 | |
| 100 | |
| 101 | if(amltProcess.callGraph!==null) |
| 102 | { |
| 103 | callGraphTransformer.transformCallGraph(amltProcess.callGraph,amltProcess,amltProcess_inchronProcessMap) |
| 104 | |
| 105 | } |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 110 | |
| 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 Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 120 | ] |
| 121 | |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 122 | ] |
Zakir Meer | 5724609 | 2019-02-12 17:13:44 +0100 | [diff] [blame] | 123 | } |
Harald Mackamul | f5d17b6 | 2019-02-14 14:57:58 +0100 | [diff] [blame] | 124 | |
Harald Mackamul | 505789c | 2019-02-14 14:28:17 +0100 | [diff] [blame] | 125 | } |