@@ -109,6 +109,14 @@ def kill(self):
109109 self .cmdQueue .put (ExecutionThread .kill )
110110 xLock .release ()
111111
112+ def configure (self , options ):
113+ try :
114+ framerate = options ['framerate' ]
115+ except KeyError :
116+ pass
117+ else :
118+ self .executionThread .setFrameRate (framerate )
119+
112120 def unpause (self ):
113121 xLock .acquire ()
114122 if not self .cmdQueue .empty ():
@@ -151,7 +159,7 @@ def getReport(self, nodeID):
151159class ExecutionThread (Thread ):
152160 def __init__ (self , cmdQueue , master ):
153161 self .graph = None
154-
162+ self . framerate = 0.1
155163 self .master = master
156164 self .paused = True
157165 self .alive = True
@@ -161,6 +169,9 @@ def __init__(self, cmdQueue, master):
161169 # self.updateGraph()
162170 self .start ()
163171
172+ def setFrameRate (self , framerate ):
173+ self .framerate = framerate
174+
164175 def run (self ):
165176 while self .alive :
166177 xLock .acquire ()
@@ -183,7 +194,7 @@ def run(self):
183194 self .executeGraphStepPar ()
184195 self .master .updateRunningNodes (self .graph .runningNodes )
185196 else :
186- time .sleep (.5 )
197+ time .sleep (self . framerate )
187198 print ('That\' s it. I\' m dead.' )
188199
189200 def pause (self ):
@@ -269,32 +280,6 @@ def executeGraphStepPar(self):
269280 print ('Nothing to do here @ {}' .format (time .time ()))
270281 time .sleep (.1 )
271282
272- def execute (self ):
273- """
274- Execute the Graph instance.
275-
276- First, the execution loop will set itself up to terminate after the first iteration.
277- Next, every node is given the chance to run if all prerequisites are met.
278- If a node is executed, the loop termination criterion will be reset to allow an additional iteration over all
279- nodes.
280- If no node is execute during one iteration, the termination criterion will not be reset and the execution loop
281- terminates.
282- :return:
283- """
284- return self .testRun ()
285- running = True
286- i = 0
287- while running :
288- i += 1
289- print ('\n Executing iteration {}.' .format (i ))
290- running = False
291- for node in self .nodes .values ():
292- checked = node .check ()
293- running = checked if not running else True
294- if checked :
295- node .run ()
296- # raise RuntimeError('Uncaught exception while executing node {}.'.format(node))
297- node .notify ()
298283
299284
300285class Listener (Thread ):
@@ -374,6 +359,9 @@ def run(self):
374359 nextID = int (message [4 :])
375360 self .send ('Runner jumping to node {}.' .format (nextID ))
376361 self .master .goto (nextID )
362+ elif message .startswith ('CONFIGURE' ):
363+ msg = message [9 :]
364+ self .master .configure (json .loads (msg ))
377365 elif message == 'STEP' :
378366 self .send ('Runner is performing one step.' )
379367 self .master .step ()
0 commit comments