com.universaldevices.device.model
Class UDGroup

java.lang.Object
  extended by com.universaldevices.device.model.UDNode
      extended by com.universaldevices.device.model.UDGroup
All Implemented Interfaces:
java.lang.Comparable

public class UDGroup
extends UDNode

UDGroup represents a collection of UDNodes.

Since a group is also a node in the device tree, as such, this class extends UDNode.
In some cases (such as Insteon), a UDGroup represents a scene where each UDNode may play a role in the scene (such as controller vs. responder) Note:UDGroup is created/instantiated by the underlying UD Network and Services Layers and should not be created independently

Author:
UDArchitect
See Also:
UDNode

Field Summary
 java.util.Hashtable<java.lang.Object,java.util.Set<java.lang.String>> deviceNodes
          A Hashtable of a Set of addresses for UDNode.
 java.util.Hashtable<java.lang.String,java.lang.String> groupNodeFlags
          A Hashtable of flags (roles) for each UDNode in this group.
 
Fields inherited from class com.universaldevices.device.model.UDNode
address, dcPeriod, deviceClass, isEnabled, name, parent, parentName, parentType, type, typeReadable, UD_HIERARCHY_NODE_TYPE_FOLDER, UD_HIERARCHY_NODE_TYPE_GROUP, UD_HIERARCHY_NODE_TYPE_NODE, UD_HIERARCHY_NODE_TYPE_NOTSET, UD_PRODUCT_FAMILY_ADR, UD_PRODUCT_FAMILY_BRULTECH, UD_PRODUCT_FAMILY_DEFAULT, UD_PRODUCT_FAMILY_GNC, UD_PRODUCT_FAMILY_INSTEON, UD_PRODUCT_FAMILY_RCS, UD_PRODUCT_FAMILY_UDI, UD_PRODUCT_FAMILY_UPB, UD_PRODUCT_FAMILY_ZWAVE, uuid, wattage
 
Constructor Summary
UDGroup(java.lang.String address, java.lang.String name)
          Constructor
UDGroup(XMLElement xml, java.lang.Object dev)
          Constructor
 
Method Summary
 java.util.Set<java.lang.String> addDevice(java.lang.Object device)
          Adds a UDProxyDevice to the list of devices (ISYs) which this group belongs to.
 void addNode(java.lang.String id, java.lang.Object device)
          Adds a UDNode to this group.
 void addNodes(java.util.Set<java.lang.String> nodes, java.lang.Object device)
          Adds a Set of UDNodes to this group.
 java.util.Set<java.lang.String> getMembers(java.lang.Object device)
          Returns the Set of Node addresses for the members of this group
 java.lang.String getPhysicalGroupAddress()
           
 short getRole(java.lang.String nodeId, java.lang.Object device)
          Returns the role the given UDNode plays in this group
 boolean hasNoDevices()
          Returns whether or not this group is empty.
 void init()
          Initializes this object
 boolean isMemberOf(java.lang.String nodeId, java.lang.Object device)
          Returns whether or not the given UDNode is a member of this group.
 boolean isNodeMaster(java.lang.String nodeId, java.lang.Object device)
          Returns whether or not the given UDNode is the master (controller) for this group.
 void processElement(XMLElement child, java.lang.Object device)
          Processes an XML/DIML representation of the attributes of a UDGroup.
 void removeDevice(java.lang.Object dev)
          Removes a UDProxyDevice from a group
 void removeNode(java.lang.String id, java.lang.Object device)
          Removes an associated UDNode from this group.
 boolean setRole(java.lang.String nodeId, java.lang.String role, java.lang.Object device)
          Set the role the given UDNode plays in this group
 
Methods inherited from class com.universaldevices.device.model.UDNode
compareTo, equals, getAction, getControls, getDeviceType, getFamilyId, getFormattedDeviceId, getHasPendingDeviceWrites, getNodeDeviceProperties, getNodeFlag, getPrimaryNode, getResponderType, getRxEndpointMask, getSubgroup, getTxEndpointMask, isController, isDefaultFamilyId, isDevicePrimaryNode, isInError, isQueryable, isResponder, isRootNode, isWritingToDevice, refresh, revise, setDeviceType, setDeviceType, setFamilyId, setFormattedDeviceId, setHasPendingDeviceWrites, setIsController, setIsInError, setIsQueryable, setIsResponder, setIsWritingToDevice, setNodeDeviceProperties, setNodeFlag, setParentType, setPrimaryNode, setResponderType, setRxEndpointMask, setSubgroup, setTxEndpointMask, setType, toString, updateState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

deviceNodes

public java.util.Hashtable<java.lang.Object,java.util.Set<java.lang.String>> deviceNodes
A Hashtable of a Set of addresses for UDNode. The entries are found based on UDProxyDevice.


groupNodeFlags

public java.util.Hashtable<java.lang.String,java.lang.String> groupNodeFlags
A Hashtable of flags (roles) for each UDNode in this group. The Hashtable index is the address of the UDNode

