com.prosysopc.ua.client
Class MonitoredDataItem

java.lang.Object
  extended by com.prosysopc.ua.MonitoredItemBase
      extended by com.prosysopc.ua.client.MonitoredItem
          extended by com.prosysopc.ua.client.MonitoredDataItem

public class MonitoredDataItem
extends MonitoredItem

Monitored Item for data change notifications from the server.

Use the MonitoredDataItem to add new items to Subscription when you wish to monitor changes in attribute values - typically in Variable Value attribute.

See Also:
MonitoredEventItem

Field Summary
protected  MonitoredDataItemListener dataChangeListener
           
 
Fields inherited from class com.prosysopc.ua.client.MonitoredItem
logger
 
Fields inherited from class com.prosysopc.ua.MonitoredItemBase
attributeId, clientHandle, dataEncoding, discardOldest, maxQueueSize, monitoredItemId, monitoringMode, nodeId, queueSize
 
Constructor Summary
MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId)
          Create a new monitored item for data changes.
MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
          Create a new monitored item for data changes.
MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.core.MonitoringMode monitoringMode)
          Create a new monitored item for data changes with sampling interval as -1 (i.e. uses the subscription rate by default) If the item is an array item, use #setIndexRange(String) to define an optional range to monitor to.
MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.core.MonitoringMode monitoringMode, double samplingInterval)
          Create a new monitored item for data changes.
MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId)
          Create a new monitored item for data changes.
MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
          Create a new monitored item for data changes.
MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.core.MonitoringMode monitoringMode)
          Create a new monitored item for data changes with sampling interval as -1 (i.e. uses the subscription rate by default) If the item is an array item, use #setIndexRange(String) to define an optional range to monitor to.
MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId, org.opcfoundation.ua.core.MonitoringMode monitoringMode, double samplingInterval)
          Create a new monitored item for data changes.
 
Method Summary
 void addChangeListener(MonitoredDataItemListener listener)
          Deprecated. the items no longer support multicasting: use setDataChangeListener(MonitoredDataItemListener) instead.
protected  void fireDataChange(org.opcfoundation.ua.builtintypes.DataValue prevValue, org.opcfoundation.ua.builtintypes.DataValue newValue)
          Fire the DataChange notification event.
 org.opcfoundation.ua.core.DataChangeFilter getDataChangeFilter()
          Current data change filter.
 MonitoredDataItemListener getDataChangeListener()
           
 MonitoredDataItemListener[] getDataChangeListeners()
          Deprecated. the items no longer support multicasting: use getDataChangeListener() instead.
protected  long getDefaultQueueSize()
           
 org.opcfoundation.ua.utils.NumericRange getIndexRange()
          Optional subrange of an array to monitor to.
 double getSamplingInterval()
          The SamplingInterval.
 org.opcfoundation.ua.builtintypes.DataValue getValue()
           
 boolean hasChangeListener(MonitoredDataItemListener listener)
          Deprecated. the items no longer support multicasting, so this method is obsolete as well: use #getChangeListener() instead.
 boolean removeChangeListener(MonitoredDataItemListener listener)
          Deprecated. the items no longer support multicasting: use setDataChangeListener(MonitoredDataItemListener) instead.
 void setAggregateFilter(org.opcfoundation.ua.core.AggregateFilter filter)
           
 void setDataChangeFilter(org.opcfoundation.ua.core.DataChangeFilter filter)
          Define the filter for selecting which notification the server should send.
 void setDataChangeListener(MonitoredDataItemListener listener)
          Define the listener for the DataChange notifications.
 void setIndexRange(org.opcfoundation.ua.utils.NumericRange indexRange)
          Define the range of array indexes to monitor.
protected  void setRevisedSamplingInterval(Double revisedSamplingInterval)
           
 void setSamplingInterval(double samplingInterval)
          The interval that defines the fastest rate at which the MonitoredItem(s) should be accessed and evaluated.
 void setSamplingInterval(long samplingInterval, TimeUnit unit)
          The interval that defines the fastest rate at which the MonitoredItem(s) should be accessed and evaluated.
