sophware.home.lang
Class Home

java.lang.Object
  extended by sophware.home.lang.Home
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NetworkHome

public class Home
extends java.lang.Object
implements java.io.Serializable

Home is the central object that defines your automated network.

This class contains a collection of HomeDevices and processes all automation events.

The HomeStorage is a container for all of the objects.

The Home transmits HomeCommands and receives HomeEvents.

Version:
1.0, 03/19/07
Author:
Russell Soph
See Also:
HomeStorage, Home, Serialized Form

Field Summary
protected  HomeStorage m_database
           
static java.io.PrintStream m_errorStream
          The error stream to which all error messages are written
protected static Home m_me
           
protected  HomeReceiver m_receiver
           
protected static HomeTransmitter m_transmitter
           
 
Constructor Summary
Home(HomeReceiver receiver)
          Creates a Home with a receiver.
Home(HomeReceiver receiver, HomeStorage store)
          Creates a Home with a receiver and storage.
Home(HomeReceiver receiver, HomeTransmitter transmitter)
          Creates a Home with a transmitter and receiver.
Home(HomeReceiver receiver, HomeTransmitter transmitter, HomeStorage store)
          Creates a Home with a transmitter, receiver and storage.
Home(HomeTransceiver transceiver)
          Creates a Home with a transceiver.
Home(HomeTransceiver transceiver, HomeStorage store)
          Creates a Home with a transceiver and storage.
Home(HomeTransmitter transmitter)
          Constructs a Home with a transmitter.
Home(HomeTransmitter transmitter, HomeStorage store)
          Constructs a Home with a transmitter and storage.
 
Method Summary
 void add(java.lang.Object obj)
          Adds and object to the Home
 void addHomeListener(HomeListener listener)
          Adds the given HomeListener to this Home.
 void distribute(HomeCommandStatus status)
          Distributes HomeCommandStatus to the command listener.
 void distribute(HomeEvent event)
          Distributes HomeEvents to the listeners.
 void flush()
          Flushes the objects in HomeStorage
 java.lang.Object get(java.lang.Class c, java.lang.String name)
          Retrieves a named object of the given class
 HomeDevice get(DeviceAddress address)
          Gets object with specified address
 java.util.Enumeration<java.lang.Object> getAll()
          Gets all objects
 java.util.Enumeration<java.lang.Object> getAll(java.lang.Class c)
          Gets all objects of the specified class
 void remove(java.lang.Object obj)
          Removes the object from the Home
 void removeHomeListener(HomeListener listener)
          Removes the given HomeListener from this Home.
 void start()
          Starts the Home and all associted resources
 void stop()
          Stops the Home and all associted resources
static int transmit(HomeCommand command)
          Transmits the given HomeEvent on this interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_errorStream

public static java.io.PrintStream m_errorStream
The error stream to which all error messages are written


m_me

protected static Home m_me

m_database

protected HomeStorage m_database

m_receiver

protected HomeReceiver m_receiver

m_transmitter

protected static HomeTransmitter m_transmitter
Constructor Detail

Home

public Home(HomeReceiver receiver)
Creates a Home with a receiver. Instances created with this constructor will only receive HomeEvents, they cannot transmit HomeCommands.

Parameters:
receiver - the HomeReceiver

Home

public Home(HomeReceiver receiver,
            HomeStorage store)
Creates a Home with a receiver and storage. Instances created with this constructor will only receive HomeEvents, they cannot transmit HomeCommands.

Parameters:
receiver - the HomeReceiver
store - the HomeStorage

Home

public Home(HomeTransmitter transmitter)
Constructs a Home with a transmitter. Instances created with this constructor will only transmit HomeCommands, they cannot receive HomeEvents.

Parameters:
transmitter - the HomeTransmitter

Home

public Home(HomeTransmitter transmitter,
            HomeStorage store)
Constructs a Home with a transmitter and storage. Instances created with this constructor will only transmit HomeCommands, they cannot receive HomeEvents.

Parameters:
transmitter - the HomeTransmitter
store - the HomeStorage

Home

public Home(HomeReceiver receiver,
            HomeTransmitter transmitter)
Creates a Home with a transmitter and receiver. Instances created with this constructor may transmit HomeCommands and receive HomeEvents.

Parameters:
receiver - the HomeReceiver
transmitter - the HomeTransmitter

Home

public Home(HomeReceiver receiver,
            HomeTransmitter transmitter,
            HomeStorage store)
Creates a Home with a transmitter, receiver and storage. Instances created with this constructor may transmit HomeCommands and receive HomeEvents.

Parameters:
receiver - the HomeReceiver
transmitter - the HomeTransmitter
store - the HomeStorage

Home

public Home(HomeTransceiver transceiver)
Creates a Home with a transceiver. Instances created with this constructor may transmit HomeCommands and receive HomeEvents.

Parameters:
transceiver - the HomeTransceiver

Home

public Home(HomeTransceiver transceiver,
            HomeStorage store)
Creates a Home with a transceiver and storage. Instances created with this constructor may transmit HomeCommands and receive HomeEvents.

Parameters:
transceiver - the HomeTransceiver
store - the HomeStorage
Method Detail

start

public void start()
           throws java.io.IOException,
                  HomeException
Starts the Home and all associted resources

Throws:
java.io.IOException
HomeException

stop

public void stop()
          throws java.io.IOException,
                 HomeException
Stops the Home and all associted resources

Throws:
java.io.IOException
HomeException

transmit

public static int transmit(HomeCommand command)
                    throws HomeException
Transmits the given HomeEvent on this interface.

Parameters:
command - the command to be transmitted
Returns:
the request id for this command
Throws:
HomeException

distribute

public void distribute(HomeEvent event)
Distributes HomeEvents to the listeners.

Parameters:
event - the HomeEvent to be distributed to listeners

distribute

public void distribute(HomeCommandStatus status)
Distributes HomeCommandStatus to the command listener.

Parameters:
status - the HomeCommandStatus to be distributed tothe command source

addHomeListener

public void addHomeListener(HomeListener listener)
Adds the given HomeListener to this Home.

Parameters:
listener - listener to be added

removeHomeListener

public void removeHomeListener(HomeListener listener)
Removes the given HomeListener from this Home.

Parameters:
listener - listener to be removed

getAll

public java.util.Enumeration<java.lang.Object> getAll(java.lang.Class c)
Gets all objects of the specified class

Parameters:
c - the class
See Also:
HomeStorage

getAll

public java.util.Enumeration<java.lang.Object> getAll()
Gets all objects

See Also:
HomeStorage

get

public HomeDevice get(DeviceAddress address)
Gets object with specified address

Parameters:
address - the address
See Also:
HomeStorage

get

public java.lang.Object get(java.lang.Class c,
                            java.lang.String name)
Retrieves a named object of the given class

Parameters:
c - the class
name - the object name
See Also:
HomeStorage

add

public void add(java.lang.Object obj)
Adds and object to the Home

Parameters:
obj - the object to be added
See Also:
HomeStorage

remove

public void remove(java.lang.Object obj)
Removes the object from the Home

Parameters:
obj - the object to be removed
See Also:
HomeStorage

flush

public void flush()
           throws java.io.IOException
Flushes the objects in HomeStorage

Throws:
java.io.IOException
See Also:
HomeStorage