net.tinyos.tinydb
Class TinyDBNetwork

java.lang.Object
  |
  +--net.tinyos.tinydb.TinyDBNetwork
All Implemented Interfaces:
net.tinyos.message.MessageListener, QueryListener, java.lang.Runnable

public class TinyDBNetwork
extends java.lang.Object
implements java.lang.Runnable, QueryListener, net.tinyos.message.MessageListener

TinyDBNetwork is responsible for getting and sending results and queries over the network


Field Summary
static byte DATA_MSG_ID
           
static byte MSG_SIZE
           
static byte QUERY_MSG_ID
           
static short UART_ADDR
           
static byte UART_MSG_ID
           
 
Constructor Summary
TinyDBNetwork(net.tinyos.message.MoteIF mif)
          Constructor
 
Method Summary
 void abortQuery(net.tinyos.tinydb.TinyDBQuery query)
          Send message to abort the specified query out over the radio
 void addQuery(net.tinyos.tinydb.TinyDBQuery q)
          A new query has begun running.
 void addResultListener(net.tinyos.tinydb.ResultListener rl)
          Add a listener to be notified when any query result arrives
 void addResultListener(net.tinyos.tinydb.ResultListener rl, boolean aggResults, int qid)
          Add a listener to be notified when a query result for the specified query id arrives
static int getBaseBcastInterval()
          Return baseBcastInterval, which controls how often data messages are sent out from the base station so that nodes can see the root.
 void messageReceived(int addr, net.tinyos.message.Message m)
          Process a radio message Assumes results are QueryResults -- parses them, and maintains the following data structures: - most recent epoch heard for each query - most recent (paritially aggregated) result for each query Notifies ResultListeners for all results every time a value arries Notifies ResultListeners for raw results for a pariticular query id every time a result for that query arrives Notifies ResultListeners for processed results from the current epoch every time a new epoch begins; the aggregate combines results that are from the same epoch and are not obviously bogus (e.g.
 void removeQuery(net.tinyos.tinydb.TinyDBQuery q)
          A query has stopped running
 void removeResultListener(net.tinyos.tinydb.ResultListener rl)
          Remove a specific result listener
 void run()
          Background thread used to periodically send information from the root down into the network; current this information includes: a message index (so that children can choose root as parent) information about the typical number of senders during an epoch (so that children can schedule comm) an epoch number (per query).
 void sendQuery(net.tinyos.tinydb.TinyDBQuery q)
          Send the specified query out over the radio
static void setBaseBcastInterval(int interval)
          Set the base station data message broadcast interval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_MSG_ID

public static final byte QUERY_MSG_ID
See Also:
Constant Field Values

DATA_MSG_ID

public static final byte DATA_MSG_ID
See Also:
Constant Field Values

UART_MSG_ID

public static final byte UART_MSG_ID
See Also:
Constant Field Values

MSG_SIZE

public static final byte MSG_SIZE
See Also:
Constant Field Values

UART_ADDR

public static final short UART_ADDR
See Also:
Constant Field Values
Constructor Detail

TinyDBNetwork

public TinyDBNetwork(net.tinyos.message.MoteIF mif)
Constructor

Parameters:
mif - The MoteIF used to send / receive messages from the motes
Method Detail

addResultListener

public void addResultListener(net.tinyos.tinydb.ResultListener rl,
                              boolean aggResults,
                              int qid)
Add a listener to be notified when a query result for the specified query id arrives

Parameters:
rl - The ResultListener to add
aggResults - Does the listener want processed (e.g. combined aggregate) results, or raw results?
qid - The query id this listener is interested in

addResultListener

public void addResultListener(net.tinyos.tinydb.ResultListener rl)
Add a listener to be notified when any query result arrives

Parameters:
rl - The listener to register

removeResultListener

public void removeResultListener(net.tinyos.tinydb.ResultListener rl)
Remove a specific result listener

Parameters:
rl - The listener to remove

messageReceived

public void messageReceived(int addr,
                            net.tinyos.message.Message m)
Process a radio message Assumes results are QueryResults -- parses them, and maintains the following data structures: - most recent epoch heard for each query - most recent (paritially aggregated) result for each query Notifies ResultListeners for all results every time a value arries Notifies ResultListeners for raw results for a pariticular query id every time a result for that query arrives Notifies ResultListeners for processed results from the current epoch every time a new epoch begins; the aggregate combines results that are from the same epoch and are not obviously bogus (e.g. from a ridiculous epoch number); each group is reported in a different result message.

Specified by:
messageReceived in interface net.tinyos.message.MessageListener

run

public void run()
Background thread used to periodically send information from the root down into the network; current this information includes: a message index (so that children can choose root as parent) information about the typical number of senders during an epoch (so that children can schedule comm) an epoch number (per query).

Specified by:
run in interface java.lang.Runnable

addQuery

public void addQuery(net.tinyos.tinydb.TinyDBQuery q)
A new query has begun running. Use this to track the queries that we need to send data messages for (see run() above.)

Specified by:
addQuery in interface QueryListener

removeQuery

public void removeQuery(net.tinyos.tinydb.TinyDBQuery q)
A query has stopped running

Specified by:
removeQuery in interface QueryListener

sendQuery

public void sendQuery(net.tinyos.tinydb.TinyDBQuery q)
               throws java.io.IOException
Send the specified query out over the radio

java.io.IOException

abortQuery

public void abortQuery(net.tinyos.tinydb.TinyDBQuery query)
Send message to abort the specified query out over the radio


getBaseBcastInterval

public static int getBaseBcastInterval()
Return baseBcastInterval, which controls how often data messages are sent out from the base station so that nodes can see the root.


setBaseBcastInterval

public static void setBaseBcastInterval(int interval)
Set the base station data message broadcast interval