protected  void setValue(org.opcfoundation.ua.builtintypes.DataValue value)
           
 
Methods inherited from class com.prosysopc.ua.client.MonitoredItem
clearModified, clearMonitoringModeModified, equals, getErrorCode, getExpandedNodeId, getNodeId, getSubscription, hashCode, isModified, isMonitoringModeModified, itemChanged, monitoringModeChanged, setClientHandle, setErrorCode, setFilterResult, setMonitoredItemId, setRevisedQueueSize, updateFilter, updateQueue
 
Methods inherited from class com.prosysopc.ua.MonitoredItemBase
close, getAttributeId, getClientHandle, getDataEncoding, getFilter, getFilterResult, getMonitoredItemId, getMonitoringMode, getQueueSize, isDiscardOldest, setDiscardOldest, setFilter, setMonitoringMode, setQueueSize, setQueueSize, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dataChangeListener

protected volatile MonitoredDataItemListener dataChangeListener
Constructor Detail

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId)
Create a new monitored item for data changes. Convenience constructor which uses the Value attribute, MonitoringMode.Reporting and "-1" as sampling interval

Parameters:
expandedNodeId - the node to listen to

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId,
                         org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
Create a new monitored item for data changes. Convenience constructor which uses MonitoringMode.Reporting and "-1" as Sampling interval

Parameters:
expandedNodeId - the node to listen to
attributeId - the attribute to listen to

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId,
                         org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                         org.opcfoundation.ua.core.MonitoringMode monitoringMode)
Create a new monitored item for data changes with sampling interval as -1 (i.e. uses the subscription rate by default)

If the item is an array item, use #setIndexRange(String) to define an optional range to monitor to.

Parameters:
expandedNodeId - the node to listen to
attributeId - the attribute to listen to
monitoringMode - monitoring mode to use

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId,
                         org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                         org.opcfoundation.ua.core.MonitoringMode monitoringMode,
                         double samplingInterval)
Create a new monitored item for data changes.

If the item is an array item, use #setIndexRange(String) to define an optional range to monitor to.

Parameters:
expandedNodeId - the node to listen to
attributeId - the attribute to listen to
monitoringMode - monitoring mode to use
samplingInterval - the sampling interval for the item in milliseconds.

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId)
Create a new monitored item for data changes. Convenience constructor which uses the Value attribute, MonitoringMode.Reporting and "-1" as sampling interval

Parameters:
nodeId - the node to listen to

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                         org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId)
Create a new monitored item for data changes. Convenience constructor which uses MonitoringMode.Reporting and "-1" as Sampling interval

Parameters:
nodeId - the node to listen to
attributeId - the attribute to listen to

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                         org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                         org.opcfoundation.ua.core.MonitoringMode monitoringMode)
Create a new monitored item for data changes with sampling interval as -1 (i.e. uses the subscription rate by default)

If the item is an array item, use #setIndexRange(String) to define an optional range to monitor to.

Parameters:
nodeId - the node to listen to
attributeId - the attribute to listen to
monitoringMode - monitoring mode to use

MonitoredDataItem

public MonitoredDataItem(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                         org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
                         org.opcfoundation.ua.core.MonitoringMode monitoringMode,
                         double samplingInterval)
Create a new monitored item for data changes.

If the item is an array item, use #setIndexRange(String) to define an optional range to monitor to.

Parameters:
nodeId - the node to listen to
attributeId - the attribute to listen to
monitoringMode - monitoring mode to use
samplingInterval - the sampling interval for the item in milliseconds.
Method Detail

addChangeListener

@Deprecated
public void addChangeListener(MonitoredDataItemListener listener)
Deprecated. the items no longer support multicasting: use setDataChangeListener(MonitoredDataItemListener) instead.

Define the listener for the DataChange notifications.

Parameters:
listener - Object that implements the MonitoredDataItemListener. Use null to remove the listener.
Throws:
RuntimeException - if the listener is already defined

getDataChangeFilter

