org.openuat.sensors
Class DeviceStateListener

java.lang.Object
  extended by org.openuat.sensors.DeviceStateListener

public abstract class DeviceStateListener
extends java.lang.Object

This is a small helper class for checking the status of a device with multiple lines/time series based on the events fired by its SampleSource objects. A device is defined to be active when at least one of its lines is active. It calls the abstract functions toActive and toPassive when the device state changes, and forwards all samples via calls to addSample.

Version:
1.0
Author:
Rene Mayrhofer

Constructor Summary
DeviceStateListener(int numLines)
          Constructs the device listener objects.
 
Method Summary
 SamplesSink_Int[] getSinks_Int()
          Returns an array of SampleSink_Int implementations that can be registered with the respective source of sample events.
 SamplesSink[] getSinks()
          Returns an array of SampleSink implementations that can be registered with the respective source of sample events.
 void reset()
          Resets the time series to the state as created when freshly constructing it (i.e. quiescent).
protected abstract  void sampleAdded(int lineIndex, double sample, int numSample)
          This method will be called when a new sample is received.
protected abstract  void sampleAdded(int lineIndex, int sample, int numSample)
          This method will be called when a new sample is received.
protected abstract  void toActive(int changedLineIndex, int numSample)
          This method will be called when the device was quiescent and became active with the last sample.
protected abstract  void toQuiescent(int changedLineIndex, int numSample)
          This method will be called when the device was active and became quiescent with the last sample.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeviceStateListener

public DeviceStateListener(int numLines)
Constructs the device listener objects.

Parameters:
numLines - The number of lines/time series this device has.
Method Detail

getSinks

public SamplesSink[] getSinks()
Returns an array of SampleSink implementations that can be registered with the respective source of sample events.

Returns:
An array of SampleSink objects with length numLines as passed to the constructor.

getSinks_Int

public SamplesSink_Int[] getSinks_Int()
Returns an array of SampleSink_Int implementations that can be registered with the respective source of sample events.

Returns:
An array of SampleSink objects with length numLines as passed to the constructor.

reset

public void reset()
Resets the time series to the state as created when freshly constructing it (i.e. quiescent).


toActive

protected abstract void toActive(int changedLineIndex,
                                 int numSample)
This method will be called when the device was quiescent and became active with the last sample.

Parameters:
changedLineIndex - The line/time series index that caused the change from quiescent to active, i.e. the first line/time series index that became active.
numSample - The number of the sample within the time series that caused the state change.

toQuiescent

protected abstract void toQuiescent(int changedLineIndex,
                                    int numSample)
This method will be called when the device was active and became quiescent with the last sample.

Parameters:
changedLineIndex - The line/time series index that caused the change from active to quiescent, i.e. the last line/time series index that became quiescent.
numSample - The number of the sample within the time series that caused the state change.

sampleAdded

protected abstract void sampleAdded(int lineIndex,
                                    double sample,
                                    int numSample)
This method will be called when a new sample is received.

Parameters:
lineIndex - The line/time series that received the sample.
sample - The sample value.
numSample - The number of the sample within the time series.

sampleAdded

protected abstract void sampleAdded(int lineIndex,
                                    int sample,
                                    int numSample)
This method will be called when a new sample is received. This uses integer samples and is called when DeviceStateListener is used as a SamplesSink_Int.

Parameters:
lineIndex - The line/time series that received the sample.
sample - The sample value.
numSample - The number of the sample within the time series.


2005-2006, Rene Mayrhofer.