| /** |
| * ******************************************************************************* |
| * 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.google.inject.Singleton |
| 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.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.m2m.stimuli.StimuliTransformer |
| import templates.m2m.utils.CounterUtils |
| import templates.utils.AmltCacheModel |
| |
| @Singleton |
| class GraphEntryBaseTransformer extends AbstractAmaltheaInchronTransformer { |
| |
| var AmltCacheModel cacheModel |
| |
| @Inject RunnableTransformer runnableTransformer |
| |
| @Inject ModeSwitchTransformer modeSwitchTransformer |
| |
| @Inject StimuliTransformer stimuliTransformer |
| |
| 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 |
| |
| // offset & prescaler |
| if (amltCallSequenceItem.counter !== null){ |
| inchronFunctionCall.period = CounterUtils.getPrescalerAsInteger(amltCallSequenceItem.counter) |
| inchronFunctionCall.offset = CounterUtils.getOffsetAsInteger(amltCallSequenceItem.counter) |
| } |
| |
| it.calls.add(inchronFunctionCall) |
| |
| } else if (amltCallSequenceItem instanceof InterProcessTrigger) { |
| |
| var inchronActivationItem = inchronModelFactory.createActivationItem |
| |
| inchronActivationItem.name = "ActivationItem" |
| |
| if (amltCallSequenceItem.counter !== null){ |
| inchronActivationItem.period = CounterUtils.getPrescalerAsInteger(amltCallSequenceItem.counter) |
| inchronActivationItem.offset = CounterUtils.getOffsetAsInteger(amltCallSequenceItem.counter) |
| } |
| |
| |
| it.calls.add(inchronActivationItem) |
| |
| val inchronActivationConnection = stimuliTransformer.createActivationConnection((amltCallSequenceItem as InterProcessTrigger).stimulus) |
| |
| inchronActivationItem.connection = inchronActivationConnection |
| |
| |
| // 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) { |
| } |
| |
| ] |
| } |
| |
| } |