cat.sensor.core
Class Sensor

java.lang.Object
  extended bycat.sensor.core.Sensor
Direct Known Subclasses:
AndSensor, CallableSensor, LeafSensor

public class Sensor
extends java.lang.Object

This class represents a generic sensor in CAT. The sensor object has information such as id, type, whether it is remote, and a list of listeners who care about this sensors data.


Field Summary
(package private)  boolean remote
          True if the sensor is remote.
private  java.util.Vector senList
          The list of listeners.
(package private)  java.lang.String sensorID
          The sensor id.
(package private)  int sensorType
          The sensor's type.
 
Constructor Summary
Sensor(java.lang.String id)
          This constructor initializes the Sensor object by setting the id.
 
Method Summary
 void addSensorListener(SensorListener s)
          This method adds a listener to this Sensor.
 int countSensorListeners()
          Returns the number of observers of this Observable object.
 void deleteSensorListener(SensorListener s)
          This method removes a listener to this Sensor.
 void deleteSensorListeners()
          This method removes all listeners to this Sensor.
 java.lang.String getID()
          This method returns the id of the sensor.
 int getSensorType()
          This method returns the type of the Sensor.
 boolean isRemote()
          This method returns whether the sensor is remote or not.
 void notifySensorListeners(java.lang.Object event)
          This method notifies all listeners of a Sensor data event.
 void setID(java.lang.String id)
          This method sets the id of the sensor.
 void setRemote(boolean b)
          This method sets whether the sensor is remote or not.
 void setSensorType(int type)
          This method sets the type of the Sensor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sensorID

java.lang.String sensorID
The sensor id.


sensorType

int sensorType
The sensor's type.


remote

boolean remote
True if the sensor is remote.


senList

private java.util.Vector senList
The list of listeners.

Constructor Detail

Sensor

public Sensor(java.lang.String id)
This constructor initializes the Sensor object by setting the id.

Parameters:
id - The sensor's unique id.
Method Detail

setID

public void setID(java.lang.String id)
This method sets the id of the sensor.

Parameters:
id - The sensor's unique id.

getID

public java.lang.String getID()
This method returns the id of the sensor.

Returns:
String The sensor's unique id.

setSensorType

public void setSensorType(int type)
This method sets the type of the Sensor.

Parameters:
type - The sensor's type.

getSensorType

public int getSensorType()
This method returns the type of the Sensor.

Returns:
int The sensor's type.

setRemote

public void setRemote(boolean b)
This method sets whether the sensor is remote or not.

Parameters:
b - True if the sensor is remote.

isRemote

public boolean isRemote()
This method returns whether the sensor is remote or not.

Returns:
boolean True if the sensor is remote.

addSensorListener

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

Parameters:
s - listener.

deleteSensorListener

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

Parameters:
s - listener.

deleteSensorListeners

public void deleteSensorListeners()
This method removes all listeners to this Sensor.


notifySensorListeners

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

Parameters:
event - Sesnor data event.

countSensorListeners

public int countSensorListeners()
Returns the number of observers of this Observable object.

Returns:
the number of observers of this object.