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

new version of the satellite scenario

parent f4d100b2
def convertDistance(distance):
if distance == 0:
distance_real = 700
elif distance == 1:
distance_real = 20200
elif distance == 2:
distance_real = 36000
elif distance == 3:
distance_real = 72000
elif distance == 4:
distance_real = 380000
else:
distance_real = 300000000
return distance_real
def convertSignalSpeed(signal_speed):
if signal_speed == 0:
signal_speed_real = 0
elif signal_speed == 1:
signal_speed_real = 0.34
elif signal_speed == 2:
signal_speed_real = 0.6
elif signal_speed == 3:
signal_speed_real = 29.8
else:
signal_speed_real = 300000
return signal_speed_real
\ No newline at end of file
from collections import namedtuple
last_duration_data = 0
last_duration_signal = 0
def calculateDurations(distance_real, signal_speed_real, data_quantity, transfer_rate):
Variables = namedtuple('Variables', 'duration_signal, duration_data')
if distance_real == 0 or signal_speed_real == 0:
duration_signal = 0
else:
duration_signal = distance_real / signal_speed_real
if transfer_rate == 0 or data_quantity == 0:
duration_data = 0
else:
duration_data = (data_quantity * 8 * 1024) / transfer_rate
return Variables(duration_signal, duration_data)
def lastDurationData(duration_data, check_result):
#def lastDurationData(duration_data, check_result, tries):
global last_duration_data
if check_result == 1:
last_duration_data = duration_data
return last_duration_data
def lastDurationSignal(duration_signal, check_result):
#def lastDurationSignal(duration_signal, check_result, tries):
global last_duration_signal
if check_result == 1:
last_duration_signal = duration_signal
return last_duration_signal
def generateDurationText(duration):
years = 0
days = 0
hours = 0
minutes = 0
seconds = 0
duration_text = ""
if duration < 60:
duration_text = '%.2f' % duration + " sec"
# print duration_text
return duration_text
if duration >= 31557600 : # years
years = duration // 31557600
duration = duration - years * 31557600
if years == 1:
duration_text = str(int(years)) + " year "
else:
duration_text = str(int(years)) + " years "
if duration >= 86400: # days
days = duration // 86400
duration = duration - days * 86400
if days == 1:
duration_text = duration_text + str(int(days)) + " day "
else:
duration_text = duration_text + str(int(days)) + " days "
if duration >= 3600: # hours
hours = duration // 3600
duration = duration - hours * 3600
if years == 0 :
if hours == 1:
duration_text = duration_text + str(int(hours)) + " hour "
else:
duration_text = duration_text + str(int(hours)) + " hours "
if duration >= 60: # minutes
minutes = duration // 60
duration = duration - minutes * 60
if years == 0 and days == 0 :
duration_text = duration_text + str(int(minutes)) + " min "
if duration > 0: # seconds
if years == 0 and days == 0 and hours == 0:
seconds = duration
duration_text = duration_text + str(int(seconds)) + " sec"
# print duration_text
return duration_text
#Test
#generateDurationText(500000000)
#generateDurationText(5000000)
#generateDurationText(50000)
#generateDurationText(500)
#generateDurationText(5)
#generateDurationText(0.05)
\ No newline at end of file
def verifyResult(task, distance_real, signal_speed_real, duration_signal, data_quantity, transfer_rate, duration_data):
if task == 1 and distance_real == 72000 and signal_speed_real == 300000 and duration_signal == 0.24:
taskResolved = 1
elif task == 2 and distance_real == 700 and signal_speed_real == 300000 and data_quantity == 100 and transfer_rate == 1000 and duration_data == 819.2:
taskResolved = 1
elif task == 3 and distance_real == 700 and signal_speed_real == 300000 and data_quantity == 50 and transfer_rate == 1000 and duration_data == 409.6:
taskResolved = 1
elif task == 4 and distance_real == 300000000 and signal_speed_real == 300000 and data_quantity == 200 and transfer_rate == 100 and duration_data == 16384 and duration_signal == 1000:
taskResolved = 1
elif task == 5 and distance_real == 300000000 and signal_speed_real == 300000 and data_quantity == 470 and transfer_rate == 230 and duration_signal == 1000:
taskResolved = 1
else:
taskResolved = 0
return taskResolved
from collections import namedtuple
score = 0
tries = 0
marks = 4
previousTask = 0
task1_resolved = 0
task2_resolved = 0
task3_resolved = 0
task4_resolved = 0
task5_resolved = 0
def calculateScore(task, task_resolved, check_result, initialize):
Variables = namedtuple('Variables', 'score, tries, marks, task1_resolved, task2_resolved, task3_resolved, task4_resolved, task5_resolved')
global score
global tries
global marks
global previousTask
global task1_resolved
global task2_resolved
global task3_resolved
global task4_resolved
global task5_resolved
if initialize == 1:
score = 0
tries = 0
marks = 0
previousTask = 0
task1_resolved = 0
task2_resolved = 0
task3_resolved = 0
task4_resolved = 0
task5_resolved = 0
return Variables(score, tries, marks)
if task == 0:
return Variables(score, tries, marks)
if task != previousTask:
# next task
previousTask = task
if (task == 1 and task1_resolved == 1) or (task == 2 and task2_resolved == 1) or (task == 3 and task3_resolved == 1) or (task == 4 and task4_resolved == 1) or (task == 5 and task5_resolved == 1):
tries = 0
marks = 0
else:
tries = 1
marks = 4
else:
# same task
if check_result == 1:
if task_resolved == 1: # resolved
if not ((task == 1 and task1_resolved == 1) or (task == 2 and task2_resolved == 1) or (task == 3 and task3_resolved == 1) or (task == 4 and task4_resolved == 1) or (task == 5 and task5_resolved == 1)):
score += marks
marks = 0
# remember which task has been solved
if task == 1 and task_resolved:
task1_resolved = 1
if task == 2 and task_resolved:
task2_resolved = 1
if task == 3 and task_resolved:
task3_resolved = 1
if task == 4 and task_resolved:
task4_resolved = 1
if task == 5 and task_resolved:
task5_resolved = 1
else: # not resolved
tries += 1
if tries == 2:
marks = 3
elif tries == 3:
marks = 2
elif tries == 4:
marks = 1
# print "task: " + str(task) + " tries:" + str(tries) + " marks: " + str(marks) + " score: " + str(score)
# print "task1: " + str(task1_resolved) + " task2: " + str(task2_resolved) + " task3: " + str(task3_resolved)
return Variables(score, tries, marks, task1_resolved, task2_resolved, task3_resolved, task4_resolved, task5_resolved)
# TEST
#calculateScore(0, 0, 0, 1) #task 0 => initializing
#calculateScore(1, 0, 0, 0) #task 1
#calculateScore(1, 1, 1, 0) #task 1: checking result - correct => score:0+3=3
#calculateScore(1, 1, 0, 0) #task 1: not checking result
#calculateScore(1, 1, 1, 0) #task 1: checking result - correct => score:3+0=3
#calculateScore(2, 0, 0, 0) #task 2
##calculateScore(2, 0, 1, 0) #task 2: checking result - incorrect => marks:2 because 2nd try
#calculateScore(2, 1, 1, 0) #task 2: checking result - correct => score:3+2=5
#calculateScore(3, 0, 0, 0) #task 3
#calculateScore(3, 1, 1, 0) #task 3:checking result - correct => score:5+3=8
# Properties for the Logger
logger.event.output.location = log.txt
logger.event.output.enabled = false
logger.level = ALL
logger.event.configuration = logger.xml
# Widget IDs to be mapped
# Properties for calibrating the interface
frameTitle = NUI Application
windowWidth = 1920
windowHeight = 1080
fullScreen = false
font = Arial
fontSize = 13
colour = BLACK
centred = false
# Properties for the calibration of the object manager
#The value below is best left at or above 1024
cursor.id.remapping.constant = 1024
# The low-level computer vision (or similar) adapter to load.
# Syntax is : adapter.class = packageName.ClassName
adapter.class = lu.list.itis.dkd.tui.adapter.TuioAdapter
# The location and name of the root bootstrapping file.
bootstrapping.root = scenarios/SatelliteCommunication/Satellitecommunication_BUTTON.xml
equation.system = scenarios/SatelliteCommunication/Satellitecommunication_BUTTON.xml
scenario.description = scenarios/SatelliteCommunication/Satellitecommunication_BUTTON.xml
# Properties for the equation system
executor.class = lu.list.itis.dkd.tui.cps.system.executor.PythonExecutor
numeric.variable.class = lu.list.itis.dkd.tui.cps.variable.NumericalVariable
logic.variable.class = lu.list.itis.dkd.tui.cps.variable.BooleanVariable
text.variable.class = lu.list.itis.dkd.tui.cps.variable.TextVariable
python.workingDir=model
# Properties for the Logger
logger.event.output.location = log.txt
logger.event.output.enabled = false
logger.level = ALL
logger.event.configuration = logger.xml
# Widget IDs to be mapped
# Properties for calibrating the interface
frameTitle = NUI Application
windowWidth = 1920
windowHeight = 1080
fullScreen = false
font = Arial
fontSize = 13
colour = BLACK
centred = false
# Properties for the calibration of the object manager
#The value below is best left at or above 1024
cursor.id.remapping.constant = 1024
# The low-level computer vision (or similar) adapter to load.
# Syntax is : adapter.class = packageName.ClassName
adapter.class = lu.list.itis.dkd.tui.adapter.TuioAdapter
# The location and name of the root bootstrapping file.
bootstrapping.root = scenarios/SatelliteCommunication/Satellitecommunication_TRYANDERROR.xml
equation.system = scenarios/SatelliteCommunication/Satellitecommunication_TRYANDERROR.xml
scenario.description = scenarios/SatelliteCommunication/Satellitecommunication_TRYANDERROR.xml
#bootstrapping.root = scenarios/PythonTest.xml
#equation.system = scenarios/PythonTest.xml
#scenario.description = scenarios/PythonTest.xml
# Properties for the equation system
executor.class = lu.list.itis.dkd.tui.cps.system.executor.PythonExecutor
numeric.variable.class = lu.list.itis.dkd.tui.cps.variable.NumericalVariable
logic.variable.class = lu.list.itis.dkd.tui.cps.variable.BooleanVariable
text.variable.class = lu.list.itis.dkd.tui.cps.variable.TextVariable
python.workingDir=model
<?xml version="1.0" encoding="UTF-8"?>
<scenario>
<scenes>
<scene>
<name>White background</name>
<image>scenarios/SatelliteCommunication/assets/white background.png</image>
<triggerCondition>true</triggerCondition>
<drawPriority>0</drawPriority>
</scene>
<scene>
<name>Low Earth Orbit with no transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_0_transfer rate_0.png</image>
<triggerCondition>distance_real == 700 &amp;&amp; transfer_rate &lt; 50</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Low Earth Orbit with low transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_0_transfer rate_1.png</image>
<triggerCondition>distance_real == 700 &amp;&amp; transfer_rate &gt;= 50 &amp;&amp; transfer_rate &lt; 200</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Low Earth Orbit with medium transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_0_transfer rate_2.png</image>
<triggerCondition>distance_real == 700 &amp;&amp; transfer_rate &gt;= 200 &amp;&amp; transfer_rate &lt; 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Low Earth Orbit with high transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_0_transfer rate_3.png</image>
<triggerCondition>distance_real == 700 &amp;&amp; transfer_rate &gt;= 600 &amp;&amp; transfer_rate &lt; 1000</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Low Earth Orbit with high transfer - with label</name>
<image>scenarios/SatelliteCommunication/assets/distance_0_transfer rate_4.png</image>
<triggerCondition>distance_real == 700 &amp;&amp; transfer_rate == 1000</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Medium Earth Orbit with no transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_1_transfer rate_1.png</image>
<triggerCondition>distance_real == 20200 &amp;&amp; transfer_rate &gt;= 50 &amp;&amp; transfer_rate &lt; 200</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Medium Earth Orbit with low transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_1_transfer rate_2.png</image>
<triggerCondition>distance_real == 20200 &amp;&amp; transfer_rate &gt;= 200 &amp;&amp; transfer_rate &lt; 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Medium Earth Orbit with medium transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_1_transfer rate_3.png</image>
<triggerCondition>distance_real == 20200 &amp;&amp; transfer_rate &gt;= 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Medium Earth Orbit with high transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_1_transfer rate_0.png</image>
<triggerCondition>distance_real == 20200 &amp;&amp; transfer_rate &lt; 50</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit with no transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_2_transfer rate_0.png</image>
<triggerCondition>distance_real == 36000 &amp;&amp; transfer_rate &lt; 50</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit with low transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_2_transfer rate_1.png</image>
<triggerCondition>distance_real == 36000 &amp;&amp; transfer_rate &gt;= 50 &amp;&amp; transfer_rate &lt; 200</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit with medium transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_2_transfer rate_2.png</image>
<triggerCondition>distance_real == 36000 &amp;&amp; transfer_rate &gt;= 200 &amp;&amp; transfer_rate &lt; 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit with high transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_2_transfer rate_3.png</image>
<triggerCondition>distance_real == 36000 &amp;&amp; transfer_rate &gt;= 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit (2-way) with no transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_3_transfer rate_0.png</image>
<triggerCondition>distance_real == 72000 &amp;&amp; transfer_rate &lt; 50</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit (2-way) with low transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_3_transfer rate_1.png</image>
<triggerCondition>distance_real == 72000 &amp;&amp; transfer_rate &gt;= 50 &amp;&amp; transfer_rate &lt; 200</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit (2-way) with medium transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_3_transfer rate_2.png</image>
<triggerCondition>distance_real == 72000 &amp;&amp; transfer_rate &gt;= 200 &amp;&amp; transfer_rate &lt; 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Geostationary Orbit (2-way) with high transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_3_transfer rate_3.png</image>
<triggerCondition>distance_real == 72000 &amp;&amp; transfer_rate &gt;= 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>To the moon</name>
<image>scenarios/SatelliteCommunication/assets/distance_4_transfer rate_0.png</image>
<triggerCondition>distance_real == 380000</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>To Mars with no transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_5_transfer rate_0.png</image>
<triggerCondition>distance_real == 300000000 &amp;&amp; transfer_rate &lt; 50</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>To Mars with low transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_5_transfer rate_1.png</image>
<triggerCondition>distance_real == 300000000 &amp;&amp; transfer_rate &gt;= 50 &amp;&amp; transfer_rate &lt; 200</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>To Mars with medium transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_5_transfer rate_2.png</image>
<triggerCondition>distance_real == 300000000 &amp;&amp; transfer_rate &gt;= 200 &amp;&amp; transfer_rate &lt; 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>To Mars with high transfer</name>
<image>scenarios/SatelliteCommunication/assets/distance_5_transfer rate_3.png</image>
<triggerCondition>distance_real == 300000000 &amp;&amp; transfer_rate &gt;= 600</triggerCondition>
<drawPriority>50</drawPriority>
</scene>
<scene>
<name>Task 0</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_0.png</image>
<triggerCondition>task == 0</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 1 unresolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_1a.png</image>
<triggerCondition>task == 1 &amp;&amp; ( distance_real != 72000 || signal_speed_real != 300000 || duration_signal != 0.24 )</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 1 resolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_1b.png</image>
<triggerCondition>task == 1 &amp;&amp; distance_real == 72000 &amp;&amp; signal_speed_real == 300000 &amp;&amp; duration_signal == 0.24</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 2 unresolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_2a.png</image>
<triggerCondition>task == 2 &amp;&amp; ( distance_real != 700 || signal_speed_real != 300000 || data_quantity != 100 || transfer_rate != 1000 || duration_data != 819.2)</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 2 resolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_2b.png</image>
<triggerCondition>task == 2 &amp;&amp; distance_real == 700 &amp;&amp; signal_speed_real == 300000 &amp;&amp; data_quantity == 100 &amp;&amp; transfer_rate == 1000 &amp;&amp; duration_data == 819.2
</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 3 unresolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_3a.png</image>
<triggerCondition>task == 3 &amp;&amp; ( distance_real != 700 || signal_speed_real != 300000 || transfer_rate != 1000 || data_quantity != 50 || duration_data != 409.6 )</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task3 resolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_3b.png</image>
<triggerCondition>task == 3 &amp;&amp; distance_real == 700 &amp;&amp; transfer_rate == 1000 &amp;&amp; data_quantity == 50 &amp;&amp; duration_data == 409.6</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 4 unresolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_4a.png</image>
<triggerCondition>task == 4 &amp;&amp; ( signal_speed_real != 300000 || data_quantity != 200 || transfer_rate != 100 || duration_data != 16384 || duration_signal != 1000 )</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 4 resolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_4b.png</image>
<triggerCondition>task == 4 &amp;&amp; signal_speed_real == 300000 &amp;&amp; data_quantity == 200 &amp;&amp; transfer_rate == 100 &amp;&amp; duration_data == 16384 &amp;&amp; duration_signal == 1000</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 5 unresolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_5a.png</image>
<triggerCondition>task == 5 &amp;&amp; ( signal_speed_real != 300000 || data_quantity != 470 || transfer_rate != 230 || duration_signal != 1000 )</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
<scene>
<name>Task 5 resolved</name>
<image>scenarios/SatelliteCommunication/assets/fixed window_5b.png</image>
<triggerCondition>task == 5 &amp;&amp; signal_speed_real == 300000 &amp;&amp; data_quantity == 470 &amp;&amp; transfer_rate == 230 &amp;&amp; duration_signal == 1000</triggerCondition>
<drawPriority>20</drawPriority>
</scene>
</scenes>
<objects>
<!-- ========================== -->
<!-- Task -->
<!-- ========================== -->
<object>
<type>ValueWidget</type>
<name>Task</name>
<handles>
<handle>0</handle>
</handles>
<variable>
<name>task</name>
<type>numeric</type>
<initial>0</initial>
</variable>
<modifyValueOnRotation>true</modifyValueOnRotation>
<lowerBound>0</lowerBound>
<upperBound>5</upperBound>
<stepSize>1</stepSize>
<lowerStopAngle>0</lowerStopAngle>
<upperStopAngle>3.141592653589793</upperStopAngle>
<coronas>
<corona>
<handle>0</handle>
<type>TextBox</type>
<drawPriority>0</drawPriority>
<rotateWithHandle>false</rotateWithHandle>
<lineWidth>200</lineWidth>
<font>Arial-20</font>
<centred>true</centred>
<assignable>true</assignable>
<initialTranslation>
<x>0</x>
<y>67</y>
<z>0</z>
<state>ScreenCoordinates</state>
</initialTranslation>
</corona>
</coronas>
</object>
<!-- ========================== -->
<!-- Data quantity -->
<!-- ========================== -->
<object>
<type>ValueWidget</type>