dk.opi.io
Interface IOGroup

All Known Implementing Classes:
DefaultIOGroup

public interface IOGroup

This interface describes IO groups. The IOGroup allows grouping of any numbers of IOItems. For instance monitoring of a group of items may be turned off by a call to setActive(false) on the group.


Method Summary
 void addIOListener(IOListener l)
          Add a listener for IO events related to this group
 void addItem(IOItem ioi)
          Add an item to this group
 void fireAllItems()
          Use this method to manually fire a onValueChanged() notification to all listeners of this group
 void fireAllItems(IOListener iol)
          Use this method to manually fire a onValueChanged() notification to the specified IOListener
 void fireAllItems(IOListener iol, boolean performRead, int dataSource)
          Use this method to manually fire a IOListener.onValueChanged(dk.opi.io.IOItem) notification to the specified IOListener.
 String getDescription()
          Get descriptive text for this group
 IOItem getItem(String actionCmdName)
          Return an IOItem from this group
 Vector getItems()
          Return Vector of all IOItems currently added to this group.
 String getName()
          Get the name of this group
 int getUpdateRate()
           
 boolean isActive()
           
 void readAllItems(int dataSource)
          Read the item value for all items in this group.
 void removeIOListener(IOListener l)
          Remove a listener for IO events related to this group
 void removeItem(IOItem ioi)
          Remove an item from this group
 void setActive(boolean b)
          Turn off/on automatical updating from the IOItems in this group depedning on the value of b
 void setDescription(String text)
          Set descriptive text for this group.
 

Method Detail

addItem

public void addItem(IOItem ioi)
Add an item to this group

Parameters:
ioi - The item to add

removeItem

public void removeItem(IOItem ioi)
                throws RbxIOException
Remove an item from this group

Parameters:
ioi - The item to remove
Throws:
RbxIOException - thrown if it was not possible to remove the specified item, for instance if the specified item is not a member of this group.

getItem

public IOItem getItem(String actionCmdName)
Return an IOItem from this group

Parameters:
actionCmdName - Name of the item to return
Returns:
null if not item with specified name exists - otherwise an IOItem object is returned

getItems

public Vector getItems()
Return Vector of all IOItems currently added to this group. Don't change anything in this Vector since it most likely is used by the implementing IOGroup class for critical IO stuff

Returns:
Vector object containing list of all IOItems added to this group

addIOListener

public void addIOListener(IOListener l)
Add a listener for IO events related to this group


removeIOListener

public void removeIOListener(IOListener l)
Remove a listener for IO events related to this group


getUpdateRate

public int getUpdateRate()
Returns:
Update rate for monitored items in this group in milli secs

setActive

public void setActive(boolean b)
Turn off/on automatical updating from the IOItems in this group depedning on the value of b

Parameters:
b - if true IOItems in this group will fire the valueChanged() event everytime a value is changed

isActive

public boolean isActive()
Returns:
True if the monitoring of the group is active, otherwise false is returned

fireAllItems

public void fireAllItems()
Use this method to manually fire a onValueChanged() notification to all listeners of this group


fireAllItems

public void fireAllItems(IOListener iol)
Use this method to manually fire a onValueChanged() notification to the specified IOListener


fireAllItems

public void fireAllItems(IOListener iol,
                         boolean performRead,
                         int dataSource)
                  throws RbxIOException
Use this method to manually fire a IOListener.onValueChanged(dk.opi.io.IOItem) notification to the specified IOListener. This method is usefull right after items have been added to the group. A call to this method will initialize your application with the current values.

Parameters:
iol - the listener to notify
performRead - if true a read will be performed for all items in the group prior to firing of the event. In combination with a dataSource value of DEVICE_READ this will ensure that the onValueChanged() is fired with the most recent and up to date value.
dataSource - The source to read from, ie. CACHE_READ or DEVICE_READ. Also see IOItem.readValue(int). Ignored unless performRead is set to true
Throws:
RbxIOException - Will only be thrown if performRead is true and the read operation for some reason fails

getName

public String getName()
Get the name of this group

Returns:
group name

setDescription

public void setDescription(String text)
Set descriptive text for this group. By default the description is set to the group name

Parameters:
text - the description.
See Also:
getDescription()

getDescription

public String getDescription()
Get descriptive text for this group

Returns:
the description. By default the description is set to the group name.
See Also:
setDescription(java.lang.String)

readAllItems

public void readAllItems(int dataSource)
                  throws RbxIOException
Read the item value for all items in this group. Item values may subsequently be obtained by a call to getOldValue() on each item. The intended use of this method is to update register values for items, in case the group is intentially set to inactive.
onValueChanged() on registered listeners for the group will be called for changed values.
The read will be executed in the most efficient way possible, ie. if the implementation supports multiple item reads in a single method call, this method will be used.

Parameters:
dataSource - The source to read from, ie. IOItem.CACHE_READ or IOItem.DEVICE_READ. A CACHE read will obtain the current value for the item from the device server cache (eg. OPC server). This is fast but the value is only updated with the specified update rate, ie. a CACHE read is accurate to within the 'UpdateRate' of the group.
The data can be read from the DEVICE in which case an actual read of the physical device is to be performed. The exact implementation of CACHE and DEVICE reads may vary between devices and communication servers.
For CACHE reads the data is only valid if both the group and the item are active. DEVICE reads are not affected by the ACTIVE state of the group or item.
Throws:
RbxIOException - thrown if one or more read operations failed.