dk.opi.io.opc.opcclient
Class OpcItem

java.lang.Object
  extended bydk.opi.io.DefaultIOItem
      extended bydk.opi.io.opc.opcclient.OpcItem
All Implemented Interfaces:
IOItem

public class OpcItem
extends DefaultIOItem

This class implements functinality related to items. An items represents the input/output points read/written to/from the devices monitored by the OPC server.

This class has no public constructor - use the OpcGroup.addItem() method to create instances of this class.

See Also:
OpcGroup.addItem(java.lang.String, java.lang.String, boolean, int, java.lang.String)

Field Summary
protected  boolean invalid
          This value is set to true if this item has been invalidated - ie. if it has been removed from the OPC server
protected  Object oldChangeValue
           
 
Fields inherited from class dk.opi.io.DefaultIOItem
actionCommand, active, dataType, description, GOOD_QUALITY_VALUE, ioGroup, name, oldValue, userObject
 
Fields inherited from interface dk.opi.io.IOItem
CACHE_READ, DATATYPE_BOOL, DATATYPE_BOOLARRAY, DATATYPE_DATE, DATATYPE_DOUBLE, DATATYPE_DOUBLEARRAY, DATATYPE_FLOAT, DATATYPE_FLOATARRAY, DATATYPE_INT, DATATYPE_INTARRAY, DATATYPE_STRING, DATATYPE_USE_NATIVE, DEVICE_READ
 
Method Summary
 IOQuality getOldQuality()
          Returns the quality of the last read value, ie. quality corresponding to the item value returned from calling DefaultIOItem.getOldValue() For efficiency reasons the same static IOQuality object is being reused when quality is good, ie. sub-status and limit value for good values will always be IOQuality.GOOD_NON_SPECIFIC and IOQuality.LIMIT_NOT_LIMITED respectively
 boolean isInvalid()
          Get the value of invalid.
 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 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[] values)
          Write the specified array of doubles 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(String value)
          Write the specified value to the device.
 
Methods inherited from class dk.opi.io.DefaultIOItem
getActionCommand, getDataType, getDescription, getGroup, getOldValue, getUserObject, isActive, setActionCommand, setDescription, setOldValue, setUserObject, toString, writeValue, writeValue, writeValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

oldChangeValue

protected Object oldChangeValue

invalid

protected boolean invalid
This value is set to true if this item has been invalidated - ie. if it has been removed from the OPC server

Method Detail

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.
The item value is read from the OPC server cache. 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.

Specified by:
readValue in interface IOItem
Specified by:
readValue in class DefaultIOItem
Returns:
the value read from the item. The object returned are either of type Integer, Boolean etc. depending on the datatype of the 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.

Specified by:
readValue in interface IOItem
Overrides:
readValue in class DefaultIOItem
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 (ie. OPC server). This is fast but the value is only updated with the specified update rate. 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.
Returns:
the value read from the item. The object returned are either of type Integer, Boolean etc. depending on the datatype of the 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

Specified by:
writeIntValue in interface IOItem
Specified by:
writeIntValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Specified by:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Specified by:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Specified by:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Specified by:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Specified by:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Overrides:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Overrides:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Overrides:
writeValue in class DefaultIOItem
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.

Specified by:
writeValue in interface IOItem
Overrides:
writeValue in class DefaultIOItem
Parameters:
values - The array of boolean values to send to the device
Throws:
RbxIOException - thrown if the write operation failed

getOldQuality

public IOQuality getOldQuality()
Returns the quality of the last read value, ie. quality corresponding to the item value returned from calling DefaultIOItem.getOldValue() For efficiency reasons the same static IOQuality object is being reused when quality is good, ie. sub-status and limit value for good values will always be IOQuality.GOOD_NON_SPECIFIC and IOQuality.LIMIT_NOT_LIMITED respectively

Specified by:
getOldQuality in interface IOItem
Overrides:
getOldQuality in class DefaultIOItem
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. This default implementation will always return true. Subclasses may overwrite for specific implementations

Specified by:
isOldQualityGood in interface IOItem
Overrides:
isOldQualityGood in class DefaultIOItem
Returns:
true if the quality of last read value is "good". For further detail on quality status see IOQuality

isInvalid

public boolean isInvalid()
Get the value of invalid. If invlalid excpetion is thrown on read/write to the item. An item is marked invalid when it has been removed from a group

Returns:
value of invalid.