com.universaldevices.client
Class UDClient

java.lang.Object
  extended by com.universaldevices.client.UDClient
All Implemented Interfaces:
IModelChangeListener
Direct Known Subclasses:
ISYClient

public abstract class UDClient
extends java.lang.Object
implements IModelChangeListener

Author:
UD Architect UDClient is the main facade class to communicate with ISY. Subclasses of this class implement callbacks to receive notification of ISY status be it a change in a control value to changes in the nodes

Field Summary
 
Fields inherited from interface com.universaldevices.device.model.IModelChangeListener
UD_BATCH_MODE_CHANGED_ACTION, UD_BATTERY_DEVICE_WRITE_MODE_CHANGED_ACTION, UD_CLIENT_HEART_BEAT_EVENT, UD_DEVICE_SPECIFIC_EVENT, UD_DISCOVERING_NODES_ACTION, UD_DISCOVERING_NODES_COMPLETE_ACTION, UD_FOLDER_ADDED_ACTION, UD_FOLDER_REMOVED_ACTION, UD_FOLDER_RENAMED_ACTION, UD_GROUP_ADDED_ACTION, UD_GROUP_REMOVED_ACTION, UD_GROUP_RENAMED_ACTION, UD_INTERNET_ACCESS_DISABLED_ACTION, UD_INTERNET_ACCESS_ENABLED_ACTION, UD_INTERNET_ACCESS_EVENT, UD_INTERNET_ACCESS_FAILED_ACTION, UD_NETWORK_RENAMED_ACTION, UD_NODE_ADDED_ACTION, UD_NODE_CHANGE_LINK_ACTION, UD_NODE_CLEAR_ERROR_ACTION, UD_NODE_DEVICE_ID_CHANGED, UD_NODE_DEVICE_PROPERTY_CHANGED, UD_NODE_ENABLED_ACTION, UD_NODE_HAS_PENDING_DEVICE_WRITES_ACTION, UD_NODE_IN_ERROR_ACTION, UD_NODE_MOVED_ACTION, UD_NODE_PARENT_CHANGED_ACTION, UD_NODE_POWER_INFO_CHANGED_ACTION, UD_NODE_REMOVED_ACTION, UD_NODE_REMOVED_FROM_GROUP_ACTION, UD_NODE_RENAMED_ACTION, UD_NODE_REVISED_ACTION, UD_NODE_WRITING_TO_DEVICE_ACTION, UD_NODES_UPDATED_EVENT, UD_NOTIFICATION_SETTINGS_UPDATED_ACTION, UD_NTP_COMM_FAILED_ACTION, UD_NTP_SETTINGS_UPDATED_ACTION, UD_PROGRESS_EVENT_UPDATE, UD_PROGRESS_UPDATED_EVENT, UD_SYS_CONFIG_UPDATED_EVENT, UD_SYSTEM_BUSY_EVENT, UD_SYSTEM_IS_BUSY_ACTION, UD_SYSTEM_IS_IDLE_ACTION, UD_SYSTEM_IS_IN_SAFE_MODE_ACTION, UD_SYSTEM_IS_NOT_BUSY_ACTION, UD_TIME_CHANGED_ACTION, UD_TIME_CONFIG_CHANGED_ACTION, UD_TRIGGER_EVENT_GET_STATUS, UD_TRIGGER_EVENT_INFO_STRING, UD_TRIGGER_EVENT_KEY_CHANGED, UD_TRIGGER_EVENT_LEARN_IR, UD_TRIGGER_EVENT_SCHEDULE, UD_TRIGGER_EVENT_STATUS, UD_TRIGGER_EVENT_VAR_INIT, UD_TRIGGER_EVENT_VAR_STATUS, UD_TRIGGER_UPDATED_EVENT
 
Constructor Summary
UDClient()
           
 
Method Summary
 void addUDErrorListener(ErrorEventListener listener)
          Adds an error listener to be notified of all the errors generated either by the client or by ISY
 void addUDModelChangeListener(IModelChangeListener listener)
          Adds a model change listener which is notified of all the events in ISY
 boolean authenticate(java.lang.String userid, java.lang.String pwd)
          Authenticates a user
protected  void cleanUp()
          Override this function if you have any cleanup routines that need to be done
 java.util.Hashtable<java.lang.String,UDControl> getControls()
          Returns a Hashtable of all the UDControl (controls) as configured in the system
 UDProxyDevice getDevice()
          Returns the UDProxyDevice device object which represents ISY and its services in its entirety.
 java.util.Hashtable<java.lang.String,UDGroup> getGroups()
          Returns a Hashtable scenes/groups as configured in the system
 java.util.Hashtable<java.lang.String,UDNode> getNodes()
          Returns a Hashtable of all the nodes (linked devices) as configured in the system
 boolean isStarted()
          Whether or not UDClient has started
 void onNewDevice(UDProxyDevice device)
          This method is called back by UDI Network Services when a new device is announced based on the device-type as set in the start method
abstract  void onNewDeviceAnnounced(UDProxyDevice device)
          Is called back when a new device is announced based on the device-type as set in the start(String) method
 void removeUDErrorListener(ErrorEventListener listener)
          Removes a previously added error listener
 void removeUDModelChangeListener(IModelChangeListener listener)
          Removes a previously added model change listener
protected  void setStarted(boolean started)
          Indicates that this client has successfully been started
 void start(java.lang.String deviceType)
          Starts the UDclient based on the device type
 void stop()
          Stops the UDclient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.universaldevices.device.model.IModelChangeListener
