|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.opi.io.DefaultIOItem
This class implements the IOGroup interface and implements a simple polling interface for IOItem values. Ie. if you set the group active this class will poll IOItems belonging to this group and report any changes in item values
Field Summary | |
protected String |
actionCommand
|
protected boolean |
active
|
protected int |
dataType
|
protected String |
description
|
static IOQuality |
GOOD_QUALITY_VALUE
Implementation of IOQuality always returning "good" |
protected IOGroup |
ioGroup
|
protected String |
name
|
protected Object |
oldValue
|
protected Object |
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 |
Constructor Summary | |
DefaultIOItem(IOGroup iog,
String name,
int dataType,
boolean active,
String actionCommand)
Construct a new DefaultIOItem object. |
|
DefaultIOItem(IOGroup iog,
String name,
int dataType,
boolean active,
String actionCommand,
String descr)
Construct a new DefaultIOItem object |
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()
This default implementation will always return good. |
Object |
getOldValue()
Last value read from the device - can be used to efficiently read an 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. |
abstract Object |
readValue()
Abstract method which will 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 |
setOldValue(Object oldValue)
The DefaultIOGroup class will call this method when a value has been read with the readValue() method. |
void |
setUserObject(Object o)
Set optional user object associated with this IOItem. |
String |
toString()
|
abstract void |
writeIntValue(int value)
Deprecated. Replaced by writeValue(int). |
abstract void |
writeValue(boolean value)
Write the specified value to the device. |
abstract void |
writeValue(Boolean value)
Write the specified value to the device. |
void |
writeValue(boolean[] values)
Write the specified array of booleans to the device. |
abstract 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. |
abstract 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[] values)
Write the specified array of integers to the device. |
void |
writeValue(Integer value)
Write the specified value to the device. |
abstract void |
writeValue(String value)
Write the specified value to the device. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface dk.opi.io.IOItem |
writeValue |
Field Detail |
protected IOGroup ioGroup
protected String name
protected int dataType
protected boolean active
protected String actionCommand
protected Object oldValue
protected String description
protected Object userObject
public static final IOQuality GOOD_QUALITY_VALUE
Constructor Detail |
public DefaultIOItem(IOGroup iog, String name, int dataType, boolean active, String actionCommand)
iog
- what group this item belongs toname
- name of the group. Must be unique within this serverdataType
- any of the types IOItem.DATATYPE_INT etc.active
- if items in this group are going to be monitoredactionCommand
- optional string users can use to quickly identify an IOItem when
for instance an item is sent to an IOListenerpublic DefaultIOItem(IOGroup iog, String name, int dataType, boolean active, String actionCommand, String descr)
iog
- what group this item belongs toname
- name of the group. Must be unique within this serverdataType
- any of the types IOItem.DATATYPE_INT etc.active
- if items in this group are going to be monitoredactionCommand
- optional string users can use to quickly identify an IOItem when
for instance an item is sent to an IOListenerdescr
- description of the item. Can be queried by a call to getDescription()Method Detail |
public IOGroup getGroup()
getGroup
in interface IOItem
public abstract Object readValue() throws RbxIOException
readValue
in interface IOItem
RbxIOException
- thrown if the read operation failedpublic Object readValue(int dataSource) throws RbxIOException
readValue
in interface IOItem
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.
RbxIOException
- thrown if the read operation failedpublic abstract void writeIntValue(int value) throws RbxIOException
writeIntValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic abstract void writeValue(float value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic abstract void writeValue(double value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic abstract void writeValue(boolean value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic void writeValue(Integer value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic void writeValue(Float value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic void writeValue(Double value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic abstract void writeValue(String value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic abstract void writeValue(Boolean value) throws RbxIOException
writeValue
in interface IOItem
value
- The value to send to the device
RbxIOException
- thrown if the write operation failedpublic void writeValue(int[] values) throws RbxIOException
writeValue
in interface IOItem
values
- The array of integer values to send to the device
RbxIOException
- thrown if the write operation failedpublic void writeValue(float[] values) throws RbxIOException
writeValue
in interface IOItem
values
- The array of float values to send to the device
RbxIOException
- thrown if the write operation failedpublic void writeValue(double[] values) throws RbxIOException
writeValue
in interface IOItem
values
- The array of double values to send to the device
RbxIOException
- thrown if the write operation failedpublic void writeValue(boolean[] values) throws RbxIOException
writeValue
in interface IOItem
values
- The array of boolean values to send to the device
RbxIOException
- thrown if the write operation failedpublic String getActionCommand()
getActionCommand
in interface IOItem
public void setActionCommand(String aCmd)
setActionCommand
in interface IOItem
aCmd
- any users defined string including nullpublic int getDataType()
getDataType
in interface IOItem
public void setOldValue(Object oldValue)
oldValue
- last read value for this item. The Object type must correspond to the
dataType of this item.IOItem.DATATYPE_INT
public Object getOldValue()
getOldValue
in interface IOItem
IOItem.DATATYPE_INT
public IOQuality getOldQuality()
getOldValue()
This default implementation will always return good. Subclasses may
overwrite for specific implementations
getOldQuality
in interface IOItem
IOQuality
. Guaranteed
never to return null.public boolean isOldQualityGood()
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
isOldQualityGood
in interface IOItem
IOQuality
public String toString()
public boolean isActive()
isActive
in interface IOItem
public void setDescription(String text)
setDescription
in interface IOItem
text
- the description. If null then the action command string is returned
on calls to getDescription()getDescription()
public String getDescription()
getDescription
in interface IOItem
setDescription(java.lang.String)
public Object getUserObject()
getUserObject
in interface IOItem
setUserObject(java.lang.Object)
public void setUserObject(Object o)
setUserObject
in interface IOItem
o
- the Object to associate with this item
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |