Skip to main content

Triggering Links

Overview​

OPC UA Part 4 §5.12.5 SetTriggering makes one MI the trigger; when it fires, a set of linked MI is reported in a burst. Typical scenario: when the threshold fires, window data is replayed (like PLC fault recording).

In the current version, Triggering is always unavailable

add_triggering_links / remove_triggering_links both return StatusCode.BadNotSupported unconditionally — this is unrelated to whether the server implements SetTriggering. The API is kept for parity with C# and currently has no effect on server-side behavior.

API​

MethodsCategoryReading and WritingNote
sub.add_triggering_links(trigger_mi_id, linked_mi_ids)SubscribeWriteAdd a link, Returns List[StatusCode] (Currently, each item is BadNotSupported)
sub.remove_triggering_links(trigger_mi_id, linked_mi_ids)SubscribeWriteRemove Link, Returns List[StatusCode] (Currently, each item is BadNotSupported)
def add_triggering_links(self, trigger_mi_id: int, linked_mi_ids: List[int]) -> List[StatusCode]: ...
def remove_triggering_links(self, trigger_mi_id: int, linked_mi_ids: List[int]) -> List[StatusCode]: ...

Returns a list of length = len(linked_mi_ids), in the same order as the input.linked_mi_ids If an empty list is passed, an empty list is returned.

Code Example​

from darra_opcua import (
DarraOpcUa, AttributeId, MonitoringMode, StatusCode,
)

with DarraOpcUa("opc.tcp://localhost:4840") as ua:
ua.connect()
sub = ua.create_subscription(100)

# 1) Threshold Monitoring (trigger), Reporting
trig_mi = sub.add_node("ns=2;s=TempHigh", attribute=AttributeId.Value,
sampling_interval_ms=200)

# 2) High-frequency signals (linked), Sampling — Not normally reported
mi1 = sub.add_node("ns=2;s=VibrationX", attribute=AttributeId.Value,
sampling_interval_ms=50, mode=MonitoringMode.Sampling,
queue_size=10, discard_oldest=True)
mi2 = sub.add_node("ns=2;s=VibrationY", attribute=AttributeId.Value,
sampling_interval_ms=50, mode=MonitoringMode.Sampling,
queue_size=10, discard_oldest=True)
mi3 = sub.add_node("ns=2;s=VibrationZ", attribute=AttributeId.Value,
sampling_interval_ms=50, mode=MonitoringMode.Sampling,
queue_size=10, discard_oldest=True)

# 3) Set up the link — Currently, each item returns BadNotSupported
add_res = sub.add_triggering_links(trig_mi, [mi1, mi2, mi3])
for i, rc in enumerate(add_res):
print(f"link[{i}] = {rc.name}") # → BadNotSupported

def on_dc(args):
print(f"[mi={args.monitored_item_handle}] {args.value_string}")

sub.data_changed.append(on_dc)

# 4) Disable the linkage
sub.remove_triggering_links(trig_mi, [mi3])

Implementation Notes​

  • Regardless of whether the server supports them SetTriggering, both methods always return the same result BadNotSupported, so the integration is never actually established.
  • When called, it pushes an OpcUaEventCategory.Diagnostic / OpcUaEventSeverity.Warn event with the message "SetTriggering is not available in the current version; Triggering is unavailable" and status code StatusCode.BadNotSupported.
  • The status code returned by the server is hereThere's no way I can get there —— The caller always receives BadNotSupported.

Interaction with MonitoringMode (standard semantics)​

The following table describes the semantics of Part 4 §5.12.5, which apply only after Triggering evaluates to true:

trigger Modelinked ModeBehavior
ReportingSampling"Linked Burst" Reported When Trigger Fires (Typical)
ReportingDisabledlinked Not reported at all
SamplingSamplingIf none are reported, it is invalid.

Best Practices​

  • Data-logging scenario: trigger threshold + Reporting, linked high-frequency + Sampling
  • Check the return value after the call StatusCode; do not assume that the link has been established.
  • linked MI used sub.add_node for mode=MonitoringMode.Sampling construction; not normally reported

Cross-Language Comparison​

C#PythonJavaC++RustC
AddTriggeringLinksadd_triggering_linksaddTriggeringLinksAddTriggeringLinksadd_triggering_linksDarraUa_Subscription_AddTriggeringLinks

On the C# side, it TriggeringExtensions isExtension Methods, Not an instance method OpcUaSubscription of, but sub.AddTriggeringLinks(...) when using it, you must specify the corresponding using namespace.

Next Step​