cat.sensor.core
Class SensorManager

java.lang.Object
  extended bycat.sensor.core.SensorManager

public class SensorManager
extends java.lang.Object

This CAT manager sets up and controls all sensors in CAT. It inits all the basic sensors, and provides tools for adding/removing and finding sensors.


Field Summary
private  java.util.Vector appList
          list of applications that want to know if a sensor has been added or removed the members MUST implement SensorListener.
private  java.util.Vector senList
          List of sensors that want notifications from this manager.
private  SocketReceiver sr
          This object is used for connecting sensor proxies to simulator.
private  java.util.HashMap table
          Contains all sensors and their ids
 
Constructor Summary
SensorManager()
          This constructor inits the manager by calling init.
 
Method Summary
 void addLeafSensor(java.lang.String id, LeafSensor sensor)
          This method is for adding a LeafSensor into CAT.
 void addLeafSensor(java.lang.String id, LeafSensor sensor, SensorProxy sp1)
          This method is for adding a LeafSensor into CAT.
 void addSensor(java.lang.String id, Sensor sensor)
          This method is for adding a SoftSensor into CAT.
 void addSensorListener(SensorListener s)
          This method adds a listener to this manager.
 void deleteSensorListener(SensorListener s)
          This method removes a listener to this manager.
 Sensor[] getAllSensors()
          Returns an array of all the sensors that this Manager has (which is all sensors in CAT).
 Sensor getSensor(java.lang.String id)
          Returns the sensor which has the desired id.
 void init()
          This method creates and adds as many basic LeafSensors as it can to CAT.
 void notifySensorListeners(java.lang.Object event)
          This method notifies all listeners of a Sensor data event that this manager observes.
 Sensor removeSensor(java.lang.String id)
          This method is for removing the Sensor with the given id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

private java.util.HashMap table
Contains all sensors and their ids


appList

private java.util.Vector appList
list of applications that want to know if a sensor has been added or removed the members MUST implement SensorListener.


senList

private java.util.Vector senList
List of sensors that want notifications from this manager.


sr

private SocketReceiver sr
This object is used for connecting sensor proxies to simulator. TODO: need additional objects for connect sensor proxies to real hardware sensors.

Constructor Detail

SensorManager

public SensorManager()
This constructor inits the manager by calling init.

Method Detail

init

public void init()
This method creates and adds as many basic LeafSensors as it can to CAT. SoftSensors should be created by CAT application only.


getAllSensors

public Sensor[] getAllSensors()
Returns an array of all the sensors that this Manager has (which is all sensors in CAT).


getSensor

public Sensor getSensor(java.lang.String id)
Returns the sensor which has the desired id.


addSensor

public void addSensor(java.lang.String id,
                      Sensor sensor)
This method is for adding a SoftSensor into CAT. It is up to whomever using this method to sign up listeners.

Parameters:
id - The sensor's id.
sensor - The soft sensor to add.

addLeafSensor

public void addLeafSensor(java.lang.String id,
                          LeafSensor sensor)
This method is for adding a LeafSensor into CAT. This method will connect the LeafSensor to the SensorProxy. (Uses simulator proxy)

Parameters:
id - The sensor's id.
sensor - The leaf sensor to add.

addLeafSensor

public void addLeafSensor(java.lang.String id,
                          LeafSensor sensor,
                          SensorProxy sp1)
This method is for adding a LeafSensor into CAT. This method will connect the LeafSensor to the supplied SensorProxy.

Parameters:
id - The sensor's id.
sensor - The leaf sensor to add.
sp1 - The proxy for the sensor to use to get data.

removeSensor

public Sensor removeSensor(java.lang.String id)
This method is for removing the Sensor with the given id.

Parameters:
id - The sensor's id.

addSensorListener

public void addSensorListener(SensorListener s)
This method adds a listener to this manager.

Parameters:
s - listener.

deleteSensorListener

public void deleteSensorListener(SensorListener s)
This method removes a listener to this manager.

Parameters:
s - listener.

notifySensorListeners

public void notifySensorListeners(java.lang.Object event)
This method notifies all listeners of a Sensor data event that this manager observes.

Parameters:
event - Sesnor data event.