com.prosysopc.ua.client
Interface SubscriptionNotificationListener

All Known Implementing Classes:
SubscriptionNotificationAdapter

public interface SubscriptionNotificationListener

Event listener for OPC UA Notification events from a Subscription. Whenever a new subscription response is received from the server, the notifications in it are broken down and the data is taken to the monitored items. You can listen to the changes either in every MonitoredItem ( MonitoredDataItemListener) or in the Subscription. These events are from the subscription.

onDataChange(com.prosysopc.ua.client.Subscription, com.prosysopc.ua.client.MonitoredDataItem, org.opcfoundation.ua.builtintypes.DataValue) is called for every data change in the message.

onStatusChange is called for the StatusChangeNotification, if it is in the message.

onEvent is called for every event in the message.

onError is called for every error while handling the item data.

onNotification is called once for each notificationData (which can be a DataChange, EventNotification or StatusChangeNotification) after the notification is taken to the items and the other events are called.


Method Summary
 void onBufferOverflow(Subscription subscription, org.opcfoundation.ua.builtintypes.UnsignedInteger sequenceNumber, org.opcfoundation.ua.builtintypes.ExtensionObject[] notificationData)
          Notification that the internal buffer for notificationData has overflown.
 void onDataChange(Subscription subscription, MonitoredDataItem item, org.opcfoundation.ua.builtintypes.DataValue newValue)
          Notification of a value change.
 void onError(Subscription subscription, Object notification, Exception exception)
          Notification of an error while handling the subscription notification.
 void onEvent(Subscription subscription, MonitoredEventItem item, org.opcfoundation.ua.builtintypes.Variant[] eventFields)
          Notification of event data.
 long onMissingData(org.opcfoundation.ua.builtintypes.UnsignedInteger lastSequenceNumber, long sequenceNumber, long newSequenceNumber, org.opcfoundation.ua.builtintypes.StatusCode serviceResult)
          Notification of a missing notificationData packet.
 void onNotificationData(Subscription subscription, org.opcfoundation.ua.core.NotificationData notification)
          Notification of a new notificationData.
 void onStatusChange(Subscription subscription, org.opcfoundation.ua.builtintypes.StatusCode oldStatus, org.opcfoundation.ua.builtintypes.StatusCode newStatus, org.opcfoundation.ua.builtintypes.DiagnosticInfo diagnosticInfo)
          Notification of the subscription status change.
 

Method Detail

onBufferOverflow

void onBufferOverflow(Subscription subscription,
                      org.opcfoundation.ua.builtintypes.UnsignedInteger sequenceNumber,
                      org.opcfoundation.ua.builtintypes.ExtensionObject[] notificationData)
Notification that the internal buffer for notificationData has overflown. If this happens, you are retrieving more data from the server than your application can handle. You can try to increase the buffer size at Subscription.setNotificationBufferSize(int) or modify the Subscription parameters so that you are not requesting that much data.

Although you get the discarded data in the event, you should not normally try to handle it, since it will not help. But you may record it as a reference.

Parameters:
subscription - the subscription that is sending the notification
sequenceNumber - the oldest sequence number in the buffer - this one is being discarded.
notificationData - the data that is being discarded.

onDataChange

void onDataChange(Subscription subscription,
                  MonitoredDataItem item,
                  org.opcfoundation.ua.builtintypes.DataValue newValue)
Notification of a value change. The method is called before the newValue is written to the monitoredItem. It is called once for every value in the notification.

Parameters:
subscription - the subscription that is sending the notification
item - the MonitoredItem that changed
newValue - the new value for the item

onError

void onError(Subscription subscription,
             Object notification,
             Exception exception)
Notification of an error while handling the subscription notification. The errors may occur, if the Subscription notification is referring to an item that does not exist (StatusException, exception.getStatusCode().getValue() .equals(StatusCodes.Bad_MonitoredItemIdInvalid)) or refers to an item of the wrong type (ClassCastException). It is also called, if there is an unhandled exception while calling the other notifications events.

Parameters:
subscription - the subscription whose notification was handled when the error occurred
notification - the notification, either a MonitoredItemNotification or an EventList or an ExtensionObject in case it cannot be decoded
exception - the error that occurred, usually a StatusException or ClassCastException

onEvent

void onEvent(Subscription subscription,
             MonitoredEventItem item,
             org.opcfoundation.ua.builtintypes.Variant[] eventFields)
Notification of event data. The method is called once for every monitored event item in the notification.

Parameters:
subscription - the subscription that is sending the notification
item - the monitored item to which this event applies to
eventFields - the values for the event fields that were "ordered" in the item. Refer to the item for the respective fields.

onMissingData

long onMissingData(org.opcfoundation.ua.builtintypes.UnsignedInteger lastSequenceNumber,
                   long sequenceNumber,
                   long newSequenceNumber,
                   org.opcfoundation.ua.builtintypes.StatusCode serviceResult)
Notification of a missing notificationData packet. The method is called, when the client notices that a notification data packet has been missed and is no longer available from the server.

If Subscription.isRetransmissionEnabled() is true, the client will try to get the missing data automatically from the server using the Republish service. However, if the server no longer has this packet available, there is a chance that data has been missed. In this case, this event is called to notify your application.

You should return 0 or (modified) newSequenceNumber if you wish to proceed with Republish. Note that the client use the AvailableSequenceNumbers that it has received from the server in previous PublishResponse messages. As necessary, the client will also skip SequenceNumbers, if the server responds that the numbers are no longer available.

Parameters:
lastSequenceNumber - the sequenceNumber of the previous packet received
sequenceNumber - the sequenceNumber of the next packet received
newSequenceNumber - the sequenceNumber that the client will try to fetch next with a Republish service. If Republish is not used, it is 0.
serviceResult - The statusCode of the failed Republish call. If the packet is missing, serviceResult.getValue() equals to StatusCodes.Bad_MessageNotAvailable. Otherwise it may be a call failure error. If Republish is not used, the error is null.
Returns:
newSequenceNumber that the client should use. If 0, the original newSequenceNumber will be used. If it equals to sequenceNumber, Republish is skipped.

onNotificationData

void onNotificationData(Subscription subscription,
                        org.opcfoundation.ua.core.NotificationData notification)
Notification of a new notificationData. If you wish to handle the complete notification package yourself, you can listen to this event, instead of the other events in the interface.

Parameters:
subscription - the subscription that is sending the notification
notification - the notification "packet"

onStatusChange

void onStatusChange(Subscription subscription,
                    org.opcfoundation.ua.builtintypes.StatusCode oldStatus,
                    org.opcfoundation.ua.builtintypes.StatusCode newStatus,
                    org.opcfoundation.ua.builtintypes.DiagnosticInfo diagnosticInfo)
Notification of the subscription status change. A status change may occur, for example, when the subscription is transferred to a new session: a StatusChange notification is then sent to the old session.

Parameters:
subscription - the subscription that is sending the notification
oldStatus - the previous status
newStatus - the new status
diagnosticInfo - optional diagnostic information related to the status change


Copyright © 2018. All rights reserved.