blob: c623c8a8cf2b366812f1d8681da0afa497fd74f9 [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2018-2019 Robert Bosch GmbH.
*
* 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.google.inject.Singleton
import com.inchron.realtime.root.model.ModeSwitch
import java.util.ArrayList
import java.util.Map
import org.eclipse.app4mc.amalthea.model.CallGraph
import org.eclipse.app4mc.amalthea.model.Process
import templates.AbstractAmaltheaInchronTransformer
@Singleton
class CallGraphTransformer extends AbstractAmaltheaInchronTransformer{
@Inject GraphEntryBaseTransformer graphEntryBaseTransformer
def void transformCallGraph(CallGraph amltGraph, Process amltTask,
Map<Process, com.inchron.realtime.root.model.Process> amltProcess_inchronProcessMap) {
val com.inchron.realtime.root.model.Process inchronProcess = amltProcess_inchronProcessMap.get(amltTask)
val inchronCallGraph = inchronModelFactory.createCallGraph
inchronProcess.callGraph = inchronCallGraph
amltGraph?.graphEntries?.forEach[amltGraphEntry|{
var inchronGraphEntryBase= graphEntryBaseTransformer.transformGraphEntryBase(amltGraphEntry, amltTask,
amltProcess_inchronProcessMap)
/*
* Based on the requirement from Inchron to use the latest Mode values:
* -- it is required to create a "Dummy CallSequence" and associate ModeConditionEvaluation of each ModeSwitchEntry object
*/
if(inchronGraphEntryBase instanceof ModeSwitch){
createDummyCallSequenceWithModeSwitchEvaluation(inchronGraphEntryBase, inchronCallGraph)
}
//Adding ModeSwitch
inchronCallGraph.graphEntries.add(inchronGraphEntryBase)
}]
}
public def void createDummyCallSequenceWithModeSwitchEvaluation(ModeSwitch inchronModeSwitch, com.inchron.realtime.root.model.CallGraph inchronCallGraph) {
var dummyCallSequence=inchronModelFactory.createCallSequence
dummyCallSequence.name = "CallSequence_For_ModeConditionEvaluation"
val dummyCallSequenceItems=new ArrayList
inchronModeSwitch.entries.forEach[inchronModeSwitchEntry|
val inchronModeCondition=inchronModeSwitchEntry.condition
var inchronModeConditionEvaluation=inchronModelFactory.createModeConditionEvaluation
inchronModeConditionEvaluation.condition=inchronModeCondition
dummyCallSequenceItems.add(inchronModeConditionEvaluation)
]
if(dummyCallSequenceItems.size>0){
dummyCallSequence.calls.addAll(dummyCallSequenceItems)
//Adding DummyCallSequence containing ModeConditionEvaluation
inchronCallGraph.graphEntries.add(dummyCallSequence);
}
}
}