Skip to content

Add Monitored Items in the OPC-UA Device Service

The following Monitored Items can be added:

  • Changes to data of Variable Value attributes
  • Object events

The publishing interval can be configured using the publishInterval attribute.

Data Change Monitored Items

Data change Monitored Items provide notifications about changes to the Value attributes of a Variable Type node. When a Variable value is updated, the server sends a notification to inform the subscribed client of the new value.

This can be defined in the device service as below:

 - description: A Simulated Counter
   name: Counter1
   isHidden: false
   properties:
     valueType: Uint32
     readWrite: R
     units: String
     defaultValue: "0"
   attributes:
     nodeID: "1001"
     monitored: "True"
     nsIndex: "3"
     publishInterval: "1000"
     IDType: "NUMERIC"

This device profile excerpt includes the monitored attribute. When set to true, this establishes a subscription to the Counter1 device resource, and readings will published automatically.

The publishInterval sets the interval between events. If this is not specified, it will default to 500 milliseconds. In the above example, this is set to 1000 milliseconds.

Note

The remote server can ignore the publishInterval value when creating a new subscription ID.

Event Monitored Items

Event Monitored Items provide notifications about events that have been triggered on the remote server. When an Event Type is created on a server, representing an event that might be triggered, that Event Type is assigned to an origin node. To subscribe to an Event Type, the client must subscribe to the origin node for the event. When the event is triggered, the server notifies all clients that are subscribed to the origin node of the event.

An Event Monitored Item notification contains mandatory and optional attributes. The OPC-UA Device Service filters out some of these attributes and requests only the following attributes as part of an Event Monitored Item notification:

  • Event ID
  • Severity
  • Source Name
  • Message

When the OPC-UA Device Service receives an Event Monitored Item notification, the attributes are posted to Edge Xpert.

Define an Event Monitored Item in the Device Profile

Care must be taken when defining the device commands section of the device profile to ensure that it matches the expected ordering and type of each reading.

For example, the following extract shows the declaration of an Event Monitored Item in a device profile:

deviceResources:
  - description: Server Events
    name: Event
    isHidden: false
    properties:
      valueType: Uint32
      readWrite: R
      units: String
    attributes:
      IDType: NUMERIC
      monitored: 'true'
      nodeID: '2253'
      nsIndex: '0'
      publishInterval: '500'
  - description: The ID of the event
    name: EventId
    isHidden: false
    properties:
      valueType: Binary
      readWrite: R
  - description: The event message
    name: EventMessage
    isHidden: false
    properties:
      valueType: String
      readWrite: R
  - description: The severity rating of the event
    name: EventSeverity
    isHidden: false
    properties:
      valueType: Uint16
      readWrite: R
  - description: The source of the event
    name: EventSource
    isHidden: false
    properties:
      valueType: String
      readWrite: R
deviceCommands:
  - name: Event
    isHidden: false
    readWrite: R
    resourceOperations:
      - deviceResource: EventId
      - deviceResource: EventMessage
      - deviceResource: EventSeverity
      - deviceResource: EventSource
Back to top