Commit 6beda736 authored by Nathan Bonnemberger's avatar Nathan Bonnemberger
Browse files

SFP-vector first version okay

parent 7b3b8989
......@@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
......@@ -19,5 +24,6 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}/model</path>
</pydev_pathproperty>
</pydev_project>
This diff is collapsed.
'''
Created on 11 aout 2017
@author: nathan
'''
import collections
def Mapping (p_BuildingIds, p_Building1, p_Building2, p_Building3, p_Building4, p_Building5, p_Building6, p_Building7, p_Building8, p_Building9, p_Building10, p_Building11, p_Building12, p_Building13, p_Building14, p_Building15, p_Building16, p_Building17, p_Building18, p_Building19, p_Building20, p_Building21, p_Building22, p_Building23, p_Building24, p_Building25, p_Building26, p_Building27, p_Building28, p_Building29, p_Building30, p_Building31, p_Building32, p_Building33, p_Building34, p_Building35, p_Building36, p_Building37):
Association = collections.namedtuple('Association', 'x,y,id')
l_BuildingAssociations = ((Association (p_Building1['x'], p_Building1['y'], p_BuildingIds[0])),
(Association (p_Building2['x'], p_Building2['y'], p_BuildingIds[0])),
(Association (p_Building3['x'], p_Building3['y'], p_BuildingIds[1])),
(Association (p_Building4['x'], p_Building4['y'], p_BuildingIds[1])),
(Association (p_Building5['x'], p_Building5['y'], p_BuildingIds[2])),
(Association (p_Building6['x'], p_Building6['y'], p_BuildingIds[3])),
(Association (p_Building7['x'], p_Building7['y'], p_BuildingIds[3])),
(Association (p_Building8['x'], p_Building8['y'], p_BuildingIds[4])),
(Association (p_Building9['x'], p_Building9['y'], p_BuildingIds[4])),
(Association (p_Building1['x'], p_Building1['y'], p_BuildingIds[5])),
(Association (p_Building11['x'], p_Building11['y'], p_BuildingIds[6])),
(Association (p_Building12['x'], p_Building12['y'], p_BuildingIds[7])),
(Association (p_Building13['x'], p_Building13['y'], p_BuildingIds[8])),
(Association (p_Building14['x'], p_Building14['y'], p_BuildingIds[9])),
(Association (p_Building15['x'], p_Building15['y'], p_BuildingIds[10])),
(Association (p_Building16['x'], p_Building16['y'], p_BuildingIds[10])),
(Association (p_Building17['x'], p_Building17['y'], p_BuildingIds[11])),
(Association (p_Building18['x'], p_Building18['y'], p_BuildingIds[11])),
(Association (p_Building19['x'], p_Building19['y'], p_BuildingIds[12])),
(Association (p_Building20['x'], p_Building20['y'], p_BuildingIds[13])),
(Association (p_Building21['x'], p_Building21['y'], p_BuildingIds[14])),
(Association (p_Building22['x'], p_Building22['y'], p_BuildingIds[15])),
(Association (p_Building23['x'], p_Building23['y'], p_BuildingIds[16])),
(Association (p_Building24['x'], p_Building24['y'], p_BuildingIds[16])),
(Association (p_Building25['x'], p_Building25['y'], p_BuildingIds[17])),
(Association (p_Building26['x'], p_Building26['y'], p_BuildingIds[17])),
(Association (p_Building27['x'], p_Building27['y'], p_BuildingIds[18])),
(Association (p_Building28['x'], p_Building28['y'], p_BuildingIds[19])),
(Association (p_Building29['x'], p_Building29['y'], p_BuildingIds[20])),
(Association (p_Building30['x'], p_Building30['y'], p_BuildingIds[21])),
(Association (p_Building31['x'], p_Building31['y'], p_BuildingIds[22])),
(Association (p_Building32['x'], p_Building32['y'], p_BuildingIds[22])),
(Association (p_Building33['x'], p_Building33['y'], p_BuildingIds[22])),
(Association (p_Building34['x'], p_Building34['y'], p_BuildingIds[23])),
(Association (p_Building35['x'], p_Building35['y'], p_BuildingIds[24])),
(Association (p_Building36['x'], p_Building36['y'], p_BuildingIds[25])),
(Association (p_Building37['x'], p_Building37['y'], p_BuildingIds[26])))
return l_BuildingAssociations
def ConstructionCosts (p_BuildingAssociations, p_BuildingCCs):
l_Index = -1
l_Costs = 0
l_Building = -1
for l_Index in range(len(p_BuildingAssociations)):
l_Building = p_BuildingAssociations[l_Index].id
if (p_BuildingAssociations[l_Index].x > 0) and (p_BuildingAssociations[l_Index].y > 0):
l_Costs += p_BuildingCCs[l_Building]
return l_Costs
def OccupiedSurface (p_BuildingAssociations, p_BuildingXsizes, p_BuildingYsizes):
l_Index = -1
l_Surface = 0
l_Building = -1
for l_Index in range(len(p_BuildingAssociations)):
l_Building = p_BuildingAssociations[l_Index].id
if (p_BuildingAssociations[l_Index].x > 0) and (p_BuildingAssociations[l_Index].y > 0):
l_Surface += p_BuildingXsizes[l_Building] * p_BuildingYsizes[l_Building]
return l_Surface
def LivingSpace (p_BuildingAssociations, p_BuildingXsizes, p_BuildingYsizes, p_BuildingFloors):
l_Index = -1
l_Space = 0
l_Building = -1
for l_Index in range(len(p_BuildingAssociations)):
l_Building = p_BuildingAssociations[l_Index].id
if (p_BuildingAssociations[l_Index].x > 0) and (p_BuildingAssociations[l_Index].y > 0):
l_Space += p_BuildingXsizes[l_Building] * p_BuildingYsizes[l_Building] * p_BuildingFloors[l_Building]
return l_Space
......@@ -29,14 +29,15 @@ adapter.class = lu.list.itis.dkd.tui.adapter.TuioAdapter
# The location and name of the root bootstrapping file.
bootstrapping.root = light_scenario.xml
python.workingDir=model
# Properties for the equation system
executor.class = lu.list.itis.dkd.tui.cps.system.executor.JavascriptExecutor
executor.class = lu.list.itis.dkd.tui.cps.system.executor.PythonExecutor
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
text.variable.class = lu.list.itis.dkd.tui.cps.variable.TextVariable
vector.variable.class = lu.list.itis.dkd.tui.cps.variable.VectorVariable
# Properties for the Database
sql.connection.url=jdbc:postgresql://localhost/nathan
......
This diff is collapsed.
This diff is collapsed.
......@@ -135,6 +135,11 @@ public class Scenario {
tangibleApplication.setContentManager(StageManager.getInstance());
tangibleApplication.connect();
final Variable<?> runOnce = equationSystemBuilder.getInputVariables().get("RunOnce");
if (runOnce != null) {
runOnce.setValueFromObject(1.0);
}
}
......@@ -154,6 +159,7 @@ public class Scenario {
corona.getTriggers().forEach(trigger -> corona.addVariable(retrieveVariableByName(trigger)));
}
}
if (widget instanceof PositionWidget) {
final SpatialVariable variable = retrieveSpatialVariableByName(((PositionWidget) widget).getVariable().getName());
if (variable.getValue() != null) {
......
......@@ -129,23 +129,11 @@
</position>
</variable>
<coronas>
<corona>
<type>ConditionalMqtt</type>
<corona>
<type>Shadow</type>
<handle>3</handle>
<drawPriority>278</drawPriority> <!-- needs to be different for each corona -->
<rotateWithHandle>false</rotateWithHandle> <!-- if true it rotates with the object -->
<mqtt>
<broker>tcp://localhost</broker>
<port>1883</port>
<userId>tui</userId>
<payload>right</payload>
<topic>/BaseNode/actuator/strip/fullstrip</topic>
</mqtt>
<triggers>
<trigger>mqttX</trigger> <!-- insert each variable you use for the trigger condition -->
<trigger>mqttY</trigger> <!-- insert each variable you use for the trigger condition -->
</triggers>
<triggerCondition>(mqttX &gt; 0.8) &amp;&amp; (mqttY &gt; 0.7)</triggerCondition> <!-- Condition: &gt; &lt; == != &amp;&amp; -->
<shape>Circle</shape>
<drawPriority>0</drawPriority>
</corona>
</coronas>
</object>
......@@ -201,6 +189,21 @@
<type>numeric</type>
<initial>0</initial>
</output>
<!--outputs for MQTT executor -->
<output>
<name>Payload</name>
<unit></unit>
<type>text</type>
<initial>right</initial>
</output>
<output>
<name>mqttResult</name>
<unit></unit>
<type></type>
<initial></initial>
</output>
</outputs>
<equations>
......@@ -268,41 +271,44 @@
</results>
</equation>
<!-- equations for MQTT -->
<equation>
<name>mqttX</name>
<invoke>mqtt_x + 0</invoke>
<!--equations for MQTT executor -->
<equation name="payload">
<parameters>
<parameter>
<name>mqtt</name>
<unit></unit>
<parameter> <!-- copy for each of the variables needed in the equation -->
<name>mqtt</name> <!-- insert variable name -->
<unit></unit> <!-- unit of the variable -->
<type>spatial</type>
<initial>100,100,100,ScreenCoordinates</initial>
<initial>100,150,200,ScreenCoordinates</initial>
</parameter>
</parameters>
<invoke>(mqtt_x*100 &lt; 600) ? 'right' : 'wrong'</invoke>
<results>
<result>
<name>mqttX</name>
</result>
<result name="Payload"/>
</results>
</equation>
<equation>
<name>mqttY</name>
<invoke>mqtt_y + 0</invoke>
</equation>
<equation name="MQTTExec">
<parameters>
<parameter>
<name>mqtt</name>
<name>Payload</name> <!-- variable holding only x parameter of BuildingID variable -->
<unit></unit>
<type>spatial</type>
<initial>100,100,100,ScreenCoordinates</initial>
<type>text</type>
<initial>right</initial>
</parameter>
<parameter>
<name>Topic</name> <!-- variable holding only x parameter of BuildingID variable -->
<unit></unit>
<type>text</type>
<initial>/BaseNode/actuator/strip/fullstrip</initial>
</parameter>
</parameters>
<invoke executor="Mqtt">SEND {Payload} TO {Topic}</invoke>
<results>
<result>
<name>mqttY</name>
</result>
<result name="mqttResult"/>
</results>
</equation>
</equation>
</equations>
</system>
......
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