cat.sensor.soft
Class AndSensor

java.lang.Object
  extended bycat.sensor.core.Sensor
      extended bycat.sensor.soft.AndSensor
All Implemented Interfaces:
java.lang.Runnable, SensorListener

public class AndSensor
extends Sensor
implements SensorListener

This is a Soft Sensor. It is a sensor/service which takes input from real physical sensors, and does some manipulation with the data before passing it on as new sensor data. This soft sensor listens to light and sound sensors, and if sound is above 40dB and light is more than 50%, then true is output.


Field Summary
private  java.util.Vector eventsQueue
          The queue of incoming sensor data.
private  boolean[] state
          An array of the most current sensor data from the sensors that this soft sensor listens to.
 
Fields inherited from class cat.sensor.core.Sensor
 
Constructor Summary
AndSensor(java.lang.String id)
          This constructor sets the id of this sensor, and then starts the thread to process any incoming sensor data that this sensor listens to.
 
Method Summary
 void run()
          Checks for any new sensor data and processes it to create new sensor data which this sensor outputs.
 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 cat.sensor.core.Sensor
addSensorListener, countSensorListeners, deleteSensorListener, deleteSensorListeners, getID, getSensorType, isRemote, notifySensorListeners, setID, setRemote, setSensorType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

private boolean[] state
An array of the most current sensor data from the sensors that this soft sensor listens to.


eventsQueue

private java.util.Vector eventsQueue
The queue of incoming sensor data.

Constructor Detail

AndSensor

public AndSensor(java.lang.String id)
This constructor sets the id of this sensor, and then starts the thread to process any incoming sensor data that this sensor listens to.

Parameters:
id - The unique id of this sensor.
Method Detail

run

public void run()
Checks for any new sensor data and processes it to create new sensor data which this sensor outputs.

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.