Commit 61df7ec3 authored by Eric Tobias's avatar Eric Tobias
Browse files

Added ConditionalCorona varaible initialization

parent 455083ca
......@@ -39,12 +39,12 @@
</scenes>
<objects>
<!-- ##### Feedback Button #########################################################-->
<object>
<!-- ##### Feedback Button ######################################################### -->
<object>
<name>Feedback</name>
<variable>
<name>Feedback</name>
<unit>none</unit>
<unit>Feedback</unit>
<value>1</value>
</variable>
<modifyValueOnRotation>False</modifyValueOnRotation>
......@@ -76,8 +76,8 @@
<text>Banana</text>
</corona>
</coronas>
</object>
<!-- ##### Wheel Gear #########################################################-->
</object>
<!-- ##### Wheel Gear ######################################################### -->
<object>
<name>WheelGear</name>
<lowerBound>-7</lowerBound>
......@@ -114,7 +114,7 @@
<drawPriority>2</drawPriority>
<image>assets/wheelgear1.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>WheelGear == -7</triggerCondition>
<triggerCondition>WheelGear == -7</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -128,7 +128,7 @@
<drawPriority>3</drawPriority>
<image>assets/wheelgear2.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>WheelGear == -6</triggerCondition>
<triggerCondition>WheelGear == -6</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -142,7 +142,7 @@
<drawPriority>4</drawPriority>
<image>assets/wheelgear3.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>WheelGear == -5</triggerCondition>
<triggerCondition>WheelGear == -5</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -156,7 +156,7 @@
<drawPriority>5</drawPriority>
<image>assets/wheelgear4.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>WheelGear == -4</triggerCondition>
<triggerCondition>WheelGear == -4</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -170,7 +170,7 @@
<drawPriority>6</drawPriority>
<image>assets/wheelgear5.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>WheelGear == -3</triggerCondition>
<triggerCondition>WheelGear == -3</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -184,7 +184,7 @@
<drawPriority>7</drawPriority>
<image>assets/wheelgear6.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>WheelGear == -2</triggerCondition>
<triggerCondition>WheelGear == -2</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -198,7 +198,7 @@
<drawPriority>8</drawPriority>
<image>assets/wheelgear7.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>WheelGear == -1</triggerCondition>
<triggerCondition>WheelGear == -1</triggerCondition>
</corona>
<corona>
<type>Image</type>
......@@ -216,7 +216,7 @@
</corona>
</coronas>
</object>
<!-- ##### Pedal Gear #########################################################-->
<!-- ##### Pedal Gear ######################################################### -->
<object>
<name>PedalGear</name>
<lowerBound>1</lowerBound>
......@@ -253,7 +253,7 @@
<drawPriority>2</drawPriority>
<image>assets/pedalgear1.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>PedalGear == 1</triggerCondition>
<triggerCondition>PedalGear == 1</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -267,7 +267,7 @@
<drawPriority>3</drawPriority>
<image>assets/pedalgear2.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>PedalGear == 2</triggerCondition>
<triggerCondition>PedalGear == 2</triggerCondition>
</corona>
<corona>
<type>ConditionalCorona</type>
......@@ -281,7 +281,7 @@
<drawPriority>4</drawPriority>
<image>assets/pedalgear3.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>PedalGear == 3</triggerCondition>
<triggerCondition>PedalGear == 3</triggerCondition>
</corona>
<corona>
<type>Image</type>
......@@ -299,7 +299,7 @@
</corona>
</coronas>
</object>
<!-- ##### Inclination #########################################################-->
<!-- ##### Inclination ######################################################### -->
<object>
<name>Inclination</name>
<lowerBound>0</lowerBound>
......@@ -356,7 +356,7 @@
</corona>
</coronas>
</object>
<!-- ##### Ground #########################################################-->
<!-- ##### Ground ######################################################### -->
<object>
<name>Ground</name>
<lowerBound>0.2</lowerBound>
......@@ -396,8 +396,8 @@
<spinOnCoronaCentre>true</spinOnCoronaCentre>
</corona>
</coronas>
</object>
<!-- ##### Distance #########################################################-->
</object>
<!-- ##### Distance ######################################################### -->
<object>
<name>Distance</name>
<lowerBound>1</lowerBound>
......@@ -455,7 +455,7 @@
</coronas>
</object>
<!-- ##### Ratio #########################################################-->
<!-- ##### Ratio ######################################################### -->
<object>
<name>Ratio</name>
<variable>
......@@ -492,8 +492,8 @@
</corona>
</coronas>
</object>
<!-- ##### ForceOnPedal #########################################################-->
<!-- ##### ForceOnPedal ######################################################### -->
<object>
<name>ForceOnPedal</name>
<variable>
......@@ -543,6 +543,9 @@
</corona>
<corona>
<type>ConditionalCorona</type>
<triggers>
<trigger>Feedback</trigger>
</triggers>
<handle>7</handle>
<initialTranslation>
<x>-100</x>
......@@ -553,12 +556,12 @@
<drawPriority>3</drawPriority>
<image>assets/waiting.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>false</triggerCondition>
</corona>
<triggerCondition>Feedback == 0</triggerCondition>
</corona>
</coronas>
</object>
<!-- ##### Energy #########################################################-->
<!-- ##### Energy ######################################################### -->
<object>
<name>Energy</name>
<variable>
......@@ -609,6 +612,9 @@
<corona>
<type>ConditionalCorona</type>
<handle>8</handle>
<triggers>
<trigger>Feedback</trigger>
</triggers>
<initialTranslation>
<x>-100</x>
<y>90</y>
......@@ -618,13 +624,13 @@
<drawPriority>3</drawPriority>
<image>assets/waiting.png</image>
<rotateWithHandle>false</rotateWithHandle>
<triggerCondition>false</triggerCondition>
</corona>
<triggerCondition>Feedback == 1</triggerCondition>
</corona>
</coronas>
</object>
</objects>
<!-- ##### EQUATIONS #########################################################-->
<!-- ##### EQUATIONS ######################################################### -->
<system>
<outputs>
<output>
......@@ -639,6 +645,10 @@
<name>Energy</name>
<unit>J</unit>
</output>
<output>
<name>Feedback</name>
<unit>Feedback</unit>
</output>
</outputs>
<equations>
<equation>
......@@ -652,10 +662,6 @@
<name>PedalGear</name>
<unit>Gear</unit>
</parameter>
<parameter>
<name>Feedback</name>
<unit>feedback</unit>
</parameter>
</parameters>
<invoke>-(WheelGear) / PedalGear ;</invoke>
<results>
......@@ -670,7 +676,7 @@
<equation>
<name>ForceOnPedal</name>
<parameters>
<parameter>
<parameter>
<name>Inclination</name>
<unit>%</unit>
</parameter>
......@@ -678,9 +684,7 @@
<name>Ground</name>
<unit>Coarseness</unit>
</parameter>
<!-- <parameter>
<name>Ratio</name>
</parameter> -->
<!-- <parameter> <name>Ratio</name> </parameter> -->
<parameter>
<name>PedalGear</name>
<unit>Gear</unit>
......@@ -702,7 +706,7 @@
<equation>
<name>Energy</name>
<parameters>
<parameter>
<parameter>
<name>Inclination</name>
<unit>%</unit>
</parameter>
......
......@@ -34,6 +34,7 @@ import lu.list.itis.dkd.tui.scenario.bootstrapping.SceneBootstrapper;
import lu.list.itis.dkd.tui.utility.PropertiesFetcher;
import lu.list.itis.dkd.tui.widget.BaseWidget;
import lu.list.itis.dkd.tui.widget.ValueWidget;
import lu.list.itis.dkd.tui.widget.corona.ConditionalCorona;
import com.google.common.base.Preconditions;
......@@ -46,7 +47,7 @@ import java.util.Map;
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 1.0
* @version 1.1.0
* @version 1.1.2
*/
@NonNullByDefault
public class Scenario {
......@@ -93,13 +94,19 @@ public class Scenario {
/**
* Method used to replace the placeholder variables in each widget with the variable as
* initialized by the equation system.
* initialized by the equation system. The method will also set all trigger variables of
* conditional corona with the variables for the given trigger names.
*
*/
private void populateVariables() {
for (final BaseWidget widget : TangibleObjectManager.getWidgets()) {
if (widget instanceof ValueWidget) {
final TangibleNumericalVariable variable = findVariable(((ValueWidget) widget).getVariable().getName());
final TangibleNumericalVariable variable = retrieveVariableByName(((ValueWidget) widget).getVariable().getName());
((ValueWidget) widget).setVariable(variable);
for (final ConditionalCorona corona : widget.getCoronas(ConditionalCorona.class)) {
corona.getTriggers().forEach(trigger -> corona.addVariable(retrieveVariableByName(trigger)));
}
}
}
}
......@@ -112,7 +119,7 @@ public class Scenario {
* @return The {@link TangibleNumericalVariable} that responds to the given name or
* <code>null</code> should no such variable exist.
*/
static @Nullable TangibleNumericalVariable findVariable(String name) {
static @Nullable TangibleNumericalVariable retrieveVariableByName(String name) {
return (TangibleNumericalVariable) (inputs.get(name) == null ? outputs.get(name) : inputs.get(name));
}
......
......@@ -92,7 +92,7 @@ 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)) {
final Variable variable = Scenario.findVariable(_name);
final Variable variable = Scenario.retrieveVariableByName(_name);
if (null != variable) {
variables.add(variable);
......
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