OPC UA Event Filter Syntax

Event Filters for the TANI OPC UA Client use a textual representation. The syntax is documented below.

Note: The filter expression is converted to OPC UA format and sent to the server as-is. Support for all of the following operators, type, etc. is therefore dependent on the server.

The filter expression consists of operators and parameters. The operator name is followed by an opening parenthesis "(", zero or more arguments separated by commas ",", and a closing parenthesis ")". Each argument is either a number, a keyword, a string, or another operator.

The available operators are:

OperatorNumber of argumentsDescription
Equals
GreaterThan
LessThan
GreaterThanOrEqual
LessThanOrEqual
2 These are comparison operators. All return a Boolean value. The return value is True if the first argument is found to be equal to, greater than, less than, greater than or equal to, or less than or equal to the second argument, and False otherwise. If the argument values can't be converted to a common type or one of them is Null, the result is False.
IsNull 1 This operator returns a Boolean value. The return value is True if the argument is a Null value and False otherwise.
Like 2 This operator performs a pattern matching operation on a string. It returns a Boolean value. The return value is True if the first argument (after conversion to String) matches the pattern given by the second argument (a String), and False otherwise. If one of the arguments is Null or can't be converted to String, the result is False.
Note: The TANI OPC Server currently doesn't implement this operator.
Not 1 This operator returns a Boolean value. The return value is True if the argument (after conversion to Boolean) evaluates to False, and False if it evaluates to True. If the argument can't be converted to Boolean, the result is False.
Between 3 This operator performs an interval test. It returns a Boolean value. The return value is True if the first argument is found to be greater than or equal to the second argument, and less than or equal to the third argument. If the argument values can't be converted to a common type or one of them is Null, the result is False.
InList 2 or more This operator performs a comparison against a list of values. It returns a Boolean value. The return value is True if the first argument is found to be equal to one of the following arguments.
And, Or 2 These operators perform Boolean operations. Both return a Boolean value. The return value is the logical conjunction or disjunction of the two arguments. If an argument is not convertible to Boolean, it is treated as a Null value. Null values are treated as unknown, and the remaining argument is used to generate a decision. If none is possible, the return value is Null.
Cast 2 This is the type conversion operator. It allows to convert a value (given as the first argument) in a specific data type (given as the second argument as a NodeId). This operator can do explicit conversions that are not allowed implicitly. If the requested conversion is not possible, a Null value is returned.
OfType 1 This operator tests the type of the received event. It returns a Boolean value. The return value is True if the event has the type given by the argument (as a NodeId) or one of its subtypes.
BitwiseAnd, BitwiseOr 2 These operators perform bitwise operations. Both expect values of integral type as arguments and return a value of the common type of the two arguments. The return value is the bitwise AND or OR combination of the two values. If a value can't be converted to an integral type, the return value is Null.
Literal 1 or more This operator generates a constant value, used for e.g. comparing against. The first argument specifies the type of the result value. The number and values of the remaining arguments depend on the type:
  • For the Null type, no additional argument can be specified.
  • For scalar types, exactly one argument follows to specify the value.
  • For array types, each argument after the first specifies one array element. There may be zero, one, or more array elements present.
Note: Matrix literals are currently not supported.
Attribute 1 or 2 This operator accesses the properties of the received event. The first argument gives the browse path of the property to access. The optional second argument specifies the attribute to read and defaults to "Value".
The browse path is specified as a list of QualifiedName values, separated by ".". Each part of the path has its own pair of quote characters and an optional namespace index in front of the name.
Examples: Attribute("EnabledState"."Id", Value) Attribute("1:Custom Property")
Note: Complex browse paths (e.g. specifying reference types or using inverse references) are currently not supported.

The available data types for the "Literal" operator are:

TypeDescriptionValue formatExample
Null The empty value. Used to signal the absence of a useful value or an error condition. None Literal(Null)
Boolean A boolean (truth) value. The allowed literals are "True" and "False". The matching is case-insensitive. Literal(Boolean,True)
SByte, Int16, Int32, Int64 Signed integral values of 8, 16, 32, and 64 bits. An optional minus sign and one or more decimal digits. It is an error to specify a value that can not be represented by the chosen type. Literal(Int32,-12345)
Byte, UInt16, UInt32, UInt64 Unsigned integral values of 8, 16, 32, and 64 bits. One or more decimal digits. It is an error to specify a value that can not be represented by the chosen type. Literal(UInt32,12345)
Float, Double Floating point values of 32 and 64 bits. An optional minus sign, one or more decimal digits, an optional decimal point, optional decimal digits. Literal(Float,3.14)
String A character string. A quote character, a sequence of zero or more characters, and another quote character. To include an actual quote character in a String, double it. A String consisting of a single quote is represented by """". Literal(String,"Example")
DateTime A date and time value. A quote character, the date/time value in ISO8601 timestamp format, and another quote character. Literal(DateTime,"2023-12-24 16:00:00")
Guid A GUID value. A quote character, an opening curly brace, 32 hex characters separated by 4 dashes, a closing curly brace, and another quote character. The curly braces are optional, either both or none must be given. The characters A to F are case-insensitive. Literal(Guid,"{01234567-89AB-CDEF-0123-4567890ABCDEF}")
ByteString A byte string value. A quote character, a sequence of pairs of hex characters, and another quote character. The characters A to F are case-insensitive. Literal(ByteString,"01234567")
XmlElement An XML fragment. Note: This type is not implemented. -
NodeId, ExtendedNodeId A Node ID or Extended Node ID value. A quote character, the node id in the format specified by OPC UA, and another quote character. Literal(NodeId,"ns=1;s=my_variable")
StatusCode An OPC UA status code value. The status code is given as an UInt32 value. Literal(StatusCode,0)
QualifiedName An OPC UA qualified name value. A quote character, optionally a namespace index followed by a colon, the text value, and another quote character. If the namespace is not given, it is assumed to be 0. Literal(QualifiedName,"1:My Variable")
LocalizedText An OPC UA localized text value. A quote character, optionally a locale name followed by a colon, the text value, and another quote character. If the locale is not given, it is assumed to be empty. Literal(LocalizedText,"en:My Variable")

The available attributes for the "Attribute" operators are:

Note: A Server is only required to implement the "Value" attribute for Properties and the "NodeId" attribute for Objects. All other are optional.

Some complete examples:

https://github.com/OPCFoundation/UA-Nodeset/blob/latest/Schema/NodeIds.csv