Commit 5e2baecf authored by Valérie Maquil's avatar Valérie Maquil
Browse files

adaptations made for new versions of TULIP-CPS

parent 61f80da1
......@@ -31,8 +31,11 @@ bootstrapping.root = light_scenario.xml
# Properties for the equation system
scriptEngine.executable = C:/Octave/Octave-3.8.2/bin/octave.exe
scriptEngine.workingDir = model
#scriptEngine.executable = C:/Octave/Octave-3.8.2/bin/octave.exe
#scriptEngine.workingDir = model
executor.class=lu.list.itis.dkd.tui.cps.system.executor.JavascriptExecutor
variable.class=lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable
equation.system = light_scenario.xml
scenario.description = light_scenario.xml
......
......@@ -72,9 +72,10 @@ public class Scenario {
* description document loaded.
*/
public Scenario(String file) throws BuildException {
properties = PropertiesFetcher.fetchProperties(file);
try {
equationSystemBuilder = new EquationSystemBuilder();
equationSystemBuilder.parseEquationFile(new File(PropertiesFetcher.fetchProperties(file).getProperty("equation.system"))); //$NON-NLS-1$
equationSystemBuilder = new EquationSystemBuilder(properties);
equationSystemBuilder.parseEquationFile(new File(properties.getProperty("equation.system"))); //$NON-NLS-1$
} catch (final EquationSystemException exception) {
throw new BuildException("The equation system for this scenario could not be built!", exception); //$NON-NLS-1$
}
......@@ -103,7 +104,7 @@ public class Scenario {
try {
equationSystemBuilder = new EquationSystemBuilder();
equationSystemBuilder = new EquationSystemBuilder(properties);
equationSystemBuilder.parseEquationFile(new File(properties.getProperty("equation.system"))); //$NON-NLS-1$
} catch (final EquationSystemException exception) {
throw new BuildException("The equation system for this scenario could not be built!", exception); //$NON-NLS-1$
......
......@@ -96,10 +96,12 @@ public class Scene extends Content {
final String triggerCondition = element.getChildText(Externalization.TRIGGER_CONDITION_NODE);
for (final String _name : Splitter.on(Externalization.SPACE).trimResults().omitEmptyStrings().split(triggerCondition)) {
// System.out.println(_name);
final Variable variable = Scenario.retrieveVariableByName(_name);
if (null != variable) {
variables.add(variable);
}
}
......@@ -108,7 +110,10 @@ public class Scene extends Content {
variables.add(triggerVariable);
}
trigger = new Equation(new Mapping(variables, triggerVariable), triggerCondition);
final LinkedHashSet<Variable> triggerVariables = new LinkedHashSet<Variable>();
// trigger = new Equation(new Mapping(variables, triggerVariable), triggerCondition);
triggerVariables.add(triggerVariable);
trigger = new Equation(new Mapping(variables, triggerVariables), triggerCondition);
try {
final Element imageNode = element.getChild(Externalization.IMAGE_ELEMENT);
......
......@@ -23,6 +23,8 @@ package lu.list.itis.dkd.tui.scenario;
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import lu.list.itis.dkd.tui.TangibleContentManager;
import lu.list.itis.dkd.tui.content.Content;
import lu.list.itis.dkd.tui.cps.system.executor.Executor;
import lu.list.itis.dkd.tui.cps.system.executor.JavascriptExecutor;
import lu.list.itis.dkd.tui.event.ContentEvent;
import java.util.ArrayList;
......@@ -30,9 +32,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
/**
* @author Eric Tobias [eric.tobias@list.lu]
* @since 1.0
......@@ -42,11 +41,13 @@ import javax.script.ScriptEngineManager;
public class StageManager extends TangibleContentManager {
private static final StageManager INSTANCE = new StageManager();
private static Map<String, Scene> scenes;
private static ScriptEngine scriptEngine;
// private static ScriptEngine scriptEngine;
private static Executor scriptEngine;
ArrayList<Content> drawableContents = new ArrayList<>();
private StageManager() {
scriptEngine = new ScriptEngineManager().getEngineByName("js"); //$NON-NLS-1$
scriptEngine = new JavascriptExecutor();
// scriptEngine = new ScriptEngineManager().getEngineByName("js"); //$NON-NLS-1$
}
/**
......@@ -63,7 +64,8 @@ public class StageManager extends TangibleContentManager {
*/
public static void setScenes(Map<String, Scene> _scenes) {
scenes = _scenes;
scenes.values().forEach(scene -> scene.getTrigger().setScriptEngine(scriptEngine));
// scenes.values().forEach(scene -> scene.getTrigger().setScriptEngine(scriptEngine));
scenes.values().forEach(scene -> scene.getTrigger().setExecutor(scriptEngine));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment