net.tinyos.sim.script.reflect
Class Interp

java.lang.Object
  |
  +--net.tinyos.sim.script.reflect.SimReflect
        |
        +--net.tinyos.sim.script.reflect.Interp

public class Interp
extends net.tinyos.sim.script.reflect.SimReflect

The Interp class controls operations on the python interpreter, specifically the management of events.

The class is bound into the simcore module as the interp global instance.


Constructor Summary
Interp(net.tinyos.sim.script.ScriptInterpreter interp, net.tinyos.sim.SimDriver driver)
           
 
Method Summary
 int addEventHandler(org.python.core.PyFunction callback)
          Equivalent to addEventHandler(callback, null);
 int addEventHandler(org.python.core.PyFunction callback, org.python.core.PyJavaClass eventclass)
          Registers a given python function as a callback.
 int getInterruptID()
          Get a unique interrupt ID.
 void interruptInFuture(long time, int interruptID)
          Schedule an interrupt event.
 void removeEventHandler(int id)
          Removes the previously registered handler.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interp

public Interp(net.tinyos.sim.script.ScriptInterpreter interp,
              net.tinyos.sim.SimDriver driver)
Method Detail

addEventHandler

public int addEventHandler(org.python.core.PyFunction callback,
                           org.python.core.PyJavaClass eventclass)
                    throws java.lang.ClassNotFoundException
Registers a given python function as a callback. If eventClass is non-null, then only events of that particular subclass of net.tinyos.sim.event will call the callback. If null, the callback is called for all events.

Parameters:
callback - python function to call on matching events
Returns:
unique id for the event handler
java.lang.ClassNotFoundException

addEventHandler

public int addEventHandler(org.python.core.PyFunction callback)
Equivalent to addEventHandler(callback, null);


removeEventHandler

public void removeEventHandler(int id)
Removes the previously registered handler.

Parameters:
id - event handler id to remove

getInterruptID

public int getInterruptID()
Get a unique interrupt ID.


interruptInFuture

public void interruptInFuture(long time,
                              int interruptID)
                       throws java.io.IOException
Schedule an interrupt event.

Parameters:
time - simulator time when to do the operation
interruptID - id code for the interrupt event
java.io.IOException