blob: 5aaae60d84606cac912db5f7ec662bac49533c80 [file] [log] [blame]
Zakir Meerbbbbdfe2019-02-21 14:22:47 +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 */
15package templates.m2m.sw
16
17import com.google.inject.Inject
18import com.inchron.realtime.root.model.Component
19import java.util.Map
20import org.eclipse.app4mc.amalthea.model.GraphEntryBase
21import org.eclipse.app4mc.amalthea.model.ModeSwitch
22import org.eclipse.app4mc.amalthea.model.Process
23import org.eclipse.app4mc.amalthea.model.RunnableModeSwitch
24import templates.utils.AmltCacheModel
25
26class ModeSwitchTransformer extends GraphEntryBaseTransformer {
27
28 @Inject RunnableItemTransformer runnableItemTransformer
29 @Inject ModeValueDisjunctionTransformer modeValueDisjunctionTransformer
30
31 var AmltCacheModel cacheModel
32
33 public def create inchronModelFactory.createModeSwitch createModeSwitch(Component inchronComponent, Process amltTask,
34 RunnableModeSwitch amltRunnableModeSwitch){
35
36 cacheModel = customObjsStore.getInstance(AmltCacheModel)
37
38 val inchronCallSequence=inchronModelFactory.createCallSequence
39
40 amltRunnableModeSwitch?.defaultEntry?.items?.forEach[amltRunnableModeSwitchRunnableItem|
41
42 inchronCallSequence.calls.addAll(runnableItemTransformer.transformRunnableItem(inchronComponent,amltTask,amltRunnableModeSwitchRunnableItem))
43 ]
44
45 }
46
47 public def create inchronModelFactory.createModeSwitch createModeSwitch(ModeSwitch amltGraphEntry,Process amltTask,
48 Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap){
49
50 cacheModel = customObjsStore.getInstance(AmltCacheModel)
51
52 var amltDefaultEntry = amltGraphEntry.defaultEntry
53
54 if (amltDefaultEntry !== null) {
55 it.defaultEntry=inchronModelFactory.createModeSwitchDefault
56
57 amltDefaultEntry?.items.forEach [ amltEntryItem |
58 var inchronGraphEntryBase=transformGraphEntryBase(amltEntryItem as GraphEntryBase, amltTask, amltProcess_inchronProcessMap)
59 it.defaultEntry.graphEntries.add(inchronGraphEntryBase)
60 ]
61 }
62
63 amltGraphEntry?.entries?.forEach [ amltEntry |
64 {
65 val inchronModeSwitchEntry=inchronModelFactory.createModeSwitchEntry
66
67 it.entries.add(inchronModeSwitchEntry)
68
69 amltEntry?.items?.forEach [ amltEntryItem |
70 {
71 var inchronGraphEntryBase=transformGraphEntryBase(amltEntryItem as GraphEntryBase, amltTask,
72 amltProcess_inchronProcessMap)
73
74 inchronModeSwitchEntry.graphEntries.add(inchronGraphEntryBase)
75
76 }
77
78 ]
79
80 var amltCondition=amltEntry.condition
81 if(amltCondition!==null){
82 var inchronConditon=modeValueDisjunctionTransformer.createModeCondition(amltCondition,amltTask,amltProcess_inchronProcessMap)
83
84 inchronModeSwitchEntry.condition = inchronConditon
85
86 if(inchronConditon.eContainer===null){
87 //Adding ModeCondition to the Inchron Model
88 cacheModel.inchronModel.globalModeConditions.add(inchronConditon)
89 }
90 }
91
92 }
93 ]
94
95
96 }
97
98
99}