| /** |
| * ******************************************************************************* |
| * Copyright (c) 2019-2020 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 org.eclipse.app4mc.amlt2systemc.m2t.transformers.sw |
| |
| import org.eclipse.app4mc.amalthea.model.ModeSwitchDefault |
| import org.eclipse.app4mc.amalthea.model.ModeSwitchEntry |
| |
| /** Target code example |
| * |
| ModeSwitchEntry caseA("case A"); |
| caseA.addCondition(modelabel1, lita); |
| caseA.addActivityGraphItem<ModeLabelAccess>({modelabel1, litb}); |
| caseA.addActivityGraphItem<RunnableCall>({ra}); |
| * |
| ModeConjunction conj_caseDandD;// = caseDandD.createConjunction(); |
| conj_caseDandD.addCondition(modelabel1, litd); |
| conj_caseDandD.addCondition(modelabel2, litd) |
| * |
| usage in ModeSwitch: |
| modeSwitch.addEntry(caseA); OR modeSwitch.setDefaultEntry(caseA); |
| |
| */ |
| |
| class ModeSwitchEntryTransformer extends IActivityGraphItemContainerTransformer { |
| |
| static var modeDefaultCnt = 0; |
| |
| private static def getName(ModeSwitchEntry modeSwitchEntry){ |
| return modeSwitchEntry.name; |
| } |
| |
| private static def getName(ModeSwitchDefault modeSwitchDefault){ |
| return "modeSwitchDefault" + modeDefaultCnt |
| } |
| |
| def void transform(ModeSwitchEntry modeSwitchEntry, ActivityGraphBuffer content) { |
| val name = getName(modeSwitchEntry) |
| content.addBody("ModeSwitchEntry " + name + "(\"" + name + "\");\n") |
| val activityGraphContents = transformItems( modeSwitchEntry, name, content.module, content.parentIsPointer) |
| content.getIncludes().addAll(activityGraphContents.getIncludes()) |
| content.getSource().addAll(activityGraphContents.getSource()) |
| content.addBody(content.instanceName + ".addEntry(" + name + ");") |
| } |
| |
| def void transform(ModeSwitchDefault modeSwitchDefault, ActivityGraphBuffer content) { |
| val name = getName(modeSwitchDefault) |
| content.addBody("ModeSwitchEntry " + name + "(\"" + name + "\");\n") |
| val activityGraphContents = transformItems(modeSwitchDefault, name, content.module, content.parentIsPointer) |
| content.getIncludes().addAll(activityGraphContents.getIncludes()) |
| content.getSource().addAll(activityGraphContents.getSource()) |
| content.addBody(content.instanceName + ".setDefaultEntry(" + name + ");") |
| modeDefaultCnt++; |
| } |
| } |