Commit b9e3561e authored by Eric Tobias's avatar Eric Tobias
Browse files

Minor changes and test scenario xml to test conditional coronas

parent 89b46722
......@@ -105,7 +105,7 @@
<rotateWithHandle>false</rotateWithHandle>
<centred>true</centred>
<text>Banana</text>
</corona>
</corona>
</coronas>
<name>Hair Dryer</name>
<definingShape></definingShape>
......
......@@ -30,15 +30,10 @@
<artifactId>tulip</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>lu.list.itis.dkd.tui</groupId>
<artifactId>tulip-cps</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -27,10 +27,10 @@ cursor.id.remapping.constant = 1024
adapter.class = lu.list.itis.dkd.tui.adapter.TuioAdapter
# The location and name of the root bootstrapping file.
bootstrapping.root = power_scenario.xml
bootstrapping.root = test_scenario.xml
# Properties for the equation system
scriptEngine.executable = C:/Octave/Octave-3.8.2/bin/octave.exe
scriptEngine.workingDir = model
equation.system = power_scenario.xml
scenario.description = power_scenario.xml
\ No newline at end of file
equation.system = test_scenario.xml
scenario.description = test_scenario.xml
\ No newline at end of file
......@@ -39,7 +39,6 @@ import com.google.common.base.Preconditions;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Class used to run a tangible scenario. It uses bootstrappers to initialize all the necessary
......@@ -53,8 +52,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class Scenario {
private Map<String, Scene> scenes;
private static ConcurrentHashMap<String, Variable> inputs;
private static ConcurrentHashMap<String, Variable> outputs;
private static Map<String, Variable> inputs;
private static Map<String, Variable> outputs;
private EquationSystemBuilder equationSystemBuilder;
private TangibleApplication tangibleApplication;
......@@ -71,7 +70,7 @@ public class Scenario {
*/
public Scenario() throws BuildException {
try {
equationSystemBuilder = new EquationSystemBuilder(PropertiesFetcher.fetchProperties());
equationSystemBuilder = new EquationSystemBuilder();
equationSystemBuilder.parseEquationFile(new File(PropertiesFetcher.fetchProperties().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$
......
......@@ -50,7 +50,7 @@ import javax.swing.ImageIcon;
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 1.0
* @version 1.0.1
* @version 1.0.2
*/
@NonNullByDefault
public class Scene extends Content {
......@@ -59,7 +59,7 @@ public class Scene extends Content {
/** All variables that will be needed to evaluate the trigger condition. */
private LinkedHashSet<Variable> variables = new LinkedHashSet<>();
/** Variable used to easily gather the output from the trigger equation. */
private BooleanVariable triggerVariable = new BooleanVariable("Trigger", "", false); //$NON-NLS-1$ //$NON-NLS-2$
private BooleanVariable triggerVariable = new BooleanVariable("Trigger", false); //$NON-NLS-1$
/** The image to show when painting. */
private ImageIcon scenery;
......@@ -90,7 +90,7 @@ public class Scene extends Content {
trigger = new Equation(new Mapping(variables, triggerVariable), triggerCondition);
try {
final Element imageNode = element.getChild(Externalization.IMAGE_NODE);
final Element imageNode = element.getChild(Externalization.IMAGE_ELEMENT);
if (null != imageNode) {
scenery = new ImageIcon(ImageIO.read(new File(imageNode.getText())));
}
......@@ -103,10 +103,22 @@ public class Scene extends Content {
}
}
/**
* Simple getter to retrieve the trigger.
*
* @return The equation that servers as a trigger for this scene.
*/
public Equation getTrigger() {
return trigger;
}
/**
* Method called to evaluate the stored trigger. Returns the result as a boolean.
*
* @return <code>true</code> if value held by the result variable of the stored trigger
* evaluates to true, <code>false</code> otherwise.
* @see Equation#evaluate()
*/
public boolean evaluateTrigger() {
trigger.evaluate();
return triggerVariable.getValue();
......
<?xml version="1.0" encoding="UTF-8"?>
<scenario>
<scenes>
<scene>
<name>Background</name>
<image>assets/Moses-Transports.jpg</image>
<triggerCondition>true</triggerCondition>
</scene>
</scenes>
<objects>
<object>
<type>ValueWidget</type>
<handles>
<handle>1</handle>
</handles>
<coronas>
<corona>
<type>Shadow</type>
<handle>1</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<shape>Circle</shape>
<drawPriority>0</drawPriority>
</corona>
<corona>
<type>TextBox</type>
<handle>1</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<drawPriority>1</drawPriority>
<lineWidth>100</lineWidth>
<font>Arial-20</font>
<initialTranslation>
<x>0</x>
<y>120</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<rotateWithHandle>false</rotateWithHandle>
<centred>true</centred>
<text>Banana</text>
</corona>
<corona>
<type>Gauge</type>
<handle>1</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<initialTranslation>
<x>-125</x>
<y>-125</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<drawPriority>2</drawPriority>
<width>250</width>
<height>250</height>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<scale>1</scale>
<title>Bicycle</title>
<unit>km</unit>
<rotateWithHandle>false</rotateWithHandle>
</corona>
</coronas>
<name>Bicycle</name>
<definingShape></definingShape>
<networkAdapter></networkAdapter>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<lowerStopAngle>0</lowerStopAngle>
<upperStopAngle>6.28318530718</upperStopAngle>
<stepSize>1</stepSize>
<variable>
<name>Bicycle</name>
<unit>km</unit>
<value>0</value>
</variable>
<modifyValueOnRotation>True</modifyValueOnRotation>
</object>
<object>
<type>ValueWidget</type>
<handles>
<handle>2</handle>
</handles>
<coronas>
<corona>
<type>Shadow</type>
<handle>2</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<shape>Circle</shape>
<drawPriority>0</drawPriority>
</corona>
<corona>
<type>TextBox</type>
<handle>2</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<drawPriority>1</drawPriority>
<lineWidth>100</lineWidth>
<font>Arial-20</font>
<initialTranslation>
<x>0</x>
<y>120</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<rotateWithHandle>false</rotateWithHandle>
<centred>true</centred>
<text>Banana</text>
</corona>
<corona>
<type>Gauge</type>
<handle>2</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<initialTranslation>
<x>-125</x>
<y>-125</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<drawPriority>2</drawPriority>
<width>250</width>
<height>250</height>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<scale>1</scale>
<title>Train</title>
<unit>km</unit>
<rotateWithHandle>false</rotateWithHandle>
</corona>
</coronas>
<name>Train</name>
<definingShape></definingShape>
<networkAdapter></networkAdapter>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<lowerStopAngle>0</lowerStopAngle>
<upperStopAngle>6.28318530718</upperStopAngle>
<stepSize>1</stepSize>
<variable>
<name>Train</name>
<unit>km</unit>
<value>0</value>
</variable>
<modifyValueOnRotation>True</modifyValueOnRotation>
</object>
<object>
<type>ValueWidget</type>
<handles>
<handle>3</handle>
</handles>
<coronas>
<corona>
<type>Shadow</type>
<handle>3</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<shape>Circle</shape>
<drawPriority>0</drawPriority>
</corona>
<corona>
<type>TextBox</type>
<handle>3</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<drawPriority>1</drawPriority>
<lineWidth>100</lineWidth>
<font>Arial-20</font>
<initialTranslation>
<x>0</x>
<y>120</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<rotateWithHandle>false</rotateWithHandle>
<centred>true</centred>
<text>Banana</text>
</corona>
<corona>
<type>Gauge</type>
<handle>3</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<initialTranslation>
<x>-125</x>
<y>-125</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<drawPriority>2</drawPriority>
<width>250</width>
<height>250</height>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<scale>1</scale>
<title>Car</title>
<unit>km</unit>
<rotateWithHandle>false</rotateWithHandle>
</corona>
</coronas>
<name>Car</name>
<definingShape></definingShape>
<networkAdapter></networkAdapter>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<lowerStopAngle>0</lowerStopAngle>
<upperStopAngle>6.28318530718</upperStopAngle>
<stepSize>1</stepSize>
<variable>
<name>Car</name>
<unit>km</unit>
<value>0</value>
</variable>
<modifyValueOnRotation>True</modifyValueOnRotation>
</object>
<object>
<type>ValueWidget</type>
<handles>
<handle>4</handle>
</handles>
<coronas>
<corona>
<type>Shadow</type>
<handle>4</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<shape>Circle</shape>
<drawPriority>0</drawPriority>
</corona>
<corona>
<type>TextBox</type>
<handle>4</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<drawPriority>1</drawPriority>
<lineWidth>100</lineWidth>
<font>Arial-20</font>
<initialTranslation>
<x>0</x>
<y>120</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<rotateWithHandle>false</rotateWithHandle>
<centred>true</centred>
<text>Banana</text>
</corona>
<corona>
<type>Gauge</type>
<handle>4</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<initialTranslation>
<x>-125</x>
<y>-125</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<drawPriority>2</drawPriority>
<width>250</width>
<height>250</height>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<scale>1</scale>
<title>Bus</title>
<unit>km</unit>
<rotateWithHandle>false</rotateWithHandle>
</corona>
</coronas>
<name>Bus</name>
<definingShape></definingShape>
<networkAdapter></networkAdapter>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<lowerStopAngle>0</lowerStopAngle>
<upperStopAngle>6.28318530718</upperStopAngle>
<stepSize>1</stepSize>
<variable>
<name>Bus</name>
<unit>km</unit>
<value>0</value>
</variable>
<modifyValueOnRotation>True</modifyValueOnRotation>
</object>
<object>
<type>ValueWidget</type>
<handles>
<handle>5</handle>
</handles>
<coronas>
<corona>
<type>Shadow</type>
<handle>5</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<shape>Circle</shape>
<drawPriority>0</drawPriority>
</corona>
<corona>
<type>TextBox</type>
<handle>5</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<drawPriority>1</drawPriority>
<lineWidth>100</lineWidth>
<font>Arial-20</font>
<initialTranslation>
<x>0</x>
<y>120</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<rotateWithHandle>false</rotateWithHandle>
<centred>true</centred>
<text>Banana</text>
</corona>
<corona>
<type>Gauge</type>
<handle>5</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<initialTranslation>
<x>-125</x>
<y>-125</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<drawPriority>2</drawPriority>
<width>250</width>
<height>250</height>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<scale>1</scale>
<title>Foot</title>
<unit>km</unit>
<rotateWithHandle>false</rotateWithHandle>
</corona>
</coronas>
<name>Foot</name>
<definingShape></definingShape>
<networkAdapter></networkAdapter>
<lowerBound>0</lowerBound>
<upperBound>50</upperBound>
<lowerStopAngle>0</lowerStopAngle>
<upperStopAngle>6.28318530718</upperStopAngle>
<stepSize>1</stepSize>
<variable>
<name>Foot</name>
<unit>km</unit>
<value>0</value>
</variable>
<modifyValueOnRotation>True</modifyValueOnRotation>
</object>
<object>
<type>ValueWidget</type>
<handles>
<handle>6</handle>
</handles>
<coronas>
<corona>
<type>Shadow</type>
<handle>6</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<shape>RoundedSquare</shape>
<drawPriority>0</drawPriority>
</corona>
<corona>
<type>TextBox</type>
<handle>6</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<drawPriority>1</drawPriority>
<rotateWithHandle>false</rotateWithHandle>
<lineWidth>100</lineWidth>
<centred>true</centred>
<font>Arial-20</font>
<initialTranslation>
<x>0</x>
<y>75</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
<text>Banana</text>
</corona>
<corona>
<type>ConditionalCorona</type>
<handle>6</handle>
<centre>
<x>0</x>
<y>0</y>
<z>0</z>
</centre>
<drawPriority>2</drawPriority>
<system>
<outputs>
<output>
<name>LessThan</name>
<unit>boolean</unit>
</output>
<output>
<name>MoreThan</name>
<unit>boolean</unit>
</output>
</outputs>
<equations>
<equation>
<name>Trigger</name>
<parameters>
<parameter>
<name>Pollution</name>
<unit>gr</unit>
</parameter>
</parameters>
<invoke>Pollution &lt; 5</invoke>
<results>
<result>
<name>LessThan</name>
<unit>boolean</unit>
</result>
</results>
</equation>
<equation>
<name>Trigger2</name>
<parameters>
<parameter>
<name>Pollution</name>
<unit>gr</unit>
</parameter>
</parameters>
<invoke>Pollution &gt; 5</invoke>
<results>
<result>
<name>MoreThan</name>
<unit>boolean</unit>
</result>
</results>
</equation>
</equations>
</system>
<images>
<image>
<asset>assets/up.png</asset>
<trigger>LessThan</trigger>
</image>
<image>
<asset>assets/down.png</asset>
<trigger>MoreThan</trigger>
</image>
</images>
</corona>
</coronas>
<name>Pollution</name>
<definingShape></definingShape>
<networkAdapter></networkAdapter>
<lowerBound>0</lowerBound>
<upperBound>1</upperBound>