public org.opcfoundation.ua.core.DataChangeFilter getDataChangeFilter()
Current data change filter.

Returns:
the current filter
See Also:
setDataChangeFilter(org.opcfoundation.ua.core.DataChangeFilter)

getDataChangeListener

public MonitoredDataItemListener getDataChangeListener()
Returns:
the current data change listener

getDataChangeListeners

@Deprecated
public MonitoredDataItemListener[] getDataChangeListeners()
Deprecated. the items no longer support multicasting: use getDataChangeListener() instead.

Returns:
the list of current data change listeners

getIndexRange

public org.opcfoundation.ua.utils.NumericRange getIndexRange()
Description copied from class: MonitoredItemBase
Optional subrange of an array to monitor to.

Overrides:
getIndexRange in class MonitoredItemBase
Returns:
the index range of an array to monitor.

getSamplingInterval

public double getSamplingInterval()
Description copied from class: MonitoredItemBase
The SamplingInterval. This is only used for the monitored data items. For event items it is always 0.

Overrides:
getSamplingInterval in class MonitoredItemBase
Returns:
the requested sampling interval in milliseconds. If negative, then the publishingInterval of the Subscription is used.

getValue

public org.opcfoundation.ua.builtintypes.DataValue getValue()
Returns:
The latest value received for the monitored item.

hasChangeListener

@Deprecated
public boolean hasChangeListener(MonitoredDataItemListener listener)
Deprecated. the items no longer support multicasting, so this method is obsolete as well: use #getChangeListener() instead.

Check if the item already has the specified notification listener.

Parameters:
listener - the listener to check
Returns:
true if the item has the listener

removeChangeListener

@Deprecated
public boolean removeChangeListener(MonitoredDataItemListener listener)
Deprecated. the items no longer support multicasting: use setDataChangeListener(MonitoredDataItemListener) instead.

Remove a listener for the DataChange notifications.

Parameters:
listener - Object that implements the MonitoredDataItemListener
Returns:
true if the listener was on the list

setAggregateFilter

public void setAggregateFilter(org.opcfoundation.ua.core.AggregateFilter filter)
                        throws ServiceException,
                               StatusException
Throws:
ServiceException
StatusException

setDataChangeFilter

public void setDataChangeFilter(org.opcfoundation.ua.core.DataChangeFilter filter)
                         throws ServiceException,
                                StatusException
Define the filter for selecting which notification the server should send.

The DataChangeFilter defines the conditions under which a data change notification should be reported and, optionally, a range or band for value changes where no DataChange Notification is generated. This range is called Deadband.

The fields of the filter are defined as follows

Name Description
trigger Specifies the conditions under which a data change notification should be reported. It has the following values :

  • STATUS_0 Report a notification ONLY if the StatusCode associated with the value changes. See Table 166 for StatusCodes defined in this Part. Part 8 specifies additional StatusCodes that are valid in particular for device data
  • STATUS_VALUE_1 Report a notification if either the StatusCode or the value change. The Deadband filter can be used in addition for filtering value changes.

    This is the default setting if no filter is set.

  • STATUS_VALUE_TIMESTAMP_2 Report a notification if either StatusCode, value or the SourceTimestamp change. The Deadband filter can be used in addition for filtering value changes.

    If the DataChangeFilter is not applied to the monitored item, STATUS_VALUE_1 is the default reporting behaviour.

deadbandType A value that defines the Deadband type and behaviour.
Value deadbandType
None_0 No Deadband calculation should be applied.
Absolute_1 AbsoluteDeadband (see below)
Percent_2 PercentDeadband
deadbandValue The Deadband is applied only if
  • the trigger includes value changes and
  • the deadbandType is set appropriately.
Deadband is ignored if the status of the data item changes.

DeadbandType = AbsoluteDeadband:

For this type the deadbandValue contains the absolute change in a data value that shall cause a Notification to be generated. This parameter applies only to Variables with any number data type.

An exception that causes a DataChange Notification based on an AbsoluteDeadband is determined as follows:

Exception if (absolute value of (last cached value - current value) > AbsoluteDeadband)

