com.prosysopc.ua.client
Class MonitoredEventItem

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

public class MonitoredEventItem
extends MonitoredItem

Monitored Item to use for event subscriptions.

Use the MonitoredEventItem to add new items to Subscription when you wish to monitor events from event notifier nodes in the server.

See Also:
MonitoredDataItem

Field Summary
 
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
MonitoredEventItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId)
          Create a new monitored item for listening server events.
MonitoredEventItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId, org.opcfoundation.ua.core.EventFilter filter)
          Create a new monitored item for listening server events.
MonitoredEventItem(org.opcfoundation.ua.builtintypes.NodeId nodeId)
          Create a new monitored item for listening server events.
MonitoredEventItem(org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.core.EventFilter filter)
          Create a new monitored item for listening server events.
 
Method Summary
 void addEventListener(MonitoredEventItemListener listener)
          Deprecated. the items no longer support multicasting: use setEventListener(MonitoredEventItemListener) instead.
static org.opcfoundation.ua.builtintypes.QualifiedName[] createBrowsePath(org.opcfoundation.ua.builtintypes.QualifiedName qualifiedName)
          Create a BrowsePath from a string, using the default separators: pathSeparator="/", namespaceSeparator=":".
static org.opcfoundation.ua.builtintypes.QualifiedName[] createBrowsePath(org.opcfoundation.ua.builtintypes.QualifiedName qualifiedName, String pathSeparator, String namespaceSeparator)
          Create a BrowsePath from a string, separated by the defined pathSeparator string.
protected  void doEvent(org.opcfoundation.ua.builtintypes.Variant[] eventFields)
           
static org.opcfoundation.ua.builtintypes.QualifiedName[] getDefaultEventFields()
           
protected  long getDefaultQueueSize()
           
 org.opcfoundation.ua.core.EventFilter getEventFilter()
          The current event filter.
 MonitoredEventItemListener getEventListener()
           
 MonitoredEventItemListener[] getEventListeners()
          Deprecated. the items no longer support multicasting: use getEventListener() instead.
 boolean hasEventListener(MonitoredEventItemListener listener)
          Deprecated. the items no longer support multicasting: use getEventListener() instead.
 boolean removeEventListener(MonitoredEventItemListener listener)
          Deprecated. the items no longer support multicasting: use getEventListener() instead.
static void setDefaultEventFields(org.opcfoundation.ua.builtintypes.QualifiedName[] defaultEventFields)
          Define the default fields to use for new items.
 void setEventFilter(org.opcfoundation.ua.core.EventFilter filter)
          Define the event filter.
 void setEventListener(MonitoredEventItemListener listener)
          Define the listener object to listen to the events from this monitored item.
 
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, getIndexRange, getMonitoredItemId, getMonitoringMode, getQueueSize, getSamplingInterval, isDiscardOldest, setDiscardOldest, setFilter, setMonitoringMode, setQueueSize, setQueueSize, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MonitoredEventItem

public MonitoredEventItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId)
Create a new monitored item for listening server events.

Parameters:
expandedNodeId - the node to listen to. Note that the server should return all events in "sub nodes" of the defined node as well. The sub nodes are defined by the HasEventSource references.

MonitoredEventItem

public MonitoredEventItem(org.opcfoundation.ua.builtintypes.ExpandedNodeId expandedNodeId,
                          org.opcfoundation.ua.core.EventFilter filter)
Create a new monitored item for listening server events.

Parameters:
expandedNodeId - the node to listen to. Note that the server should return all events in "sub nodes" of the defined node as well. The sub nodes are defined by the HasEventSource references.
filter - the event filter, which defines the event types and fields that you wish to listen to.

MonitoredEventItem

public MonitoredEventItem(org.opcfoundation.ua.builtintypes.NodeId nodeId)
Create a new monitored item for listening server events.

Parameters:
nodeId - the node to listen to. Note that the server should return all events in "sub nodes" of the defined node as well. The sub nodes are defined by the HasEventSource references.

