jhomenet.hw.device
Class Device

java.lang.Object
  extended by Model
      extended by jhomenet.hw.HomenetHardware
          extended by jhomenet.hw.device.Device
All Implemented Interfaces:
java.io.Serializable, Hardware
Direct Known Subclasses:
LightSwitchDevice, TestDevice

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,v 1.14 2005/11/14 03:47:07 dhirwinjr Exp $

Author:
David Irwin

Field Summary
protected  State desiredState
          The desired state of the device.
static java.lang.String PROPERTYNAME_CURRENTSTATE
           
protected  java.util.Set<State> states
          Keep a list of the device's avaiable states.
 
Fields inherited from class jhomenet.hw.HomenetHardware
configuration, driver, errorTracker, hardwareDescription, hardwareId, PROPERTYNAME_CONFIGURATION, PROPERTYNAME_SETUPDESC, setupDescription
 
Constructor Summary
Device()
          Constructor.
Device(java.lang.String hardwareID, java.lang.String description)
          The default constructor the Device object.
 
Method Summary
abstract  void execute()
          Execute the device based on the desired state.
 State getCurrentState()
          Get the current state.
 java.util.Set<State> getStates()
          Get the list of available states.
protected abstract  void initializeStates()
          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.
 java.lang.String toString()
          Get the string equivalent of the device.
 
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

states

protected java.util.Set<State> states
Keep a list of the device's avaiable states.


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 hardwareID,
              java.lang.String description)
The default constructor the Device object. The constructor initializes the location of the particular device as well as setting the default state to OFF.

Parameters:
hardwareID -
description -

Device

public Device()
Constructor.

Method Detail

initializeStates

protected abstract void initializeStates()
Initialize the list of states.


toString

public java.lang.String toString()
Get the string equivalent of the device.

See Also:
Object.toString()

getStates

public java.util.Set<State> getStates()
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-2005 David Irwin. All Rights Reserved.