dk.opi.io
Interface IOItem

All Known Implementing Classes:
DefaultIOItem

public interface IOItem

This interface represents IO items (tags) which represent values from PLC's, digital IO cards etc.


Field Summary
static int CACHE_READ
          Specify CACHED read
static int DATATYPE_BOOL
          Value is of type Boolean - this type should be used when dealing with single bit values.
static int DATATYPE_BOOLARRAY
          Value is of type Boolean[].
static int DATATYPE_DATE
          Value is of type Date.
static int DATATYPE_DOUBLE
          Value is of type Double.
static int DATATYPE_DOUBLEARRAY
          Value is of type Double[].
static int DATATYPE_FLOAT
          Value is of type Float.
static int DATATYPE_FLOATARRAY
          Value is of type Integer[].
static int DATATYPE_INT
          Value is of type Integer
static int DATATYPE_INTARRAY
          Value is of type Integer[].
static int DATATYPE_STRING
          Value is of type String
static int DATATYPE_USE_NATIVE
          Value is automatically assigned according to what the IOServer suggests.
static int DEVICE_READ
          Specify DEVICE read
 
Method Summary
 String getActionCommand()
          Returns the command name associated with this item.
 int getDataType()
          Describes the data type of the value associated with this event.
 String getDescription()
          Get descriptive text for this item
 IOGroup getGroup()
          Get the group this item belongs to
 IOQuality getOldQuality()
          Returns the quality of the last read value, ie. quality corresponding to the value returned from calling getOldValue()
 Object getOldValue()
          Last value read from the device - can be used to efficiently read an item value when fired in an IOListener onDataChanged() event.
 Object getUserObject()
          Returns a user object that may optionally having been assigned to this IOItem.
 boolean isActive()
          Is the item active - ie. is it automatically being polled
 boolean isOldQualityGood()
          Returns quality of last read value.
 Object readValue()
          Read the item value from the device.
 Object readValue(int dataSource)
          Read the item value from the device.
 void setActionCommand(String aCmd)
          Set the command name associated with this item.
 void setDescription(String text)
          Set descriptive text for this item
 void setUserObject(Object o)
          Set optional user object associated with this IOItem.
 void writeIntValue(int value)
          Deprecated. Replaced by writeValue(int).
 void writeValue(boolean value)
          Write the specified value to the device.
 void writeValue(Boolean value)
          Write the specified value to the device.
 void writeValue(boolean[] values)
          Write the specified array of booleans to the device.
 void writeValue(double value)
          Write the specified value to the device.
 void writeValue(Double value)
          Write the specified value to the device.
 void writeValue(double[] values)
          Write the specified array of doubles to the device.
 void writeValue(float value)
          Write the specified value to the device.
 void writeValue(Float value)
          Write the specified value to the device.
 void writeValue(float[] values)
          Write the specified array of floats to the device.
 void writeValue(int value)
          Write the specified value to the device.
 void writeValue(int[] values)
          Write the specified array of integers to the device.
 void writeValue(Integer value)
          Write the specified value to the device.
 void writeValue(String value)
          Write the specified value to the device.
 

Field Detail

DATATYPE_USE_NATIVE

public static final int DATATYPE_USE_NATIVE
Value is automatically assigned according to what the IOServer suggests. This is usefull if you are adding items dynamically, without knowing the exact type. After the item has been created you may query the type using the IOItem.getDataType() method

See Also:
Constant Field Values

DATATYPE_BOOL

public static final int DATATYPE_BOOL
Value is of type Boolean - this type should be used when dealing with single bit values.

See Also:
Constant Field Values

DATATYPE_INT

public static final int DATATYPE_INT
Value is of type Integer

See Also:
Constant Field Values

DATATYPE_FLOAT

public static final int DATATYPE_FLOAT
Value is of type Float.

See Also:
Constant Field Values

DATATYPE_DOUBLE

public static final int DATATYPE_DOUBLE
Value is of type Double.

See Also:
Constant Field Values

DATATYPE_STRING

public static final int DATATYPE_STRING
Value is of type String

See Also:
Constant Field Values

DATATYPE_DATE

public static final int DATATYPE_DATE
Value is of type Date. Important note: This data type is currently unsupported in the OPC client, but has been included for future compatibility.

See Also:
Constant Field Values

DATATYPE_BOOLARRAY

public static final int DATATYPE_BOOLARRAY
Value is of type Boolean[]. This data type is not supported by all communication servers, but the Siemens S7 OPC Server supports it.

See Also:
Constant Field Values

DATATYPE_INTARRAY

public static final int DATATYPE_INTARRAY
Value is of type Integer[]. This data type is not supported by all communication servers, but the Siemens S7 OPC Server supports it.

See Also:
Constant Field Values

