| /** | |
| * ******************************************************************************* | |
| * 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 com.google.inject.Inject | |
| import org.eclipse.app4mc.amalthea.model.ModeSwitch | |
| import org.eclipse.app4mc.amlt2systemc.m2t.transformers.sw.IActivityGraphItemContainerTransformer.ActivityGraphBuffer | |
| class ModeSwitchTransformer { | |
| @Inject ModeSwitchEntryTransformer modeSwitchEntryTransformer | |
| static int cnt =0; | |
| static def getName(){ | |
| return "modeSwitch_" + cnt; | |
| } | |
| def void transform(ModeSwitch modeSwitch, ActivityGraphBuffer parentContent) { | |
| val name = getName() | |
| cnt++; | |
| parentContent.addBody("ModeSwitch " + name + ";") | |
| val modeSwitchContent = new ActivityGraphBuffer(name, parentContent.module, false) | |
| //run through entries | |
| modeSwitch.entries.forEach[entry | | |
| modeSwitchEntryTransformer.transform(entry, modeSwitchContent) | |
| ] | |
| if (modeSwitch.defaultEntry !== null){ | |
| modeSwitchEntryTransformer.transform(modeSwitch.defaultEntry, modeSwitchContent) | |
| } | |
| parentContent.getIncludes().addAll(modeSwitchContent.getIncludes()); | |
| parentContent.getSource().addAll(modeSwitchContent.getSource()); | |
| parentContent.addAsActivityGraphItem("<ModeSwitch>(" + name + ")") | |
| } | |
| } | |