cat.hist
Class HistoryManager

java.lang.Object
  extended bycat.hist.HistoryManager
All Implemented Interfaces:
java.lang.Runnable, SensorListener

public class HistoryManager
extends java.lang.Object
implements SensorListener

This class is the Manager of the History of sensor data. All sensor is stored by this manager into ClientApplication. All sensor data can also be queried through the ClientApplication by this manager. Currently ClientApplication uses a local database for storing data, however, this can easy be modified to a remote db, or other storage mechanisms if necessary.


Field Summary
private  ClientApplication ca
          This is the object used to store retrieve sensor data.
private  java.util.Vector eventsQueue
          Holds all sensor data events to be processed.
 
Constructor Summary
HistoryManager()
          This constructor starts the manager to get ready to process sensor data events.
 
Method Summary
 java.util.Vector[] query(java.lang.String id, int type)
          Use this method to retrieve the sensor data for the given sensor for all times.
 java.lang.Object query(java.lang.String id, int type, java.util.Calendar endtime)
          Use this method to retrieve the sensor data for the given sensor that is closest to the given time.
 void run()
          This method is for processing any and all sensor data that occurs in CAT.
 void update(java.lang.Object event)
          Being an Observer, we must implement this method to get sensor events from those that we observe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventsQueue

private java.util.Vector eventsQueue
Holds all sensor data events to be processed.


ca

private ClientApplication ca
This is the object used to store retrieve sensor data.

Constructor Detail

HistoryManager

public HistoryManager()
This constructor starts the manager to get ready to process sensor data events. And it prepares the client for storing and retrieving data.

Method Detail

query

public java.lang.Object query(java.lang.String id,
                              int type,
                              java.util.Calendar endtime)
Use this method to retrieve the sensor data for the given sensor that is closest to the given time.

Parameters:
id - The sensor id of the desired data.
type - The type of the sensor data.
endtime - The nearest time of the data.
Returns:
Object The sensor data object or null if doesn't exist.

query

public java.util.Vector[] query(java.lang.String id,
                                int type)
Use this method to retrieve the sensor data for the given sensor for all times.

Parameters:
id - The sensor id of the desired data.
type - The type of the sensor data.
Returns:
Vector[] The array contain two vectors of the desired sensor data (values and times).

run

public void run()
This method is for processing any and all sensor data that occurs in CAT.

Specified by:
run in interface java.lang.Runnable

update

public void update(java.lang.Object event)
Being an Observer, we must implement this method to get sensor events from those that we observe.

Specified by:
update in interface SensorListener
Parameters:
event - The incoming sensor event.