onDeviceOffLine, onDeviceOnLine, onDeviceSpecific, onDiscoveringNodes, onFolderRemoved, onFolderRenamed, onGroupRemoved, onGroupRenamed, onInternetAccessUpdated, onModelChanged, onNetworkRenamed, onNewFolder, onNewGroup, onNewNode, onNodeDeviceIdChanged, onNodeDevicePropertiesRefreshed, onNodeDevicePropertiesRefreshedComplete, onNodeDevicePropertyChanged, onNodeDiscoveryStopped, onNodeEnabled, onNodeError, onNodeErrorCleared, onNodeHasPendingDeviceWrites, onNodeIsWritingToDevice, onNodeMoved, onNodeParentChanged, onNodePowerInfoChanged, onNodeRemoved, onNodeRemovedFromGroup, onNodeRenamed, onNodeRevised, onNodeToGroupRoleChanged, onProgress, onSystemConfigChanged, onSystemStatus, onTriggerStatus
 

Constructor Detail

UDClient

public UDClient()
Method Detail

start

public void start(java.lang.String deviceType)
Starts the UDclient based on the device type

Calling the start(String) method instructs the UDClient Network Services to start looking for, and issue search requests, for the specific device type passed in as the paramter.

For Insteon, the device type is:
urn:udi-com:device:X_Insteon_Lighting_Device:1

Parameters:
deviceType - ; the uniquely identifiable type of device

cleanUp

protected void cleanUp()
Override this function if you have any cleanup routines that need to be done


stop

public void stop()
Stops the UDclient.

Calling the stop() method instructs the UDClient Network Services to stop, all active subscriptions are canceled, and all resources cleared

Call this method upon application/applet exit


getDevice

public UDProxyDevice getDevice()
Returns the UDProxyDevice device object which represents ISY and its services in its entirety.

UDProxyDevice is a proxy to ISY and, as such, all ISY services are encapsulated in this class.

Returns:
UDProxyDevice object

addUDModelChangeListener

public void addUDModelChangeListener(IModelChangeListener listener)
Adds a model change listener which is notified of all the events in ISY

Parameters:
listener - - a model change listener to be added
See Also:
IModelChangeListener

removeUDModelChangeListener

public void removeUDModelChangeListener(IModelChangeListener listener)
Removes a previously added model change listener

Parameters:
listener - - the model change listener to be removed
See Also:
IModelChangeListener

addUDErrorListener

public void addUDErrorListener(ErrorEventListener listener)
Adds an error listener to be notified of all the errors generated either by the client or by ISY

Parameters:
listener - - an error listener to be added
See Also:
ErrorEventListener

removeUDErrorListener

public void removeUDErrorListener(ErrorEventListener listener)
Removes a previously added error listener

Parameters:
listener - - the error listener to be removed
See Also:
ErrorEventListener

authenticate

public boolean authenticate(java.lang.String userid,
                            java.lang.String pwd)
                     throws NoDeviceException
Authenticates a user

Parameters:
userid - - the user id
pwd - - the password
Returns:
true if authenticated false otherwise
Throws:
NoDeviceException

onNewDevice

public final void onNewDevice(UDProxyDevice device)
This method is called back by UDI Network Services when a new device is announced based on the device-type as set in the start method

Subclasses may not override onNewDevice(UDProxyDevice) method as the discovered device (ISY) can be retrieved by getDevice() method. In case the subclass needs to be notified of a new device, it should override the onNewDeviceAnnounced(UDProxyDevice) method

Specified by:
onNewDevice in interface IModelChangeListener
Parameters:
device -
See Also:
getDevice(), onNewDeviceAnnounced(com.universaldevices.upnp.UDProxyDevice)

onNewDeviceAnnounced

public abstract void onNewDeviceAnnounced(UDProxyDevice device)
Is called back when a new device is announced based on the device-type as set in the start(String) method

Subclasses must override onNewDeviceAnnounced(UDProxyDevice) in order to be notified of a new device

Parameters:
device -
See Also:
getDevice(), onNewDevice(UDProxyDevice)

getGroups

public java.util.Hashtable<java.lang.String,UDGroup> getGroups()
                                                        throws NoDeviceException
Returns a Hashtable scenes/groups as configured in the system

Returns:
Hashtable representation of all the groups/scenes in the system
Throws:
NoDeviceException
See Also:
UDGroup, UDNode

getNodes

public java.util.Hashtable<java.lang.String,UDNode> getNodes()
                                                      throws NoDeviceException
Returns a Hashtable of all the nodes (linked devices) as configured in the system

Returns:
Hashtable representation of all the nodes in the system
Throws:
NoDeviceException
See Also:
UDGroup, UDNode

getControls

public java.util.Hashtable<java.lang.String,UDControl> getControls()
                                                            throws NoDeviceException
Returns a Hashtable of all the UDControl (controls) as configured in the system

Controls are "things" that either control or maintain the state of a device such as Power, Status, SetPoint, etc..

Returns:
Hashtable representation of all the controls in the system
Throws:
NoDeviceException
See Also:
UDControl

isStarted

public boolean isStarted()
Whether or not UDClient has started

Returns:
true if UDClient has started false otherwise

setStarted

protected void setStarted(boolean started)
Indicates that this client has successfully been started

Subclasses may have different methods of starting the client and, as such, they may use this method to indicate that the client has successfully started

Parameters:
started - - whether or not the client started