Table of Contents

KNet for OPC (KNetOPC): current available predicates

This page describes each predicate available in KNetOPC and its configuration properties. For a general introduction to predicates, how they are applied, and how to configure them in the connector properties file, see Introduction to predicates.

Summary

Predicate Description
KNetOPCPredicateGood Passes records whose OPC-UA StatusCode is Good.
KNetOPCPredicateBad Passes records whose OPC-UA StatusCode is Bad.
KNetOPCPredicateBoolean Passes records whose Boolean node value matches a configured value.
KNetOPCPredicateNotOldThan Passes records whose timestamp is not older than a configured number of seconds.
KNetOPCPredicateValueCompare Passes records whose scalar node value satisfies a comparison condition against a configured threshold.

KNetOPCPredicateGood

Java class: org.mases.knetopc.transformations.predicates.KNetOPCPredicateGood

Passes a record only if the OPC-UA StatusCode of the change notification is Good (i.e. StatusCode.IsGood(statusCode) == true). Use this predicate to ensure only healthy readings reach the Kafka topic.

Configuration properties and example

This predicate has no additional configuration properties beyond the common base properties.

Example

predicates=OnlyGood
predicates.OnlyGood.type=org.mases.knetopc.transformations.predicates.KNetOPCPredicateGood

KNetOPCPredicateBad

Java class: org.mases.knetopc.transformations.predicates.KNetOPCPredicateBad

Passes a record only if the OPC-UA StatusCode of the change notification is Bad (i.e. StatusCode.IsBad(statusCode) == true). Useful for routing fault or error readings to a dedicated diagnostic topic, typically combined with negate=true on the main pipeline to exclude them.

Configuration properties and example

This predicate has no additional configuration properties beyond the common base properties.

Example

The following example uses negate=true to exclude Bad records from the main topic:

predicates=NoBad
predicates.NoBad.type=org.mases.knetopc.transformations.predicates.KNetOPCPredicateBad
predicates.NoBad.negate=true

KNetOPCPredicateBoolean

Java class: org.mases.knetopc.transformations.predicates.KNetOPCPredicateBoolean

Passes a record only if the OPC-UA node value is of Boolean built-in type and its value matches the configured boolean.value. Records whose value is not of Boolean type always fail the predicate.

Configuration properties and example
Property Type Required Default Description
boolean.value boolean Yes The boolean value to match. Set to true to pass only records where the node value is true; set to false to pass only records where the node value is false.

Example

predicates=OnlyActive
predicates.OnlyActive.type=org.mases.knetopc.transformations.predicates.KNetOPCPredicateBoolean
predicates.OnlyActive.boolean.value=true

KNetOPCPredicateNotOldThan

Java class: org.mases.knetopc.transformations.predicates.KNetOPCPredicateNotOldThan

Passes a record only if the elapsed time between the record timestamp and the current time is less than the configured delta.time.in.seconds. The timestamp used is controlled by the UseServerTimestamp property of the connector configuration (see KNetOPC Source configuration): when true the ServerTimestamp is used, otherwise the SourceTimestamp is used.

Setting delta.time.in.seconds to -1 disables the check and all records pass regardless of their age.

Configuration properties and example
Property Type Required Default Description
delta.time.in.seconds integer Yes Maximum age of a record in seconds. Records older than this value are discarded. Set to -1 to disable the check and let all records pass.

Example

Discard records older than 30 seconds:

predicates=FreshOnly
predicates.FreshOnly.type=org.mases.knetopc.transformations.predicates.KNetOPCPredicateNotOldThan
predicates.FreshOnly.delta.time.in.seconds=30

KNetOPCPredicateValueCompare

Java class: org.mases.knetopc.transformations.predicates.KNetOPCPredicateValueCompare

Passes a record only if the OPC-UA node value satisfies a comparison condition against a configured threshold. The predicate works on scalar values only; records with array or non-scalar values are rejected with an error. The OPC-UA BuiltInType of the incoming value must match the builtin configuration property exactly, otherwise the record is rejected with an error.

Supported types, configuration properties and examples

Supported types

builtin value OPC-UA BuiltInType .NET type Supported operators
4 Int16 short greater, lower, equal
5 UInt16 short greater, lower, equal
6 Int32 int greater, lower, equal
7 UInt32 int greater, lower, equal
8 Int64 long greater, lower, equal
9 UInt64 long greater, lower, equal
10 Float double greater, lower, equal
11 Double double greater, lower, equal
12 String string greater, lower, equal, start.with, end.with, contains
Note

For Float and Double types, equality is evaluated with a tolerance of 1E-06. For String type, greater and lower use lexicographic ordering (string.Compare).

Configuration properties

At least one operator flag must be set to true. For numeric types, exactly one of greater, lower, or equal must be true. For String type, one of greater, lower, equal, start.with, end.with, or contains must be true.

Property Type Required Default Description
builtin integer Yes The OPC-UA BuiltInType integer value of the node to compare. See the supported types table above.
greater boolean No false If true, passes records where the value is greater than the configured threshold.
lower boolean No false If true, passes records where the value is lower than the configured threshold.
equal boolean No false If true, passes records where the value is equal to the configured threshold.
start.with boolean No false (String only) If true, passes records where the string value starts with the configured threshold.
end.with boolean No false (String only) If true, passes records where the string value ends with the configured threshold.
contains boolean No false (String only) If true, passes records where the string value contains the configured threshold.
short short Conditional Threshold value used when builtin is 4 (Int16) or 5 (UInt16).
int integer Conditional Threshold value used when builtin is 6 (Int32) or 7 (UInt32).
long long Conditional Threshold value used when builtin is 8 (Int64) or 9 (UInt64).
double double Conditional Threshold value used when builtin is 10 (Float) or 11 (Double).
string string Conditional Threshold value used when builtin is 12 (String).

Examples

Pass only records where an Int32 node value is greater than 100:

predicates=AboveThreshold
predicates.AboveThreshold.type=org.mases.knetopc.transformations.predicates.KNetOPCPredicateValueCompare
predicates.AboveThreshold.builtin=6
predicates.AboveThreshold.greater=true
predicates.AboveThreshold.int=100

Pass only records where a String node value contains "alarm":

predicates=AlarmOnly
predicates.AlarmOnly.type=org.mases.knetopc.transformations.predicates.KNetOPCPredicateValueCompare
predicates.AlarmOnly.builtin=12
predicates.AlarmOnly.contains=true
predicates.AlarmOnly.string=alarm