net.tinyos.sim.script.reflect
Class SimObject

java.lang.Object
  |
  +--net.tinyos.sim.script.reflect.SimReflect
        |
        +--net.tinyos.sim.script.reflect.SimObject
Direct Known Subclasses:
Mote

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

The SimObject class provides internal access to simulator objects that are not motes.

New objects are obtained by calling the newSimObject() method on the Sim class.


Constructor Summary
SimObject(net.tinyos.sim.script.ScriptInterpreter interp, net.tinyos.sim.SimDriver driver, int size, double x, double y)
          Constructor that's called by sim.newSimObject()
 
Method Summary
 void addAttribute(java.lang.String name, net.tinyos.sim.Attribute attrib)
          Add the given attribute to the object.
 void addAttributeChangedEvent(net.tinyos.sim.Attribute attrib)
          Register an attribute changed event for the given attribute.
 net.tinyos.sim.Attribute getAttribute(java.lang.String name)
          Return the attribute with the given name.
 java.lang.String getCoord()
          Return the object's coordinates as a string "(x, y)".
 double getDistance(double x, double y)
          Return the distance from this mote to the given coordinates
 double getDistance(int moteID)
          Return the distance from this mote to another.
 double getDistance(net.tinyos.sim.script.reflect.SimObject other)
          Return the distance from this mote to another.
 double getXCoord()
          Return the object's X coordinate.
 double getYCoord()
          Return the object's Y coordinate.
 boolean isSelected()
          Determine if the object is selected.
 void move(double dx, double dy)
          Move the mote in virtual space by a given amount.
 void moveTo(double x, double y)
          Move the mote in virtual space to the given location
 void removeAttribute(java.lang.String name)
          Remove the given attribute from the object.
 void setCoord(double x, double y)
          Move the mote in virtual space to the given location.
 void setSelected()
          Add the object to the selected set.
 void setUnselected()
          Remove the object from the selected set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimObject

public SimObject(net.tinyos.sim.script.ScriptInterpreter interp,
                 net.tinyos.sim.SimDriver driver,
                 int size,
                 double x,
                 double y)
Constructor that's called by sim.newSimObject()

Method Detail

addAttribute

public void addAttribute(java.lang.String name,
                         net.tinyos.sim.Attribute attrib)
Add the given attribute to the object.

Parameters:
name - the name of the attribute
attrib - the attribute

getAttribute

public net.tinyos.sim.Attribute getAttribute(java.lang.String name)
Return the attribute with the given name.

Parameters:
name - the name of the attribute
Returns:
the attribute

removeAttribute

public void removeAttribute(java.lang.String name)
Remove the given attribute from the object.

Parameters:
name - the name of the attribute

addAttributeChangedEvent

public void addAttributeChangedEvent(net.tinyos.sim.Attribute attrib)
Register an attribute changed event for the given attribute.

Parameters:
attrib - the attribute

getCoord

public java.lang.String getCoord()
Return the object's coordinates as a string "(x, y)".


getXCoord

public double getXCoord()
Return the object's X coordinate.


getYCoord

public double getYCoord()
Return the object's Y coordinate.


getDistance

public double getDistance(net.tinyos.sim.script.reflect.SimObject other)
Return the distance from this mote to another.

Parameters:
other - the other Mote instance

getDistance

public double getDistance(int moteID)
Return the distance from this mote to another.

Parameters:
moteID - the other Mote id

getDistance

public double getDistance(double x,
                          double y)
Return the distance from this mote to the given coordinates

Parameters:
x - the X coordinate of the target point
y - the Y coordinate of the target point

move

public void move(double dx,
                 double dy)
Move the mote in virtual space by a given amount.

Parameters:
dx - distance to move in the X direction
dy - distance to move in the Y direction

moveTo

public void moveTo(double x,
                   double y)
Move the mote in virtual space to the given location

Parameters:
x - new X coordinate
y - new Y coordinate

setCoord

public void setCoord(double x,
                     double y)
Move the mote in virtual space to the given location. Analogous to moveTo().

Parameters:
x - new X coordinate
y - new Y coordinate

isSelected

public boolean isSelected()
Determine if the object is selected.


setSelected

public void setSelected()
Add the object to the selected set.


setUnselected

public void setUnselected()
Remove the object from the selected set.