jhomenet.commons.hw.device
Class Device

java.lang.Object
  extended by Model
      extended by jhomenet.commons.hw.HomenetHardware
          extended by jhomenet.commons.hw.device.Device
All Implemented Interfaces:
java.io.Serializable, Hardware, RegisteredHardware

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

The device class is used as a container for holding information related to devices. Devices are defined as sensors that are used to control other objects, such as switches.

ID: $Id: Device.java 1081 2005-12-22 16:40:22Z dhirwinjr $

Author:
David Irwin (jhomenet at gmail dot com)

Field Summary
protected  State desiredState
          The desired state of the device.
static java.lang.String PROPERTYNAME_CURRENTSTATE
           
 
Fields inherited from class jhomenet.commons.hw.HomenetHardware
hardwareAddr, hardwareSetupDescription, PROPERTYNAME_CHANNELDESC, PROPERTYNAME_HWSETUPDESC
 
Constructor Summary
Device(Device device)
           
Device(java.lang.String hardwareAppDescription, java.lang.Integer numChannels)
           
Device(java.lang.String hardwareAddr, java.lang.String hardwareSetupDescription, java.lang.String hardwareAppDescription, java.lang.Integer numChannels)
          The default constructor the Device object.
 
Method Summary
abstract  void execute()
          Execute the device based on the desired state.
 java.util.Set<State> getAvailableStates()
          Get the list of available states.
 State getCurrentState()
          Get the current state.
protected abstract  void initializeStates(java.util.Set<State> availableStates)
          Initialize the list of states.
protected  void setCurrentState(State state)
          Set the current state of the device.
 void setDesiredState(State state)
          Set the desired state.
 
Methods inherited from class jhomenet.commons.hw.HomenetHardware
addHardwareListener, copy, equals, getAppHardwareDescription, getChannel, getChannelDescription, getChannels, getHardwareAddr, getHardwareClassname, getHardwareSetupDescription, getId, getNumChannels, hashCode, initializeHardware, removeHardwareListener, setChannelDescription, setHardwareSetupDescription, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTYNAME_CURRENTSTATE

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

desiredState

protected State desiredState
The desired state of the device.

Constructor Detail

Device

public Device(java.lang.String hardwareAddr,
              java.lang.String hardwareSetupDescription,
              java.lang.String hardwareAppDescription,
              java.lang.Integer numChannels)
The default constructor the Device object.

Parameters:
hardwareAddr -
hardwareSetupDescription -
hardwareAppDescription -
numChannels -

Device

public Device(java.lang.String hardwareAppDescription,
              java.lang.Integer numChannels)
Parameters:
hardwareAppDescription -
numChannels -

Device

public Device(Device device)
Parameters:
device -
Method Detail

initializeStates

protected abstract void initializeStates(java.util.Set<State> availableStates)
Initialize the list of states.


getAvailableStates

public final java.util.Set<State> getAvailableStates()
Get the list of available states.

Returns:
List of available states

setDesiredState

public void setDesiredState(State state)
Set the desired state. This should be called prior to calling the execute method.

Parameters:
state - The desired state

getCurrentState

public State getCurrentState()
Get the current state.

Returns:
The current state

setCurrentState

protected void setCurrentState(State state)
Set the current state of the device.

Parameters:
state -

execute

public abstract void execute()
Execute the device based on the desired state.



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