blob: c64cea0544de1fc2cc53bda5d3d3186d53a349d1 [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.Process
import java.util.Map
import org.eclipse.app4mc.amalthea.model.CallSequence
import org.eclipse.app4mc.amalthea.model.GraphEntryBase
import org.eclipse.app4mc.amalthea.model.InterProcessStimulus
import org.eclipse.app4mc.amalthea.model.InterProcessTrigger
import org.eclipse.app4mc.amalthea.model.ModeSwitch
import org.eclipse.app4mc.amalthea.model.ProbabilitySwitch
import org.eclipse.app4mc.amalthea.model.SchedulePoint
import org.eclipse.app4mc.amalthea.model.TaskRunnableCall
import templates.AbstractAmaltheaInchronTransformer
import templates.utils.AmltCacheModel
import com.google.inject.Singleton
@Singleton
class GraphEntryBaseTransformer extends AbstractAmaltheaInchronTransformer {
var AmltCacheModel cacheModel
@Inject RunnableTransformer runnableTransformer
@Inject ModeSwitchTransformer modeSwitchTransformer
def create inchronModelFactory.createFunction createFunction(java.lang.Process amltProcess, Runnable amltRunnable) {
cacheModel = customObjsStore.getInstance(AmltCacheModel)
}
def com.inchron.realtime.root.model.GraphEntryBase transformGraphEntryBase(GraphEntryBase amltGraphEntry, org.eclipse.app4mc.amalthea.model.Process amltTask,
Map<org.eclipse.app4mc.amalthea.model.Process, Process> amltProcess_inchronProcessMap) {
val Process inchronProcess = amltProcess_inchronProcessMap.get(amltTask)
cacheModel = customObjsStore.getInstance(AmltCacheModel)
if (amltGraphEntry instanceof CallSequence) {
var inchronCallSequence=createCallSequence( amltGraphEntry, amltTask, inchronProcess, amltProcess_inchronProcessMap)
return (inchronCallSequence)
} else if (amltGraphEntry instanceof ModeSwitch) {
var inchronModeSwitch=modeSwitchTransformer.createModeSwitch(amltGraphEntry,amltTask, amltProcess_inchronProcessMap)
return (inchronModeSwitch)
} else if (amltGraphEntry instanceof ProbabilitySwitch) {
return inchronModelFactory.createProbabilitySwitch
}
return null
}
protected def create inchronModelFactory.createCallSequence createCallSequence( CallSequence amltGraphEntry, org.eclipse.app4mc.amalthea.model.Process amltTask, Process inchronProcess, Map<org.eclipse.app4mc.amalthea.model.Process, Process> amltProcess_inchronProcessMap) {
it.name = "CS"
amltGraphEntry.calls.forEach [ amltCallSequenceItem |
if (amltCallSequenceItem instanceof TaskRunnableCall) {
var amltRunnable = amltCallSequenceItem.runnable
var inchronComponent = cacheModel.getInchronComponent(amltTask)
var inchronFunction = runnableTransformer.createFunction(inchronComponent, amltTask, amltRunnable)
var inchronFunctionCall = inchronModelFactory.createFunctionCall
inchronFunctionCall.function = inchronFunction
inchronFunctionCall.name = "call_" + inchronFunction.name
it.calls.add(inchronFunctionCall)
} else if (amltCallSequenceItem instanceof InterProcessTrigger) {
var inchronActivationItem = inchronModelFactory.createActivationItem
inchronActivationItem.name = "ActivationItem"
it.calls.add(inchronActivationItem)
val inchronActivationConnection = createActivationConnection()
inchronActivationConnection.name = inchronProcess.name + "_" + amltCallSequenceItem.stimulus.name +
"_Connection"
inchronActivationItem.connection = inchronActivationConnection
getInchronRoot().connections.add(inchronActivationConnection)
(amltCallSequenceItem.stimulus as InterProcessStimulus).affectedProcesses.forEach [ amltRefProcess |
{
var inchronActivateProcess = inchronModelFactory.createActivateProcess
inchronActivateProcess.target = amltProcess_inchronProcessMap.get(amltRefProcess)
inchronActivationConnection.activations.add(inchronActivateProcess)
}
]
// in the call sequence of the process, create ActivateProcess
// create ActivationItem -> ActivationConnection -> ActivationAction (ActivateProcess)
// In Amalthea -> It is handled with InterProcessStimulus being refered by InterProcessTrigger -> Stimulus is referred inside a Task
} else if (amltCallSequenceItem instanceof SchedulePoint) {
}
]
}
def create inchronModelFactory.createActivationConnection createActivationConnection() {
}
}