• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Protocols - OPC UA I/O
  • EventsFromOPC-UA
  • 5.0.0

OPC UA Custom Data Types Event Conversion ChaiScripts

EventsFromOPC-UA

EventsFromOPC-UA

OPC UA includes a system for event-handling, similar to how it is done in the CDP Framework. OPC UA also has a special event class called condition events that can carry information about the state of the object that the event is associated with. The condition events will be sent out when some monitored condition changes. Similar to the CDP alarms, the OPC UA condition events have a special event sub-class called alarm events that can be used to indicate that the object is in a state that requires attention.

Read more about the OPC UA events from the OPC UA reference documentation, at events specification.

EventsFromOPC-UA is a CDP node that can be added to the OPC-UA-Client in order to receive and forward OPC UA events to the CDP system as CDP events.

To start forwarding all OPC UA events to CDP, add an instance of the EventsFromOPC-UA block to the OPC-UA-Client. With the default configuration, the block will start to listen to all the OPC UA events from the OPC UA server, convert and forward them to the CDP system as CDP events. In addition, the block is also able to forward the CDP alarm acknowledge actions to all OPC UA event senders to acknowledge and/or confirm the OPC UA alarm event.

EventsFromOPC-UA has the following configuration properties:

PropertyDescription
FilterSelect<string>Optional SQL-like statement that will be appended to the event filter to the SELECT part. Allows to retrieve some additional OPC UA event attributes from the OPC UA server (for example the ones that are referred to in the FilterWhere statement or in the EventConverterScript). Even when left empty, a minimal set of event attributes that are needed for the block functioning will always be queried. See Event Filter Query Language for more information.
FilterWhere<string>Optional SQL-like statement that will be used as the event filter WHERE part, to instruct the OPC UA server to send only the events that match the query. When left empty, all events will be retrieved. See Event Filter Query Language for more information.
EventConverterScript<string>A ChaiScript to calculate the CDP event attributes (to the value map named CDPEvent) from the OPC UA event attributes (accessible in the value map named UAEvent). See Event Conversion ChaiScripts for more information.
DescriptionScript<string>A ChaiScript to calculate the Description attribute for the CDP event from the OPC UA event attribute values. In case of an empty script, an OPC UA event Comment attribute value will be used.
GroupScript<string>A ChaiScript to calculate the Group attribute for the CDP event from the OPC UA event attribute values.
EventSourceNodeId<string>Together with EventSourceNodeIdType and EventSourceNodeNamespaceIndex properties specifies an OPC UA node id to subscribe the events from. By default, OPC UA Server information object (i=2253) node is subscribed, as that node usually forwards events from all event emitter nodes in the OPC UA server.
EventSourceNodeIdType<string>Together with EventSourceNodeId and EventSourceNodeNamespaceIndex properties specifies an OPC UA node id to subscribe the events from. By default, OPC UA Server information object (i=2253) node is subscribed, as that node usually forwards events from all event emitter nodes in the OPC UA server.
EventSourceNodeNamespaceIndex<unsigned short>Together with EventSourceNodeId and EventSourceNodeIdType properties specifies an OPC UA node id to subscribe the events from. By default, OPC UA Server information object (i=2253) node is subscribed, as that node usually forwards events from all event emitter nodes in the OPC UA server.
AcknowledgeCallsUAMethod<unsigned char>What OPC UA methods (Acknowledge or Confirm or both) are called by the CDP alarm Acknowledge.
UAAcknowledgeComment<string>Text to send to OPC UA event Acknowledge or Confirm method call Comment parameter.

EventsFromOPC-UA state can be observed at runtime via these read-only properties:

PropertyDescription
UAStatusCode<unsigned int>OPC UA status code of the latest events subscription try. Is set to zero when the subscription to events was successful.
UAStatusString<string>OPC UA status string of the latest events subscription try. Indicates the reason for the subscription failure.

You can also add multiple EventsFromOPC-UA blocks to OPC-UA-Client with different configurations. Multiple EventsFromOPC-UA blocks with altered FilterWhere or EventConverterScript can be useful when different types of OPC UA events should be converted using very different conversion logic.

Event Filter Query Language

OPC UA event filtering is an OPC UA core mechanism that enables OPC UA clients to receive only the specific events that are of interest, rather than being flooded with every event generated by the server. That way, by applying tailored filter criteria, an EventsFromOPC-UA block can subscribe only to the events that meet defined conditions - such as a minimum severity level or events originating from specific sources - which helps reduce unnecessary network traffic and processing overhead.

The EventsFromOPC-UA block leverages a query language similar in structure to SQL to define the event filter. The query language consists of two parts: the SELECT part and the WHERE part.

SELECT Part of the Query

The SELECT part of the query is used to specify which event attributes need to be fetched from the server. The SELECT part can be altered via the FilterSelect property. When the FilterSelect is left empty, a minimal set of event attributes that are needed for the block functioning is always queried.

The SELECT part is a comma-separated list of event attribute RelativePaths that are to be fetched from the server.

RelativePath is built up from one or more path elements, each starting with a forward slash (“/”). Some example event attribute ReplativePath's are /EventId, e {/SourceName}, /Severity, /e {/Message}, and /e {/AckedState/Id}.

Read more about the RelativePath format from the OPC UA reference documentation, at RelativePath specification.

WHERE Part of the Query

The WHERE part of the query is used to define the criteria that the events must meet in order to be sent to the client. The WHERE part can be altered via the FilterWhere property. When the FilterWhere is left empty, all events from the OPC UA server will be retrieved.

The WHERE part is a logical expression that can be built from the event attributes that are fetched from the server. The logical expression can be built using the event attributes tested using the following OPC UA filter operators:

OperatorDescriptionExample Expression
==Equal/Severity == 100
<Less than/Severity < 100
>Greater than/Severity > 100
<=Less than or equal/Severity <= 100
>=Greater than or equal/Severity >= 100
NOTUnary notNOT /Severity == 100
ANDLogical and/Severity >= 100 AND /Severity <= 500
BETWEENValue between two values/Severity BETWEEN [100, 500]
OFTYPEOPC UA OfType() operator with type id stringOFTYPE(i=2052)

The WHERE and SELECT parts can be verified using the online OPC UA EventFilter Query Language test tool.

To test out the FilterSelect and FilterWhere statements, combine them into one query statement using SELECT and WHERE parts, like this:

SELECT {FilterSelect property content} WHERE {FilterWhere property content}

Copy this combined query sentence to the Query Input pane and then press the Submit button. When the statements in the query are all valid then a JSON describing the OPC UA SELECT and WHERE clause metadata will be displayed in the Result pane. On the other hand, when something in the query is invalid then an error message will be displayed describing the problem.

OPC UA Custom Data Types Event Conversion ChaiScripts

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top