Subscription Class
The Subscription class used in the OPCUA server side.
Constructor
Subscription
-
options
Parameters:
-
options
Object-
id
Integer- a unique identifier
-
publishingInterval
Integer- optional the publishing interval.
-
maxKeepAliveCount
Integer- optional the max KeepAlive Count.
-
lifeTimeCount
Integer- optional the max Life Time Count
-
publishingEnabled
Boolean -
sessionId
NodeId- [optional]
-
maxNotificationsPerPublish
Integer -
priority
Byte
-
Item Index
Methods
- _addNotificationMessage
- _createMonitoredItemStep2
- _popNotificationToSend
- _publish_pending_notifications *
- _sendKeepAliveResponse
- _tick
- acknowledgeNotification
- adjustSamplingInterval
- discardOldSentNotifications
- extract_notifications_chunk extract up to maxNotificationsPerPublish notifications static
- getAvailableSequenceNumbers
- getMonitoredItem
- getMonitoredItems
- increaseKeepAliveCounter
- increaseLifeTimeCounter
- modify
- notificationHasExpired
- removeMonitoredItem
- resetKeepAliveCounter
- resetLifeTimeAndKeepAliveCounters
- resetLifeTimeCounter
- terminate Calling this method will also remove any monitored items.
Properties
- disabledMonitoredItemCount
- hasMonitoredItemNotifications true if monitored Item have uncollected Notifications
- hasPendingNotifications
- keepAliveCounterHasExpired
- lifeTimeCount
- lifeTimeHasExpired
- maxKeepAliveCount
- maxNotificationsPerPublish
- monitoredItemCount
- monitoredItemIdCounter
- pendingNotificationsCount - number of pending notifications
- publishingInterval
- sentNotificationsCount
- timeToExpiration
- unacknowledgedMessageCount
Methods
_addNotificationMessage
-
notificationData
Parameters:
-
notificationData
ArrayEventNotificationList | StatusChangeNotification>
_createMonitoredItemStep2
-
timestampsToReturn
-
monitoredItemCreateRequest
-
node
Parameters:
-
timestampsToReturn
Object -
monitoredItemCreateRequest
MonitoredItemCreateRequest- the parameters describing the monitored Item to create
-
node
BaseNode
Returns:
_popNotificationToSend
()
NotificationMessage
Extract the next Notification that is ready to be sent to the client.
Returns:
the Notification to send._pending_notifications
_publish_pending_notifications *
()
private
_publish_pending_notifications send a "notification" event:
_sendKeepAliveResponse
()
private
_tick
()
private
adjustSamplingInterval
-
samplingInterval
-
node
adjust monitored item sampling interval
- an samplingInterval ===0 means that we use a event-base model ( no sampling)
- otherwise the sampling is adjusted
Parameters:
-
samplingInterval
Object -
node
Object
Returns:
discardOldSentNotifications
()
private
discardOldSentNotification find all sent notification message that have expired keep-alive and destroy them.
extract_notifications_chunk
extract up to maxNotificationsPerPublish notifications
-
monitoredItems
-
maxNotificationsPerPublish
Parameters:
-
monitoredItems
Array -
maxNotificationsPerPublish
Numberthe maximum number of notification to extract
Returns:
getAvailableSequenceNumbers
()
Integer
returns in an array the sequence numbers of the notifications that haven't been acknowledged yet.
Returns:
getMonitoredItem
-
monitoredItemId
get a monitoredItem by Id.
Parameters:
-
monitoredItemId
Numberthe id of the monitored item to get.
Returns:
getMonitoredItems
-
result.serverHandles
getMonitoredItems is used to get information about monitored items of a subscription.Its intended use is defined in Part 4. This method is the implementation of the Standard OPCUA GetMonitoredItems Method.
Parameters:
-
result.serverHandles
Int32Array of serverHandles for all MonitoredItems of the subscription identified by subscriptionId. result.clientHandles {Int32[]} Array of clientHandles for all MonitoredItems of the subscription identified by subscriptionId. result.statusCode {StatusCode} from spec: This method can be used to get the list of monitored items in a subscription if CreateMonitoredItems failed due to a network interruption and the client does not know if the creation succeeded in the server.
increaseKeepAliveCounter
()
private
increaseLifeTimeCounter
()
private
modify
-
param
Parameters:
-
param
Object-
requestedPublishingInterval
DurationrequestedPublishingInterval =0 means fastest possible
-
requestedLifetimeCount
CounterrequestedLifetimeCount ===0 means no change
-
requestedMaxKeepAliveCount
CounterrequestedMaxKeepAliveCount ===0 means no change
-
maxNotificationsPerPublish
Counter -
priority
Byte
-
notificationHasExpired
-
notification
returns true if the notification has expired
Parameters:
-
notification
Object
Returns:
removeMonitoredItem
-
monitoredItemId
remove a monitored Item from the subscription.
Parameters:
-
monitoredItemId
Numberthe id of the monitored item to get.
resetKeepAliveCounter
()
private
resetLifeTimeAndKeepAliveCounters
()
the server invokes the resetLifeTimeAndKeepAliveCounters method of the subscription when the server has send a Publish Response, so that the subscription can reset its life time counter.
resetLifeTimeCounter
()
private
Reset the Lifetime Counter Variable to the value specified for the lifetime of a Subscription in the CreateSubscription Service( 5.13.2).
terminate
Calling this method will also remove any monitored items.
()
Terminates the subscription.
Properties
disabledMonitoredItemCount
Number
number of disabled monitored items.
hasMonitoredItemNotifications true if monitored Item have uncollected Notifications
Boolean
hasPendingNotifications
Boolean
return True is there are pending notifications for this subscription. (i.e moreNotifications)
keepAliveCounterHasExpired
Boolean true if the keep alive counter has reach its limit.
private
lifeTimeCount
Number
The life time count defines how many times the publish interval expires without having a connection to the client to deliver data. If the life time count reaches maxKeepAliveCount, the subscription will automatically terminate. OPCUA Spec: The life-time count shall be a minimum of three times the keep keep-alive count.
Note: this has to be interpreted as without having a PublishRequest available
Default: 1
lifeTimeHasExpired
boolean - true if the subscription life time has expired.
True if the subscription life time has expired.
maxKeepAliveCount
Number
The keep alive count defines how many times the publish interval need to expires without having notifications available before the server send an empty message. OPCUA Spec says: a value of 0 is invalid.
Default: 10
maxNotificationsPerPublish
Number
#default 0
The maximum number of notifications that the Client wishes to receive in a single Publish response. A value of zero indicates that there is no limit. The number of notifications per Publish is the sum of monitoredItems in the DataChangeNotification and events in the EventNotificationList.
monitoredItemCount
Number
number of monitored items.
monitoredItemIdCounter
Number
number of monitored Item
pendingNotificationsCount - number of pending notifications
Number
publishingInterval
Number
the Subscription publishing interval
Default: 1000
sentNotificationsCount
Number
number of sent notifications
timeToExpiration
Number
number of milliseconds before this subscription times out (lifeTimeHasExpired === true);
unacknowledgedMessageCount
Number
The number of unacknowledged messages saved in the republish queue.
Events
"terminated"
notify the subscription owner that the subscription has been terminated.
expired
notify the subscription owner that the subscription has expired by exceeding its life time.
keepalive
notify the subscription owner that a keepalive message has to be sent.
removeMonitoredItem
notify that a monitored item has been removed from the subscription
Event Payload:
-
monitoredItem
MonitoredItem