|
@@ -1,13 +1,17 @@
|
|
|
import abc
|
|
|
import re
|
|
|
-from accurate_time import time
|
|
|
+from kernel.mvk_server.python_runtime.accurate_time import time
|
|
|
import threading
|
|
|
import traceback
|
|
|
import math
|
|
|
-from nextafter import nextafter
|
|
|
-from infinity import INFINITY
|
|
|
-from event_queue import EventQueue
|
|
|
-from Queue import Queue, Empty
|
|
|
+from kernel.mvk_server.python_runtime.nextafter import nextafter
|
|
|
+from kernel.mvk_server.python_runtime.infinity import INFINITY
|
|
|
+from kernel.mvk_server.python_runtime.event_queue import EventQueue
|
|
|
+
|
|
|
+try:
|
|
|
+ from Queue import Queue, Empty
|
|
|
+except ImportError:
|
|
|
+ from queue import Queue, Empty
|
|
|
|
|
|
class RuntimeException(Exception):
|
|
|
def __init__(self, message):
|
|
@@ -504,7 +508,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
|
|
@@ -639,12 +643,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 +726,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 +744,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 +762,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):
|