Constructor Detail

UDGroup

public UDGroup(XMLElement xml,
               java.lang.Object dev)
Constructor

Is called by the underlying UD Network and Services Layers based on the (XML) nodes configuration retrieved from the deivce (ISY).
Note: Should not be used independently

Parameters:
xml - - the xml/diml representation of a group
dev - - the device (UDProxyDevice

UDGroup

public UDGroup(java.lang.String address,
               java.lang.String name)
Constructor

Is called by the underlying UD Network and Services Layers based on a given address and given name Note: Should not be used independently

Parameters:
address - - the address to be used for this group (must be unique)
name - - the name to be used for this group
Method Detail

init

public void init()
Initializes this object

Overrides:
init in class UDNode

getPhysicalGroupAddress

public java.lang.String getPhysicalGroupAddress()
Returns:
the physicalGroupAddress

removeNode

public void removeNode(java.lang.String id,
                       java.lang.Object device)
Removes an associated UDNode from this group.

Note: this operation does not remove the actual node from this group in the device (ISY).
To do that, UDProxyDevice.removeFromGroup(java.lang.String, java.lang.String) should be used instead.

Parameters:
id - - the address of the node to be removed
device - - the UDProxyDevice to which the node belongs to
See Also:
UDNode

addDevice

public java.util.Set<java.lang.String> addDevice(java.lang.Object device)
Adds a UDProxyDevice to the list of devices (ISYs) which this group belongs to.

As there might be more than one ISY on the network, this method captures the relationship of one group to many devices.
i.e. We may have a Entertainment Room group which spans three ISYs of 1) Insteon Enabled 2) Aprilaire and 3) Nuvo

Parameters:
device - - the UDProxyDevice to be added to this group
Returns:
a set of UDNode addresses which belong to this group and this device
See Also:
UDNode

removeDevice

public void removeDevice(java.lang.Object dev)
Removes a UDProxyDevice from a group

Parameters:
dev - - the UDProxyDevice
See Also:
addDevice(java.lang.Object)

addNode

public void addNode(java.lang.String id,
                    java.lang.Object device)
Adds a UDNode to this group.

Note: this operation does not add the actual node to this group in the device (ISY).
To do that, UDProxyDevice.moveNode(java.lang.String, java.lang.String, char) should be used instead.

Parameters:
id - - the address of the UDNode to be added
device - - the UDProxyDevice to which this node belongs to
See Also:
UDNode

hasNoDevices

public boolean hasNoDevices()
Returns whether or not this group is empty.

i.e. No devices (ISY) have this group nor are there any UDNodes for this group

Returns:
true if empty false otherwise

isMemberOf

public boolean isMemberOf(java.lang.String nodeId,
                          java.lang.Object device)
Returns whether or not the given UDNode is a member of this group.

Parameters:
nodeId - - the address of the UDNode to be checked for membership
device - - the UDProxyDevice that the UDNode belongs to
Returns:
true if the node is a member of this group, false otherwise
See Also:
UDNode, UDProxyDevice

getRole

public short getRole(java.lang.String nodeId,
                     java.lang.Object device)
Returns the role the given UDNode plays in this group

Parameters:
nodeId - - the address of the UDNode to be checked
device - - the UDProxyDevice to which the node belongs to
Returns:
-1 if no roles are found otherwise the (short) casted representation of a char value defining the role. The return value has to be casted back to (char)
See Also:
UDNode, UDProxyDevice

setRole

public boolean setRole(java.lang.String nodeId,
                       java.lang.String role,
                       java.lang.Object device)
Set the role the given UDNode plays in this group

Parameters:
nodeId - - the address of the UDNode to be checked
role - - the new role of the UDNode to be set
device - - the UDProxyDevice to which the node belongs to
Returns:
true if successful, otherwise false
See Also:
UDNode, UDProxyDevice

isNodeMaster

public boolean isNodeMaster(java.lang.String nodeId,
                            java.lang.Object device)
Returns whether or not the given UDNode is the master (controller) for this group.

Parameters:
nodeId - - the address of the UDNode to be checked
device - - the UDProxyDevice to which the node belongs to
Returns:
true if the node is master of this group, false otherwise
See Also:
UDNode, UDProxyDevice

addNodes

public void addNodes(java.util.Set<java.lang.String> nodes,
                     java.lang.Object device)
Adds a Set of UDNodes to this group.

Note: This method is utilized by the underlying UD Network and Services Layers and, as such, should not be invoked independently

Parameters:
nodes - - a Set of UDNode addresses
device - - the UDProxyDevice to which these nodes belong to

getMembers

public java.util.Set<java.lang.String> getMembers(java.lang.Object device)
Returns the Set of Node addresses for the members of this group

Parameters:
device - - the device for which this is a group

processElement

public void processElement(XMLElement child,
                           java.lang.Object device)
Processes an XML/DIML representation of the attributes of a UDGroup.

Note: Should not be used independently

Overrides:
processElement in class UDNode