| /** |
| * ******************************************************************************* |
| * 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.Component |
| import org.eclipse.app4mc.amalthea.model.Process |
| import org.eclipse.app4mc.amalthea.model.Runnable |
| import org.eclipse.app4mc.amalthea.model.RunnableCall |
| import org.eclipse.app4mc.amalthea.model.Ticks |
| import templates.AbstractAmaltheaInchronTransformer |
| import templates.m2m.sw.runnableItem.RunnableCallTransformer |
| import templates.m2m.sw.runnableItem.TicksTransformer |
| import templates.utils.AmltCacheModel |
| |
| class RunnableTransformer extends AbstractAmaltheaInchronTransformer { |
| |
| var AmltCacheModel cacheModel |
| |
| @Inject RunnableCallTransformer runnableCallTransformer |
| |
| @Inject TicksTransformer ticksTransformer |
| |
| def create inchronModelFactory.createFunction createFunction(Component inchronComponent, Process amltTask, |
| Runnable amltRunnable) { |
| |
| cacheModel = customObjsStore.getInstance(AmltCacheModel) |
| |
| inchronComponent.functions.add(it) |
| |
| it.name = amltRunnable.name |
| |
| val inchronCallGraph = inchronModelFactory.createCallGraph |
| |
| it.callGraph = inchronCallGraph |
| |
| val inchronCallSequence = inchronModelFactory.createCallSequence |
| |
| inchronCallSequence.name = "CS" |
| |
| inchronCallGraph.graphEntries.add(inchronCallSequence) |
| |
| amltRunnable?.runnableItems?.forEach [ amltRunnableItem | |
| if (amltRunnableItem instanceof RunnableCall) { |
| |
| var inchronFunctionCall = runnableCallTransformer.createFunctionCall(inchronComponent, amltTask, |
| amltRunnableItem) |
| |
| inchronCallSequence.calls.add(inchronFunctionCall) |
| |
| } else if (amltRunnableItem instanceof Ticks) { |
| var inchronResourceConsumption = ticksTransformer.createResourceConsumption(amltTask, amltRunnableItem) |
| inchronCallSequence.calls.add(inchronResourceConsumption) |
| |
| } |
| ] |
| } |
| } |