|
@@ -504,7 +504,7 @@ class EventLoop:
|
|
|
if now - self.last_print > 1.0:
|
|
|
behind_schedule = now - simulated_now
|
|
|
if behind_schedule > 0.1:
|
|
|
- print "Warning: running %.f ms behind schedule" % (behind_schedule*1000.0)
|
|
|
+ print("Warning: running %.f ms behind schedule" % (behind_schedule*1000.0))
|
|
|
self.last_print = now
|
|
|
if self.last_time:
|
|
|
delta = simulated_now - self.last_time
|
|
@@ -573,20 +573,20 @@ class ThreadsControllerBase(ControllerBase):
|
|
|
|
|
|
def handleInput(self, delta):
|
|
|
with self.input_condition:
|
|
|
- ControllerBase.handleInput(self, delta)
|
|
|
+ ControllerBase.handleInput(self, delta)
|
|
|
|
|
|
def start(self):
|
|
|
self.thread.start()
|
|
|
|
|
|
def stop(self):
|
|
|
with self.input_condition:
|
|
|
- self.stop_thread = True
|
|
|
- self.input_condition.notifyAll()
|
|
|
+ self.stop_thread = True
|
|
|
+ self.input_condition.notifyAll()
|
|
|
|
|
|
def getWaitTime(self):
|
|
|
"""Compute time untill earliest next event"""
|
|
|
with self.input_condition:
|
|
|
- wait_time = ControllerBase.getWaitTime(self)
|
|
|
+ wait_time = ControllerBase.getWaitTime(self)
|
|
|
|
|
|
if wait_time == INFINITY :
|
|
|
if self.done :
|
|
@@ -598,20 +598,20 @@ class ThreadsControllerBase(ControllerBase):
|
|
|
|
|
|
def handleWaiting(self):
|
|
|
with self.input_condition:
|
|
|
- wait_time = self.getWaitTime()
|
|
|
- if(wait_time <= 0.0):
|
|
|
- return
|
|
|
-
|
|
|
- if wait_time == INFINITY :
|
|
|
- if self.keep_running :
|
|
|
- self.input_condition.wait() #Wait for a signals
|
|
|
- else :
|
|
|
- self.stop_thread = True
|
|
|
-
|
|
|
- elif wait_time != 0.0 :
|
|
|
- reduced_wait_time = wait_time - (time() - self.last_recorded_time)
|
|
|
- if reduced_wait_time > 0.0 :
|
|
|
- self.input_condition.wait(reduced_wait_time)
|
|
|
+ wait_time = self.getWaitTime()
|
|
|
+ if(wait_time <= 0.0):
|
|
|
+ return
|
|
|
+
|
|
|
+ if wait_time == INFINITY :
|
|
|
+ if self.keep_running :
|
|
|
+ self.input_condition.wait() #Wait for a signals
|
|
|
+ else :
|
|
|
+ self.stop_thread = True
|
|
|
+
|
|
|
+ elif wait_time != 0.0 :
|
|
|
+ reduced_wait_time = wait_time - (time() - self.last_recorded_time)
|
|
|
+ if reduced_wait_time > 0.0 :
|
|
|
+ self.input_condition.wait(reduced_wait_time)
|
|
|
|
|
|
def run(self):
|
|
|
self.last_recorded_time = time()
|
|
@@ -620,15 +620,15 @@ class ThreadsControllerBase(ControllerBase):
|
|
|
|
|
|
while True:
|
|
|
with self.input_condition:
|
|
|
- self.handleInput(last_iteration_time)
|
|
|
+ self.handleInput(last_iteration_time)
|
|
|
#Compute the new state based on internal events
|
|
|
self.object_manager.stepAll(last_iteration_time)
|
|
|
|
|
|
self.handleWaiting()
|
|
|
|
|
|
with self.input_condition:
|
|
|
- if self.stop_thread :
|
|
|
- break
|
|
|
+ if self.stop_thread :
|
|
|
+ break
|
|
|
|
|
|
previous_recorded_time = self.last_recorded_time
|
|
|
self.last_recorded_time = time()
|
|
@@ -639,12 +639,12 @@ class ThreadsControllerBase(ControllerBase):
|
|
|
|
|
|
def addInput(self, input_event, time_offset = 0.0):
|
|
|
with self.input_condition:
|
|
|
- super(ThreadsControllerBase, self).addInput(input_event, time_offset)
|
|
|
- self.input_condition.notifyAll()
|
|
|
+ super(ThreadsControllerBase, self).addInput(input_event, time_offset)
|
|
|
+ self.input_condition.notifyAll()
|
|
|
|
|
|
def addEventList(self, event_list):
|
|
|
with self.input_condition:
|
|
|
- super(ThreadsControllerBase, self).addEventList(event_list)
|
|
|
+ super(ThreadsControllerBase, self).addEventList(event_list)
|
|
|
|
|
|
class StatechartSemantics:
|
|
|
# Big Step Maximality
|
|
@@ -722,7 +722,7 @@ class RuntimeClassBase(object):
|
|
|
if not self.is_stable:
|
|
|
return 0.0
|
|
|
if self.timers:
|
|
|
- return min(self.events.getEarliestTime(), min(self.timers.itervalues()))
|
|
|
+ return min(self.events.getEarliestTime(), min(self.timers.values()))
|
|
|
return self.events.getEarliestTime()
|
|
|
|
|
|
def processBigStepOutput(self):
|
|
@@ -740,7 +740,7 @@ class RuntimeClassBase(object):
|
|
|
|
|
|
# decrease timers time
|
|
|
next_timers = {}
|
|
|
- for (key,value) in self.timers.iteritems() :
|
|
|
+ for (key,value) in self.timers.items() :
|
|
|
time = value - delta
|
|
|
if time <= 0.0 :
|
|
|
self.addEvent( Event("_" + str(key) + "after"), time)
|
|
@@ -758,7 +758,7 @@ class RuntimeClassBase(object):
|
|
|
self.processBigStepOutput()
|
|
|
|
|
|
def inState(self, nodes):
|
|
|
- for c in self.current_state.itervalues():
|
|
|
+ for c in self.current_state.values():
|
|
|
new_nodes = []
|
|
|
for n in nodes:
|
|
|
if not (n in c):
|