net.tinyos.sim.script.reflect
Class Sim

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

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

The Sim class controls high-level operations on the simulation, including pause/resume and execution control.

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


Field Summary
 net.tinyos.sim.SimDriver __driver
          Backdoor handle on the SimDriver internal object.
 java.lang.String[] argv
          Array version of the arguments passed in the -scriptargs command line argument.
 
Constructor Summary
Sim(net.tinyos.sim.script.ScriptInterpreter interp, net.tinyos.sim.SimDriver driver)
          Constructor for the Sim object.
 
Method Summary
 void dumpDBG(java.lang.String filename)
          Starts dumping debug messages to the given file.
 void exec(java.lang.String executable, int numMotes)
          Run the simulator and block until the driver connects.
 void exec(java.lang.String executable, int numMotes, java.lang.String args)
          Run the simulator and block until the driver connects.
 void exit()
          Exits the simulator environment with an error code of 0.
 void exit(int errcode)
          Exits the simulator environment with the given error code.
 long getTossimTime()
          Returns the current simulator time.
 int getWorldHeight()
          Returns the height of the simulator 'world' in logical space units.
 int getWorldWidth()
          Returns the width of the simulator 'world' in logical space units.
 boolean isPaused()
          Indicates whether or not the simulator is paused.
 void loadPlugin(java.lang.String pluginName)
          Load the requested plugin.
 net.tinyos.sim.script.reflect.SimObject newSimObject()
          Create a new generic SimObject.
 net.tinyos.sim.script.reflect.SimObject newSimObject(int size, double x, double y)
          Create a new generic SimObject.
 void pause()
          Pauses the simulation.
 void reset()
          Reset the simulator, stopping the current simulation process and clearing out all internal state.
 void resume()
          Resumes the simulation.
 void setSimDelay(long delay_ms)
          Sets the logical simulator delay.
 void stop()
          Stops the simulator execution.
 void stopDBGDump()
          Stops dumping debug messages.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__driver

public net.tinyos.sim.SimDriver __driver
Backdoor handle on the SimDriver internal object. This should not be used in scripts and will likely disappear in a future release.


argv

public java.lang.String[] argv
Array version of the arguments passed in the -scriptargs command line argument.

Constructor Detail

Sim

public Sim(net.tinyos.sim.script.ScriptInterpreter interp,
           net.tinyos.sim.SimDriver driver)
Constructor for the Sim object. This should not be called explicitly, rather the pre-constructed instance sim should be used.

Method Detail

pause

public void pause()
Pauses the simulation.


resume

public void resume()
Resumes the simulation.


isPaused

public boolean isPaused()
Indicates whether or not the simulator is paused.


stop

public void stop()
Stops the simulator execution.


getWorldWidth

public int getWorldWidth()
Returns the width of the simulator 'world' in logical space units.


getWorldHeight

public int getWorldHeight()
Returns the height of the simulator 'world' in logical space units.


getTossimTime

public long getTossimTime()
Returns the current simulator time. More accurately, this reflects the timestamp carried in the last event to arrive from the simulator.


exit

public void exit(int errcode)
Exits the simulator environment with the given error code.

Parameters:
errcode - the exit status code

exit

public void exit()
Exits the simulator environment with an error code of 0.


setSimDelay

public void setSimDelay(long delay_ms)
Sets the logical simulator delay.

Parameters:
delay_ms - delay in milliseconds

dumpDBG

public void dumpDBG(java.lang.String filename)
             throws java.io.IOException
Starts dumping debug messages to the given file.

Parameters:
filename - path to the file for debug output
java.io.IOException

stopDBGDump

public void stopDBGDump()
                 throws java.io.IOException
Stops dumping debug messages.

java.io.IOException

exec

public void exec(java.lang.String executable,
                 int numMotes,
                 java.lang.String args)
          throws java.io.IOException
Run the simulator and block until the driver connects.

Parameters:
executable - path to the executable
numMotes - number of motes to run
args - argument string
java.io.IOException

exec

public void exec(java.lang.String executable,
                 int numMotes)
          throws java.io.IOException
Run the simulator and block until the driver connects.

Parameters:
executable - path to the executable
numMotes - number of motes to run
java.io.IOException

reset

public void reset()
Reset the simulator, stopping the current simulation process and clearing out all internal state.


newSimObject

public net.tinyos.sim.script.reflect.SimObject newSimObject(int size,
                                                            double x,
                                                            double y)
Create a new generic SimObject.


newSimObject

public net.tinyos.sim.script.reflect.SimObject newSimObject()
Create a new generic SimObject.


loadPlugin

public void loadPlugin(java.lang.String pluginName)
Load the requested plugin.