avrora.sim
Class Simulation.Node

java.lang.Object
  extended byavrora.sim.Simulation.Node
Direct Known Subclasses:
SensorSimulation.SensorNode
Enclosing class:
Simulation

public class Simulation.Node
extends java.lang.Object

The Node class represents a node in a simulation, which has an ID and a program to be loaded onto it. It also has a PlatformFactory instance that is used to create the actual Simulator object when the simulation is begun.


Field Summary
 int id
           
protected  java.util.LinkedList monitors
           
protected  LoadableProgram path
           
protected  Platform platform
           
protected  PlatformFactory platformFactory
           
protected  Simulator simulator
           
protected  SimulatorThread thread
           
 
Constructor Summary
protected Simulation.Node(int id, PlatformFactory pf, LoadableProgram p)
          The constructor for the Node class creates a representation of a new node that includes its id, a factory capable of creating a platform instance (i.e. microcontroller with attached devices) and the program to be loaded onto the node.
 
Method Summary
 void addMonitor(Simulation.Monitor f)
          The addMonitor() method is called by a Monitor when it attaches itself to this node.
 java.util.List getMonitors()
          The getMonitors() method gets a list of monitors that are attached to this node.
 LoadableProgram getProgram()
          The getProgram() method return a reference to the loadable program for this node.
 Simulation getSimulation()
          The getSimulation() method returns a reference to the simulation instance which this node is a part of.
 Simulator getSimulator()
          The getSimulator() method returns the simulator instance for this node while it is executing.
 SimulatorThread getThread()
           
protected  void instantiate()
          The instantiate() method is called when the simulation begins.
protected  void remove()
          The remove() method is called on a node when it is being removed from the simulation.
 void removeMonitor(Simulation.Monitor f)
          The removeMonitor() method is called by a Monitor when it removes itself from this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public final int id

path

protected final LoadableProgram path

platformFactory

protected final PlatformFactory platformFactory

monitors

protected final java.util.LinkedList monitors

platform

protected Platform platform

simulator

protected Simulator simulator

thread

protected SimulatorThread thread
Constructor Detail

Simulation.Node

protected Simulation.Node(int id,
                          PlatformFactory pf,
                          LoadableProgram p)
The constructor for the Node class creates a representation of a new node that includes its id, a factory capable of creating a platform instance (i.e. microcontroller with attached devices) and the program to be loaded onto the node. The constructor does not yet instantiate the node, but leaves the node in an unconstructed state (i.e. the simulator and microcontroller and external devices for the node have not been allocated and initialized yet).

Parameters:
id - the unique id of the node
pf - the platform factory that will be used to instantiate the node
p - the program to load onto the microcontroller
Method Detail

instantiate

protected void instantiate()
The instantiate() method is called when the simulation begins. When the node is created (i.e the constructor is called), it is left in an unconstructed state. The role of this method is to create the simulator, the microcontroller, and external devices for the node that will be actually executing in the simulation.


getSimulator

public Simulator getSimulator()
The getSimulator() method returns the simulator instance for this node while it is executing. When the node is not currently executing (i.e. the simulation has not started yet), this method will return null.

Returns:
the simulator instance for this node if the simulation has started; null otherwise

getSimulation

public Simulation getSimulation()
The getSimulation() method returns a reference to the simulation instance which this node is a part of.

Returns:
a reference to the simulation instance that this node is a part of

addMonitor

public void addMonitor(Simulation.Monitor f)
The addMonitor() method is called by a Monitor when it attaches itself to this node. More specifically, the model is that a Monitor is attached to a list of nodes; the monitor itself decides which of those nodes to attach to and, for each one, calls this method.

Parameters:
f - the monitor being added to this node

removeMonitor

public void removeMonitor(Simulation.Monitor f)
The removeMonitor() method is called by a Monitor when it removes itself from this node.

Parameters:
f - the monitor being removed from this node

getMonitors

public java.util.List getMonitors()
The getMonitors() method gets a list of monitors that are attached to this node.

Returns:
a list of monitors currently attached to this node

getProgram

public LoadableProgram getProgram()
The getProgram() method return a reference to the loadable program for this node.

Returns:
a reference to the loadable program for this node

remove

protected void remove()
The remove() method is called on a node when it is being removed from the simulation.


getThread

public SimulatorThread getThread()