Commit c61f50b4 authored by Nathan Bonnemberger's avatar Nathan Bonnemberger
Browse files

PositionWidget CPU consumption optimized

parent 3c3d4af9
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="lu.list.itis.dkd.tui.logging">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<File name="LogFile" fileName="logs/colosseum.log" append="false">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
</Appenders>
<Loggers>
<Logger name="lu.list.itis.dkd.tui.cps" level="info">
<AppenderRef ref="LogFile" level="trace"/>
</Logger>
<Logger name="com.mchange" level="warn"/>
<Logger name="lu.list.itis.dkd.tui.cps.system.executor.JavascriptExecutor" level="info"/>
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="LogFile"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
This diff is collapsed.
......@@ -39,4 +39,8 @@ spatial.variable.class = lu.list.itis.dkd.tui.cps.variable.SpatialVariable
equation.system = circuit_scenario.xml
scenario.description = circuit_scenario.xml
# Properties for the Database
sql.connection.url=jdbc:postgresql://localhost/nathan
sql.driver.class=org.postgresql.Driver
sql.user.name=nathan
sql.user.password=qwertz
\ No newline at end of file
......@@ -36,3 +36,9 @@ executor.class = lu.list.itis.dkd.tui.cps.system.executor.JavascriptExecutor
numeric.variable.class = lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable
logic.variable.class = lu.list.itis.dkd.tui.cps.variable.BooleanVariable
spatial.variable.class = lu.list.itis.dkd.tui.cps.variable.SpatialVariable
# Properties for the Database
sql.connection.url=jdbc:postgresql://localhost/nathan
sql.driver.class=org.postgresql.Driver
sql.user.name=nathan
sql.user.password=qwertz
......@@ -65,6 +65,9 @@ public class Scenario {
Properties properties;
private TangibleApplication tangibleApplication;
static {
System.setProperty("log4j.configurationFile", "log4j2.xml");
}
/**
* Constructor initializing all fields. The constructor will also populate all variables and use
......@@ -76,6 +79,9 @@ public class Scenario {
* description document loaded.
*/
public Scenario(String file) throws BuildException {
try {
properties = PropertiesFetcher.fetchProperties(file);
equationSystemBuilder = new EquationSystemBuilder(properties);
......@@ -150,7 +156,12 @@ public class Scenario {
if (variable.getValue() != null) {
((PositionWidget) widget).setVariable(variable);
for (final ConditionalCorona corona : widget.getCoronas(ConditionalCorona.class)) {
corona.getTriggers().forEach(trigger -> corona.addVariable(retrieveVariableByName(trigger)));
for (final String trigger : corona.getTriggers()) {
final Variable<?> triggerVariable = retrieveVariableByName(trigger);
corona.addVariable(triggerVariable);
triggerVariable.addListener(corona);
}
}
} else {
final Logger LOGGER = Logger.getLogger(Logger.class.getName());
......
......@@ -54,6 +54,50 @@
</corona>
</coronas>
</object>
<object>
<type>PositionWidget</type>
<name>SQL</name>
<scaleX>1.0</scaleX>
<scaleY>1.0</scaleY>
<stepXSize>0.1</stepXSize>
<stepYSize>0.1</stepYSize>
<modifyValueOnTranslation>true</modifyValueOnTranslation>
<leftMostBound>0.0</leftMostBound>
<rightMostBound>1.0</rightMostBound>
<downMostBound>1.0</downMostBound>
<upMostBound>0.0</upMostBound>
<handles>
<handle>2</handle>
</handles>
<variable>
<name>BuildingID</name>
<type>spatial</type>
<position>
<x>0</x>
<y>0</y>
<z>0</z>
<state>CameraCoordinates</state>
</position>
</variable>
<coronas>
<corona>
<handle>2</handle> <!-- Marker ID: needs to be the same for a same widget -->
<type>ConditionalCorona</type>
<drawPriority>277</drawPriority> <!-- needs to be different for each corona -->
<rotateWithHandle>false</rotateWithHandle> <!-- if true it rotates with the object -->
<image>assets/industry2.jpg</image> <!-- The image file name -->
<spinOnCoronaCentre>true</spinOnCoronaCentre>
<triggers>
<trigger>Building</trigger> <!-- insert each variable you use for the trigger condition -->
</triggers>
<initialTranslation>
<x>-158</x><y>-141</y><z>0</z> <!-- in pixel -->
<state>ScreenCoordinates</state>
</initialTranslation>
<triggerCondition>(Building &lt; 8.5) &amp;&amp; (Building &gt; 7.5)</triggerCondition> <!-- Condition: &gt; &lt; == != &amp;&amp; -->
</corona>
</coronas>
</object>
</objects>
<!-- ##### EQUATIONS ######################################################### -->
......@@ -71,6 +115,24 @@
<type>numeric</type>
<initial>0</initial>
</output>
<output>
<name>Building</name> <!-- result of SQL query -->
<unit></unit>
<type>numeric</type>
<initial>0</initial>
</output>
<output>
<name>BuildingID</name> <!-- variable holding value for handle#2 -->
<unit></unit>
<type>spatial</type>
<initial>0,0,0,CameraCoordinates</initial>
</output>
<output>
<name>BuildingX</name> <!-- variable holding only x parameter of BuildingID variable -->
<unit></unit>
<type>numeric</type>
<initial>0</initial>
</output>
</outputs>
<equations>
<equation> <!-- copy for each equation -->
......@@ -107,6 +169,32 @@
</result>
</results>
</equation>
<equation>
<name>changeX</name>
<invoke>BuildingID_x + 0</invoke>
<parameters>
<parameter>
<name>BuildingID</name>
<unit></unit>
<type>spatial</type>
<initial>250,300,350,ScreenCoordinates</initial>
</parameter>
</parameters>
<results>
<result>
<name>BuildingX</name>
</result>
</results>
</equation>
<equation name="SQLTest">
<parameters>
<parameter name="BuildingX"/>
</parameters>
<invoke executor="Sql">SELECT id FROM buildings WHERE (id = #{BuildingX}*10+3);</invoke>
<results>
<result name="Building" equate="id"/>
</results>
</equation>
</equations>
</system>
</scenario>
\ No newline at end of file
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