jhomenet.hw.sensor
Class Sensor

java.lang.Object
  extended by Model
      extended by jhomenet.hw.HomenetHardware
          extended by jhomenet.hw.sensor.Sensor
All Implemented Interfaces:
java.io.Serializable, Hardware
Direct Known Subclasses:
ConfigurableTestSensor, StateSensor, ValueSensor

public abstract class Sensor
extends HomenetHardware
implements java.io.Serializable

This is the superclass of all sensor hardware as part of the Homenet system. It extends the HomenetHardware class that provides general functionality to all registered hardware. The Sensor class adds additional functionality common to all sensors including reading data from the sensor, storing data, and the sensor polling type.
ID: $Id: Sensor.java,v 1.24 2005/11/10 03:36:00 dhirwinjr Exp $

Author:
David Irwin

Field Summary
protected  HardwareData currentData
          The sensor values and ounded bean data property names.
static float INVALID_DATA
          Define an unknown value
protected  HardwareData maxData
          The sensor values and ounded bean data property names.
protected  HardwareData minData
          The sensor values and ounded bean data property names.
protected  PollingService.PollingTypes pollingType
          The desired polling type of the hardware and binding information
static java.lang.String PROPERTYNAME_CURRENTDATA
           
static java.lang.String PROPERTYNAME_MAXDATA
           
static java.lang.String PROPERTYNAME_MINDATA
           
static java.lang.String PROPERTYNAME_POLLINGTYPE
           
protected  boolean readFailed
          Flag indicating whether the sensor read was successful or not.
 
Fields inherited from class jhomenet.hw.HomenetHardware
configuration, driver, errorTracker, hardwareDescription, hardwareId, PROPERTYNAME_CONFIGURATION, PROPERTYNAME_SETUPDESC, setupDescription
 
Constructor Summary
Sensor()
          Constructor (used when creating the sensor hardware from the persistence layer using Hibernate).
Sensor(java.lang.String hardwareID, java.lang.String description)
          Default constructor.
 
Method Summary
 void capture()
          Reads states from the sensor and in the process stores the data retrieved from the sensor in the jHomeNet database.
 java.lang.String getCurrentAsString()
          Returns the current sensor value as a string (includes the unit).
 HardwareData getCurrentData()
          Return the current hardware data value.
 HardwareData getMaxData()
           
 HardwareData getMinData()
           
 PollingService.PollingTypes getPollingType()
          Get the polling type if the hardware is registered.
 javax.swing.ListModel getPollingTypeListModel()
          Get the polling type list model.
protected  boolean isFirstPoll()
          Whether this is the first time the hardware has been polled.
protected abstract  double readFromDriver()
          Read the raw value from the driver.
abstract  HardwareData readSensor()
          Capture the sensor's data in the sensor's current unit (if applicable).
 void resetData()
          Reset the hardware data values.
protected  void setCurrentData(HardwareData currentData)
          Set the current data value.
protected  void setMaxData(HardwareData maxData)
           
protected  void setMinData(HardwareData minData)
           
 void setPollingType(PollingService.PollingTypes pollingType)
          Set the sensor hardware polling type.
 java.lang.String toString()
          Returns the string equivalent of the sensor.
 
Methods inherited from class jhomenet.hw.HomenetHardware
equals, getConfiguration, getConfiguration, getDriverHardwareDescription, getDriverName, getErrorCount, getHardwareClassname, getHardwareDescription, getHardwareId, getSetupDescription, initializeHardware, initializeHardwareDescription, isRegistered, setConfiguration, setConfiguration, setDriver, setHardwareId, setSetupDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pollingType

protected PollingService.PollingTypes pollingType
The desired polling type of the hardware and binding information


PROPERTYNAME_POLLINGTYPE

public static final java.lang.String PROPERTYNAME_POLLINGTYPE
See Also:
Constant Field Values

INVALID_DATA

public static final float INVALID_DATA
Define an unknown value

See Also:
Constant Field Values

currentData

protected HardwareData currentData
The sensor values and ounded bean data property names.


maxData

protected HardwareData maxData
The sensor values and ounded bean data property names.


minData

protected HardwareData minData
The sensor values and ounded bean data property names.


PROPERTYNAME_CURRENTDATA

public static final java.lang.String PROPERTYNAME_CURRENTDATA
See Also:
Constant Field Values

PROPERTYNAME_MAXDATA

public static final java.lang.String PROPERTYNAME_MAXDATA
See Also:
Constant Field Values

PROPERTYNAME_MINDATA

public static final java.lang.String PROPERTYNAME_MINDATA
See Also:
Constant Field Values

readFailed

protected boolean readFailed
Flag indicating whether the sensor read was successful or not.

Constructor Detail

Sensor

public Sensor(java.lang.String hardwareID,
              java.lang.String description)
Default constructor.

Parameters:
hardwareID - The 1-Wire address of the sensor.
description - The name of the sensor.

Sensor

public Sensor()
Constructor (used when creating the sensor hardware from the persistence layer using Hibernate).

Method Detail

resetData

public void resetData()
Reset the hardware data values.


setPollingType

public void setPollingType(PollingService.PollingTypes pollingType)
Set the sensor hardware polling type.

Parameters:
pollingType -

getPollingType

public PollingService.PollingTypes getPollingType()
Get the polling type if the hardware is registered.

Returns:
The polling type.

getPollingTypeListModel

public javax.swing.ListModel getPollingTypeListModel()
Get the polling type list model.

Returns:

readSensor

public abstract HardwareData readSensor()
                                 throws SensorException
Capture the sensor's data in the sensor's current unit (if applicable).

Returns:
The sensor's data in the sensor's default data unit.
Throws:
SensorException

readFromDriver

protected abstract double readFromDriver()
                                  throws SensorException
Read the raw value from the driver.

Returns:
The raw value read from the driver.
Throws:
SensorException

capture

public void capture()
Reads states from the sensor and in the process stores the data retrieved from the sensor in the jHomeNet database.


isFirstPoll

protected boolean isFirstPoll()
Whether this is the first time the hardware has been polled.

Returns:
True if it's the first time the hardware has been polled

getCurrentAsString

public java.lang.String getCurrentAsString()
Returns the current sensor value as a string (includes the unit).

Returns:
The current value as a string with the current unit value

setCurrentData

protected void setCurrentData(HardwareData currentData)
Set the current data value.

Parameters:
currentData - The current data value

getCurrentData

public HardwareData getCurrentData()
Return the current hardware data value.

Returns:
The current hardware data

getMaxData

public HardwareData getMaxData()

setMaxData

protected void setMaxData(HardwareData maxData)

getMinData

public HardwareData getMinData()

setMinData

protected void setMinData(HardwareData minData)

toString

public java.lang.String toString()
Returns the string equivalent of the sensor.

See Also:
Object.toString()


Copyright © 2004-2005 David Irwin. All Rights Reserved.