The last cached value is defined as the most recent value previously sent to the Notification channel.

If the item is an array of values, the entire array is returned if any array element exceeds the AbsoluteDeadband.

DeadbandType = PercentDeadband:

For this type of deadband the deadbandValue is defined as the percentage of the EURange. That is, it applies only to AnalogItems with an EURange Property that defines the typical value range for the item. This range shall be multiplied with the deadbandValue to generate an exception limit. An exception is determined as follows:

Exception if (absolute value of (last cached value - current value) > (deadbandValue/100.0) * ((high-low) of EURange)))

If the item is an array of values and any array element exceeds the deadbandValue, the entire monitored array is returned.

Parameters:
filter - the new filter
Throws:
StatusException
ServiceException

setDataChangeListener

public void setDataChangeListener(MonitoredDataItemListener listener)
Define the listener for the DataChange notifications.

Parameters:
listener - Object that implements the MonitoredDataItemListener. Use null to remove the listener.

setIndexRange

public void setIndexRange(org.opcfoundation.ua.utils.NumericRange indexRange)
                   throws ServiceException
Define the range of array indexes to monitor.

This parameter is used to identify a single element of an array, or a single range of indexes for arrays. If a range of elements is specified, the values are returned as a composite. The first element is identified by index 0 (zero).

This parameter is null if the specified Attribute is not an array. However, if the specified Attribute is an array, and this parameter is null, then all elements are to be included in the range.

The format of the parameter is defined formally in the OPC UA specification (Part 4), using BNF notation. In short, the following alternatives can be used:

Dimensions are specified in the order that they appear in the ArrayDimensions Attribute. All dimensions shall be specified for a NumericRange to be valid.

All indexes start with 0. The maximum value for any index is one less than the length of the dimension.

When reading a value the indexes may not specify a range that is within the bounds of the array. The Server shall return a partial result if some elements exist within the range. The Server shall return a Bad_OutOfRange If no elements exist within the range.

Parameters:
indexRange - A number or a numeric range. Null or empty string indicates that this parameter is not used.
Throws:
ServiceException - if the service call to update the value to the server fails

setSamplingInterval

public void setSamplingInterval(double samplingInterval)
                         throws ServiceException
The interval that defines the fastest rate at which the MonitoredItem(s) should be accessed and evaluated. This interval is defined in milliseconds.

The value 0 indicates that the Server should use the fastest practical rate.

The value -1 indicates that the default sampling interval defined by the publishing rate of the Subscription is used.

The Server uses this parameter to assign the MonitoredItems to a sampling interval that it supports.

Parameters:
samplingInterval - the interval in milliseconds
Throws:
ServiceException - if the service call to update the value to the server fails

setSamplingInterval

public void setSamplingInterval(long samplingInterval,
                                TimeUnit unit)
                         throws ServiceException
The interval that defines the fastest rate at which the MonitoredItem(s) should be accessed and evaluated. This interval is defined in milliseconds.

The value 0 indicates that the Server should use the fastest practical rate.

The value -1 indicates that the default sampling interval defined by the publishing rate of the Subscription is used.

The Server uses this parameter to assign the MonitoredItems to a sampling interval that it supports.

Parameters:
samplingInterval - the interval in milliseconds
unit - the time unit of the requestedPublishingInterval argument
Throws:
ServiceException - if the service call to update the value to the server fails

fireDataChange

protected void fireDataChange(org.opcfoundation.ua.builtintypes.DataValue prevValue,
                              org.opcfoundation.ua.builtintypes.DataValue newValue)
Fire the DataChange notification event.

Parameters:
prevValue -
newValue -

getDefaultQueueSize

protected long getDefaultQueueSize()
Specified by:
getDefaultQueueSize in class MonitoredItemBase
Returns:

setRevisedSamplingInterval

protected void setRevisedSamplingInterval(Double revisedSamplingInterval)
Parameters:
revisedSamplingInterval -

setValue

protected void setValue(org.opcfoundation.ua.builtintypes.DataValue value)


Copyright © 2018. All rights reserved.