DATATYPE_FLOATARRAY

public static final int DATATYPE_FLOATARRAY
Value is of type Integer[]. This data type is not supported by all communication servers, but the Siemens S7 OPC Server supports it.

See Also:
Constant Field Values

DATATYPE_DOUBLEARRAY

public static final int DATATYPE_DOUBLEARRAY
Value is of type Double[]. This data type is not supported by all communication servers, but the Siemens S7 OPC Server supports it.

See Also:
Constant Field Values

CACHE_READ

public static final int CACHE_READ
Specify CACHED read

See Also:
readValue(int), Constant Field Values

DEVICE_READ

public static final int DEVICE_READ
Specify DEVICE read

See Also:
readValue(int), Constant Field Values
Method Detail

getGroup

public IOGroup getGroup()
Get the group this item belongs to

Returns:
The group this item belongs to

getDataType

public int getDataType()
Describes the data type of the value associated with this event. The value returned is any of the values DATATYPE_INT etc. also defined in this interface

Returns:
any of the values DATATYPE_INT etc. also defined in this interface

readValue

public Object readValue()
                 throws RbxIOException
Read the item value from the device. The value is converted into an object corresponding to the dataType of this item.

Throws:
RbxIOException - thrown if the read operation failed

readValue

public Object readValue(int dataSource)
                 throws RbxIOException
Read the item value from the device. The value is converted into an object corresponding to the dataType of this item.

Parameters:
dataSource - The source to read from, ie. CACHE_READ or 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 intended use of a DEVICE read is to update the register value of an inactive item. 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 the read operation failed

writeIntValue

public void writeIntValue(int value)
                   throws RbxIOException
Deprecated. Replaced by writeValue(int).

Write the specified value to the device. The value written is supplied as an integer

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(int value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(float value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(double value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(boolean value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(String value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(Integer value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(Boolean value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(Float value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(Double value)
                throws RbxIOException
Write the specified value to the device.

Parameters:
value - The value to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(int[] values)
                throws RbxIOException
Write the specified array of integers to the device.

Parameters:
values - The array of integer values to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(float[] values)
                throws RbxIOException
Write the specified array of floats to the device.

Parameters:
values - The array of float values to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(double[] values)
                throws RbxIOException
Write the specified array of doubles to the device.

Parameters:
values - The array of double values to send to the device
Throws:
RbxIOException - thrown if the write operation failed

writeValue

public void writeValue(boolean[] values)
                throws RbxIOException
Write the specified array of booleans to the device.

Parameters:
values - The array of boolean values to send to the device
Throws:
RbxIOException - thrown if the write operation failed

getActionCommand

public String getActionCommand()
Returns the command name associated with this item. This allows users to assign logical names for items

Returns:
any String including the null object

setActionCommand

public void setActionCommand(String aCmd)
Set the command name associated with this item. This allows users to assign logical names for items

Parameters:
aCmd - any users defined string including null

getOldValue

public Object getOldValue()
Last value read from the device - can be used to efficiently read an item value when fired in an IOListener onDataChanged() event. The value returned is returned from an internal cache rather than reading from the device. Reading from cache is more efficient than actually reading the value directly from the device

Returns:
last read value for this item. The Object type corresponds to the dataType of this item (ie. IOItem.DATATYPE_BOOL, IOItem.DATATYPE_INT etc).

getOldQuality

public IOQuality getOldQuality()
Returns the quality of the last read value, ie. quality corresponding to the value returned from calling getOldValue()

Returns:
an implementation of interface IOQuality. Guaranteed never to return null.

isOldQualityGood

public boolean isOldQualityGood()
Returns quality of last read value. Calling this method is more efficient than first calling getOldQuality() and then investigate the returned IOQuality instance, since the implementation need not create an IOQuality instance to determine if the quality is good or not.

Returns:
true if the quality of last read value is "good". For further detail on quality status see IOQuality

isActive

public boolean isActive()
Is the item active - ie. is it automatically being polled

Returns:
true if item is active

setDescription

public void setDescription(String text)
Set descriptive text for this item

Parameters:
text - the description. If null then the action command string is returned on calls to getDescription()
See Also:
getDescription()

getDescription

public String getDescription()
Get descriptive text for this item

Returns:
the description. If descriptive text has not been specified the current value of the action command is returned
See Also:
setDescription(java.lang.String)

getUserObject

public Object getUserObject()
Returns a user object that may optionally having been assigned to this IOItem. The user object may be used for eg. storing ImageIcons or additional descriptive text.

Returns:
optional user object
See Also:
setUserObject(java.lang.Object)

setUserObject

public void setUserObject(Object o)
Set optional user object associated with this IOItem. The user object may be used for eg. storing ImageIcons or additional descriptive text.

Parameters:
o - the Object to associate with this item