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

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/whitebackground.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>true</triggerCondition>
<drawPriority>1</drawPriority>
</scene>
</scenes>
<objects>
</objects>
<system>
<outputs>
<output>
<name>AllVariablesInOneEquation</name>
<unit />
</output>
</outputs>
<equations>
<equation>
<name>AllVariablesInOneEquation</name>
<invoke>0</invoke>
<parameters>
</parameters>
<results>
<result>
<name>AllVariablesInOneEquation</name>
</result>
</results>
</equation>
</equations>
</system>
</scenario>
\ No newline at end of file
......@@ -271,7 +271,8 @@ public class Scene extends Content implements Drawable {
/** {@inheritDoc} */
@Override
public int getDrawPriority() {
return this.getDrawPriority();
// return this.getDrawPriority();
return drawPriority;
}
......
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