MonitoredEventItem

public MonitoredEventItem(org.opcfoundation.ua.builtintypes.NodeId nodeId,
                          org.opcfoundation.ua.core.EventFilter filter)
Create a new monitored item for listening server events.

Parameters:
nodeId - the node to listen to. Note that the server should return all events in "sub nodes" of the defined node as well. The sub nodes are defined by the HasEventSource references.
filter - the event filter, which defines the event types and fields that you wish to listen to.
Method Detail

createBrowsePath

public static org.opcfoundation.ua.builtintypes.QualifiedName[] createBrowsePath(org.opcfoundation.ua.builtintypes.QualifiedName qualifiedName)
Create a BrowsePath from a string, using the default separators: pathSeparator="/", namespaceSeparator=":".

Parameters:
qualifiedName - The QualifiedName to parse
Returns:
the browse path as an array of QualifiedName

createBrowsePath

public static org.opcfoundation.ua.builtintypes.QualifiedName[] createBrowsePath(org.opcfoundation.ua.builtintypes.QualifiedName qualifiedName,
                                                                                 String pathSeparator,
                                                                                 String namespaceSeparator)
Create a BrowsePath from a string, separated by the defined pathSeparator string. The namespaceIndex of the QualifiedName is used to initialize every part of the path as well, unless the namespaceIndex is defined before the node name, using the provided namespaceSeparator. For example, QualifiedName[] path1 = createBrowsePath(new QualifiedName("ActiveState/Id"), "/", null); QualifiedName[] path2 = createBrowsePath(new QualifiedName("2:MyEventField/2:MyId"), "/", ":");

Parameters:
qualifiedName - The QualifiedName to parse
pathSeparator - The string used to separate the parts of the browse path
namespaceSeparator - The string used to separate the namespaceIndex in every part of the path. Use null to use the index of the qualifiedName for every part.
Returns:
the browse path as an array of QualifiedName

getDefaultEventFields

public static org.opcfoundation.ua.builtintypes.QualifiedName[] getDefaultEventFields()
Returns:
the default fields used for new event items.
See Also:
setDefaultEventFields(QualifiedName[])

setDefaultEventFields

public static void setDefaultEventFields(org.opcfoundation.ua.builtintypes.QualifiedName[] defaultEventFields)
Define the default fields to use for new items. These are used to initialize the items, if they are created without a default filter.

These fields are used to create the default filter for new items, unless EventFilter is defined.

Note that the NodeId field will be appended to the filter by default.

This is initialized to an empty array by default.

Parameters:
defaultEventFields -

addEventListener

@Deprecated
public void addEventListener(MonitoredEventItemListener listener)
Deprecated. the items no longer support multicasting: use setEventListener(MonitoredEventItemListener) instead.

Add a new listener object to listen to the events from this monitored item.

Parameters:
listener - Object that implements the MonitoredDataItemListener. Must not be null

getEventFilter

public org.opcfoundation.ua.core.EventFilter getEventFilter()
The current event filter. See MonitoredItemBase.setFilter(org.opcfoundation.ua.core.MonitoringFilter) for a description of the filter fields.

Returns:
the current filter used to filter events

getEventListener

public MonitoredEventItemListener getEventListener()
Returns:
the current event listener

getEventListeners

@Deprecated
public MonitoredEventItemListener[] getEventListeners()
Deprecated. the items no longer support multicasting: use getEventListener() instead.

Returns:
the current event listeners

hasEventListener

@Deprecated
public boolean hasEventListener(MonitoredEventItemListener listener)
Deprecated. the items no longer support multicasting: use getEventListener() instead.

Check if the item already has the specified notification listener.

Parameters:
listener - the listener to check. Must not be null
Returns:
true if the item has the listener

removeEventListener

@Deprecated
public boolean removeEventListener(MonitoredEventItemListener listener)
Deprecated. the items no longer support multicasting: use getEventListener() instead.

Remove a listener from the item.

