APIs

Show:

a object to manage a subscription on the client side.

Constructor

ClientSubscription

(
  • session
  • options
)

Parameters:

  • session Object
  • options Object
    • requestedPublishingInterval Number
    • requestedLifetimeCount Number
    • requestedMaxKeepAliveCount Number
    • maxNotificationsPerPublish Number
    • publishingEnabled Boolean
    • priority Number

Methods

monitor

(
  • itemToMonitor
  • requestedParameters
  • timestampsToReturn
  • [done]
)
ClientMonitoredItem async

add a monitor item to the subscription

Parameters:

  • itemToMonitor ReadValueId
    • nodeId NodeId
    • attributeId AttributeId
    • indexRange Null | NumericRange
    • dataEncoding
  • requestedParameters MonitoringParameters
    • clientHandle IntegerId
    • samplingInterval Duration
    • filter ExtensionObject | Null

      EventFilter/DataChangeFilter

    • queueSize Counter
    • discardOldest Boolean
  • timestampsToReturn TimestampsToReturn

    //{TimestampsToReturnId}

  • [done] Function optional

    optional done callback

Returns:

ClientMonitoredItem:

Monitoring a simple Value Change

Example:

:

clientSubscription.monitor( // itemToMonitor: { nodeId: "ns=0;i=2258", attributeId: AttributeIds.Value, indexRange: null, dataEncoding: { namespaceIndex: 0, name: null } }, // requestedParameters: { samplingInterval: 3000, filter: null, queueSize: 1, discardOldest: true }, TimestampsToReturn.Neither );

Monitoring a Value Change With a DataChange Filter

options.trigger {DataChangeTrigger} {Status|StatusValue|StatusValueTimestamp} options.deadbandType {DeadbandType} {None|Absolute|Percent} options.deadbandValue {Double}

:

clientSubscription.monitor( // itemToMonitor: { nodeId: "ns=0;i=2258", attributeId: AttributeIds.Value, }, // requestedParameters: { samplingInterval: 3000, filter: new DataChangeFilter({ trigger: DataChangeTrigger.StatusValue, deadbandType: DeadBandType.Absolute, deadbandValue: 0.1 }), queueSize: 1, discardOldest: true }, TimestampsToReturn.Neither );

Monitoring an Event

If the monitor attributeId is EventNotifier then the filter must be specified

:

var filter = new subscription_service.EventFilter({ selectClauses: [ { browsePath: [ {name: 'ActiveState' }, {name: 'id'} ]}, { browsePath: [ {name: 'ConditionName'} ]} ], whereClause: [] });

clientSubscription.monitor( // itemToMonitor: { nodeId: "ns=0;i=2258", attributeId: AttributeIds.EventNotifier, indexRange: null, dataEncoding: { namespaceIndex: 0, name: null } }, // requestedParameters: { samplingInterval: 3000,

   filter: filter,
                    
                       queueSize: 1,
                       discardOldest: true
                    },
                    TimestampsToReturn.Neither
                    

);

ping_server when a session is opened on a server, the client shall send request on a regular basis otherwise the server session object might time out. start_ping make sure that ping_server is called on a regular basis to prevent session to timeout.

(
  • callback
)

Parameters:

  • callback Object

recreateSubscriptionAndMonitoredItem

()

utility function to recreate new subscription

Properties

hasTimedOut

Boolean

set to True when the server has notified us that this sbuscription has timed out ( maxLifeCounter x published interval without being able to process a PublishRequest

Events

failure raised when the server is not responding or is responding with en error to the keep alive read Variable value transaction

internal_error

notify the observers that an error has occurred

Event Payload:

  • err Error

    the error

item_added

notify the observers that a new monitored item has been added to the subscription.

Event Payload:

keepalive

notify the observers that a keep alive Publish Response has been received from the server.

received_notifications

notify the observers that some notifications has been received from the server in a PublishResponse each modified monitored Item

started

notify the observers that the subscription has now started

status_changed

notify the observers that the server has send a status changed notification (such as BadTimeout )

terminated

notify the observers tha the client subscription has terminated