moteaccess
Class TOSMoteAccess

java.lang.Object
  extended bymoteaccess.TOSMoteAccess
All Implemented Interfaces:
IMoteAccess, java.lang.Runnable

public class TOSMoteAccess
extends java.lang.Object
implements IMoteAccess, java.lang.Runnable

Author:
Matteo Giani

Field Summary
private  int baseStationId
           
private  short configNumber
           
static int DEFAULT_CONFIG_REQUEST_TIME_MILLS
           
static int DEFAULT_GROUP_ID
           
private  java.util.Vector finishedRequestIDs
           
private  java.util.HashMap listenerMap
           
private  java.util.HashMap messageMap
           
private  java.util.LinkedList messageQueue
           
private  MoteIF moteif
           
private  boolean quitting
           
private  java.util.Random rand
           
private  java.util.HashMap runningReactions
           
private  java.util.HashMap runningReads
           
private  java.lang.Thread thread
           
private  java.util.HashMap timeouts
           
private  TOSMoteAccessUI ui
           
 
Fields inherited from interface moteaccess.IMoteAccess
DEFAULT_SENSING_TIMEOUT_SECS
 
Constructor Summary
TOSMoteAccess()
          Creates a new TOSMoteAccess object, and tries to initialize MoteIF from TinyOS in order to access the sensor network.
 
Method Summary
 void doRead(RequestID rid, MoteRequest mr_in, IMoteListener ml)
          Method by which the MoteAccess layer is requested to start an unconditional read operation.
 int getParameter(java.lang.String parameter)
           
 void injectReaction(RequestID rid, MoteReaction mr_in, IMoteListener ml)
          Method by which the MoteAccess layer is requested to install a reaction.
 void messageReceived(int dest_addr, Message msg)
           
 void run()
          This is the body of the thread that both sends messages to the sensor network and updates the timeouts.
 boolean setParameter(java.lang.String parameter, int value)
          Method by which parameters at the MoteAccess level can be set.
 void shutdown()
          This method shuts down the TOSMoteAccess, more specifically it lets the message sending Thread know that it's time to die.
private  void stopConfigRequest(ConfigRequestTOSMessage msg)
           
 void stopOperation(RequestID rid)
          Method used to stop a running operation, i.e.
private  void stopRequest(RequestID rid, java.lang.String reason)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONFIG_REQUEST_TIME_MILLS

public static final int DEFAULT_CONFIG_REQUEST_TIME_MILLS
See Also:
Constant Field Values

DEFAULT_GROUP_ID

public static final int DEFAULT_GROUP_ID
See Also:
Constant Field Values

baseStationId

private int baseStationId

moteif

private MoteIF moteif

ui

private TOSMoteAccessUI ui

runningReads

private java.util.HashMap runningReads

runningReactions

private java.util.HashMap runningReactions

messageQueue

private java.util.LinkedList messageQueue

messageMap

private java.util.HashMap messageMap

timeouts

private java.util.HashMap timeouts

listenerMap

private java.util.HashMap listenerMap

finishedRequestIDs

private java.util.Vector finishedRequestIDs

quitting

private boolean quitting

thread

private java.lang.Thread thread

configNumber

private short configNumber

rand

private java.util.Random rand
Constructor Detail

TOSMoteAccess

public TOSMoteAccess()
Creates a new TOSMoteAccess object, and tries to initialize MoteIF from TinyOS in order to access the sensor network.

Method Detail

doRead

public void doRead(RequestID rid,
                   MoteRequest mr_in,
                   IMoteListener ml)
Description copied from interface: IMoteAccess
Method by which the MoteAccess layer is requested to start an unconditional read operation.

Specified by:
doRead in interface IMoteAccess
Parameters:
rid - : the RequestID that the client application has generated.
mr_in - : the MoteRequest object describing the desired reading.
ml - : reference to the IMoteListener implementation to be notified of incoming results.

stopOperation

public void stopOperation(RequestID rid)
Description copied from interface: IMoteAccess
Method used to stop a running operation, i.e. a reading or a reaction.

Specified by:
stopOperation in interface IMoteAccess
Parameters:
rid - : the RequestID identifying the operation to be stopped.

injectReaction

public void injectReaction(RequestID rid,
                           MoteReaction mr_in,
                           IMoteListener ml)
Description copied from interface: IMoteAccess
Method by which the MoteAccess layer is requested to install a reaction.

Specified by:
injectReaction in interface IMoteAccess
Parameters:
rid - : the RequestID that the client application has generated.
mr_in - : the MoteReaction object describing the desired reaction.
ml - : reference to the IMoteListener implementation to be notified of incoming results.

setParameter

public boolean setParameter(java.lang.String parameter,
                            int value)
Description copied from interface: IMoteAccess
Method by which parameters at the MoteAccess level can be set.

Specified by:
setParameter in interface IMoteAccess
Parameters:
parameter - String identifying the parameter to be modified
value - integer to which the parameter has to be set.
Returns:
boolean indicating wheter the update has taken place or not

getParameter

public int getParameter(java.lang.String parameter)

shutdown

public void shutdown()
This method shuts down the TOSMoteAccess, more specifically it lets the message sending Thread know that it's time to die. It is quite useless though, since the underlying MoteIF framework seems to have no way of exiting but a brutal System.exit()... :-(


messageReceived

public void messageReceived(int dest_addr,
                            Message msg)

stopRequest

private void stopRequest(RequestID rid,
                         java.lang.String reason)

stopConfigRequest

private void stopConfigRequest(ConfigRequestTOSMessage msg)

run

public void run()
This is the body of the thread that both sends messages to the sensor network and updates the timeouts.

Specified by:
run in interface java.lang.Runnable