Parameters:
listener - the listener to remove from the item
Returns:
true if the list contained the element

setEventFilter

public void setEventFilter(org.opcfoundation.ua.core.EventFilter filter)
                    throws ServiceException
Define the event filter.

The EventFilter provides for the filtering and content selection of Event Subscriptions. If an Event Notification conforms to the filter defined by the where parameter of the EventFilter, then the Notification is sent to the Client.

Each Event Notification shall include the fields defined by the selectClauses parameter of the EventFilter. The defined EventTypes are specified in Part 5 of the OPC UA specification.

The selectClause and whereClause parameters are specified with the SimpleAttributeOperand structure. This structure requires the NodeId of an EventType supported by the Server and a path to an InstanceDeclaration. An InstanceDeclaration is a Node which can be found by following forward hierarchical references from the fully inherited EventType where the Node is also the source of a HasModellingRule reference. EventTypes, InstanceDeclarations and Modeling Rules are described completely in Part 3 of the specification.

In some cases the same BrowsePath will apply to multiple EventTypes. If the Client specifies the BaseEventType in the SimpleAttributeOperand then the Server shall evaluate the BrowsePath without considering the Type.

Each InstanceDeclaration in the path shall be Object or Variable Node. The final Node in the path may be an Object Node, however, Object Nodes are only available for Events which are visible in the Server's Address Space.

The SimpleAttributeOperand structure allows the Client to specify any Attribute, however, the Server is only required to support the Value Attribute for Variable Nodes and the NodeId Attribute for Object Nodes.

The SimpleAttributeOperand structure is used in the selectClause to select the value to return if an Event meets the criteria specified by the whereClause. A null value is returned in the corresponding event field in the Publish response if the selected field is not part of the Event or an error was returned in the selectClauseResults of the EventFilterResult. If the selected field is available but cannot be returned to Client then the Server shall return a StatusCode that indicates the reason for the error. For example, the Server shall return a Bad_UserAccessDenied error if the value is not accessible to the user associated with the Session. If a Value Attribute has an uncertain or bad StatusCode associated with it then the Server shall return the StatusCode instead of the Value. The Server shall validate the selectClauses when a Client creates or updates the EventFilter. Any errors which are true for all possible Events are returned in the selectClauseResults parameter. The Server shall not report errors that might occur depending on the state or the Server or type of Event. For example, a selectClause that requests a single element in an array would always produce an error if the DataType of the Attribute is a scalar. However, even if the DataType is an array an error could occur if the requested index does not exist for a particular Event, the Server would not report an error in the selectClauseResults parameter if the latter situation existed.

The SimpleAttributeOperand is used in the whereClause to select a value which forms part of a logical expression. These logical expressions are then used to determine whether a particular Event should be reported to the Client. The Server shall use a null value for if any error occurs when a whereClause is evaluated for a particular Event. If a Value Attribute has an uncertain or bad StatusCode associated with it then the Server shall use a null value instead of the Value.

Any basic FilterOperator may be used in the whereClause, however, only the OfType FilterOperator from the complex filters is permitted.

The Server shall validate the whereClauses when a Client creates or updates the EventFilter. Any structural errors in the construction of the filter and any errors which are true for all possible Events are returned in the whereClauseResult parameter. Errors that could occur depending on the state of the Server or the Event are not reported.

SubscriptionControlEvents are special Events which are used to provide control information to the Client. These Events are only published to the MonitoredItems in the Subscription that produced the SubscriptionControlEvent. These Events bypass the whereClause.

Parameters:
filter - the new event filter. If set to null, the default event filter will be used (initialized with getDefaultEventFields())
Throws:
ServiceException - if the filter update fails in the server

setEventListener

public void setEventListener(MonitoredEventItemListener listener)
Define the listener object to listen to the events from this monitored item.

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

doEvent

protected void doEvent(org.opcfoundation.ua.builtintypes.Variant[] eventFields)
Parameters:
eventFields -

getDefaultQueueSize

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


Copyright © 2018. All rights reserved.