| /** |
| * Copyright (c) 2020-2021 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.slg.linux.generators; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| import java.util.Properties; |
| |
| import org.eclipse.app4mc.amalthea.model.PeriodicStimulus; |
| import org.eclipse.app4mc.amalthea.model.Stimulus; |
| import org.eclipse.app4mc.transformation.util.OutputBuffer; |
| |
| public class LinuxStimulusTranslationUnit extends LinuxSyntheticTranslationUnit { |
| |
| private List<Stimulus> stimuli = new ArrayList<>(); |
| private Properties properties; |
| |
| public LinuxStimulusTranslationUnit(final OutputBuffer outputBuffer, final Properties properties, |
| final List<Stimulus> stimuli) { |
| super(outputBuffer); |
| this.properties = properties; |
| |
| for (Stimulus stimulus : stimuli) { |
| if ((stimulus instanceof PeriodicStimulus)) { |
| this.stimuli.add(stimulus); |
| } |
| } |
| |
| this.genFiles(); |
| } |
| |
| @Override |
| public String getBasePath() { |
| return "Executable"; |
| } |
| |
| @Override |
| public String getModuleName() { |
| return "main"; |
| } |
| |
| public void genFiles() { |
| Stimulus lastStimulus = stimuli.isEmpty() ? null : stimuli.get(stimuli.size() - 1); |
| boolean enableInstrumentation = Boolean.parseBoolean(properties.getProperty("enableInstrumentation")); |
| |
| srcAppend(LinuxStimulusGenerator.toSrc(stimuli, lastStimulus, enableInstrumentation)); |
| } |
| |
| } |