Package robot_script :: Package event_simulators :: Module event_simulator :: Class EventSimulator
[hide private]
[frames] | no frames]

Class EventSimulator

source code

        object --+        
                 |        
threading._Verbose --+    
                     |    
      threading.Thread --+
                         |
                        EventSimulator
Known Subclasses:

Superclass for all robot_script event simulation applications. Takes a schedule and a callback, and invokes the callback at times determined by the schedule. Each callback invokation is passed an argument that is specified by the schedule. Example schedule:

           schedule = OrderedDict();
           schedule[2.0] = 'This';
           schedule[5.0] = 'is';
           schedule[6.0] = 'a';
           schedule[7.2] = 'test';

This schedule invokes the callback at 2.0 seconds from program start, and at 5, 6, and 7.2 seconds. The callback argument is the dict value corresponding to the time. See example in __main__.

The simulator runs in a separate thread, which is started by calling start(). Make sure that your subclasses invoked this superclass' start() method.

The callback function may return a value. This value is pushed into an eventQueue that may be access by other applications. Applications may obtain the eventQueue via getEventQueue(). See Python's built-in Queue class for how applications may feed from that queue.

Instance Methods [hide private]
 
start(self, schedule, callback, repeat=False)
Starts the simulator.
source code
 
getEventQueue(self)
Return this event simulator's event queue.
source code
 
run(self)
Thread loop: works through the schedule, sleeping as needed.
source code
 
stop(self) source code
 
sigintHandler(signum, frame) source code

Inherited from threading.Thread: __init__, __repr__, getName, isAlive, isDaemon, is_alive, join, setDaemon, setName

Inherited from threading.Thread (private): _reset_internal_locks, _set_daemon, _set_ident

Inherited from threading._Verbose (private): _note

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from threading.Thread: daemon, ident, name

Inherited from threading.Thread (private): _block

Inherited from object: __class__

Method Details [hide private]

start(self, schedule, callback, repeat=False)

source code 

Starts the simulator.

Parameters:
  • schedule (collections.OrderedDict) - plan with times and callback arguments.
  • callback (callable) - callable to invoke at the times indicated in the schedule.
  • repeat (boolean) - if True, schedule is excecuted over and over.
Overrides: threading.Thread.start

getEventQueue(self)

source code 

Return this event simulator's event queue. This queue is fed with return values from the callbacks.

run(self)

source code 

Thread loop: works through the schedule, sleeping as needed.

Overrides: threading.Thread.run