| /** |
| * ******************************************************************************* |
| * 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 |
| |
| class GraphEntryBaseTransformer extends AbstractAmaltheaInchronTransformer { |
| |
| var AmltCacheModel cacheModel |
| |
| @Inject RunnableTransformer runnableTransformer |
| |
| def create inchronModelFactory.createFunction createFunction(java.lang.Process amltProcess, Runnable amltRunnable) { |
| |
| cacheModel = customObjsStore.getInstance(AmltCacheModel) |
| |
| } |
| |
| def void 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) |
| |
| val inchronCallGraph = inchronModelFactory.createCallGraph |
| |
| inchronProcess.callGraph = inchronCallGraph |
| |
| if (amltGraphEntry instanceof CallSequence) { |
| |
| val inchronCallSequence = inchronModelFactory.createCallSequence |
| |
| inchronCallSequence.name = "CS" |
| |
| inchronCallGraph.graphEntries.add(inchronCallSequence) |
| |
| 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 |
| inchronCallSequence.calls.add(inchronFunctionCall) |
| |
| } else if (amltCallSequenceItem instanceof InterProcessTrigger) { |
| |
| var inchronActivationItem = inchronModelFactory.createActivationItem |
| |
| inchronActivationItem.name = "ActivationItem" |
| inchronCallSequence.calls.add(inchronActivationItem) |
| |
| val inchronActivationConnection = createActivationConnection() |
| |
| inchronActivationConnection.name = inchronProcess.name + "_" + amltCallSequenceItem.stimulus.name + |
| "_Connection" |
| inchronActivationItem.connection = inchronActivationConnection |
| |
| cacheModel.inchronModel.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) { |
| } |
| |
| ] |
| } else if (amltGraphEntry instanceof ModeSwitch) { |
| |
| var amltDefaultEntry = amltGraphEntry.defaultEntry |
| |
| if (amltDefaultEntry !== null) { |
| amltDefaultEntry?.items.forEach [ amltEntryItem | |
| transformGraphEntryBase(amltEntryItem as GraphEntryBase, amltTask, amltProcess_inchronProcessMap) |
| ] |
| } |
| |
| amltGraphEntry.entries.forEach [ amltEntry | |
| { |
| |
| amltEntry.items.forEach [ amltEntryItem | |
| { |
| transformGraphEntryBase(amltEntryItem as GraphEntryBase, amltTask, |
| amltProcess_inchronProcessMap) |
| |
| } |
| ] |
| |
| } |
| ] |
| |
| } else if (amltGraphEntry instanceof ProbabilitySwitch) { |
| // TODO: handle it later |
| } |
| } |
| |
| def create inchronModelFactory.createActivationConnection createActivationConnection() { |
| } |
| } |