Skip to main content

DataChangeFilter

Overview​

OPC UA Part 4 §7.17 DataChangeFilter: Trigger / DeadbandType / DeadbandValue — the three-piece set.

API​

monitoring_filter.hpp Only the type has been defined; it hasn't been connected yet. Subscription: There is currently no entry point SetMonitoringFilter; this header only defines the type, and the actual application will read it in the overload Subscription::AddNode.

Class / FieldCategoryReading and WritingNote
DataChangeFilter DataChangeFilter { trigger, deadband_type, deadband_value }Structure—Filter PoD
DataChangeTriggerEnumeration—Status / StatusValue / StatusValueTimestamp
DeadbandTypeEnumeration—None / Absolute / Percent
namespace darra::opcua {

enum class DataChangeTrigger : uint8_t {
Status = 0, // Report only when there is a change StatusCode
StatusValue = 1, // StatusCode Report when "Value" changes (default)
StatusValueTimestamp = 2, // StatusCode / Value / Report any SourceTimestamp changes
};

enum class DeadbandType : uint8_t {
None = 0,
Absolute = 1,
Percent = 2,
};

struct DataChangeFilter {
DataChangeTrigger trigger = DataChangeTrigger::StatusValue;
DeadbandType deadband_type = DeadbandType::None;
double deadband_value = 0.0;
};
}

Related Structure (DataChangeTrigger):

  • Status (0) — Changes StatusCode Only
  • StatusValue (1) — StatusCode or Value (default)
  • StatusValueTimestamp (2) — Any change

Related Structures (DeadbandType):

  • None (0) — No dead zone
  • Absolute (1) — Absolute Dead Zone
  • Percent (2) — Percentage (based on EURange)
The Subscription::AddNode function in C++ does not have a filter parameter.

The actual signature is AddNode(std::string const& node_id, OnDataChange cb, AttributeId attr = AttributeId::Value, double sampling_ms = -1.0):Nonemode / queue_size / discard_oldest / filter These parameters are not overloaded for the filter function either. On the C++ side, currentlyCannot be constructed With a dead zone MonitoredItem.

Both viable approaches are at the C layer:

  • DarraUa_MonitoredItemConfig There are monitoring_mode / queue_size / discard_oldest / deadband_type / inside deadband_value. Let's go DarraUa_MonitoredItem_Create.There are no trigger fields in this structure.
  • C. Convenience Layer DarraUa_MonitoredItem_AddWithFilter(h, ..., const DarraUa_DataChangeFilter* filter):filter Passing NULL indicates that none is set.

Code Example​

Currently, on the C++ side, we can only construct the filter type itself (for interoperability with the C layer),AddNode but we cannot access it:

#include <darra/opcua/client.hpp>
#include <darra/opcua/monitoring_filter.hpp>
#include <iostream>

using namespace darra::opcua;

Session s("opc.tcp://localhost:4840");
s.Connect();
Subscription sub = s.CreateSubscription(100.0);

// 1) Construct a filter type (currently used only for Layer C interoperability; cannot be passed directly to AddNode)
DataChangeFilter f1;
f1.trigger = DataChangeTrigger::StatusValue;
f1.deadband_type = DeadbandType::Absolute;
f1.deadband_value = 0.5;

DataChangeFilter f2;
f2.deadband_type = DeadbandType::Percent;
f2.deadband_value = 2.0;

// 2) In C++, there are AddNode only these four parameters
DarraUa_MonitoredItemHandle mi1 =
sub.AddNode("ns=2;s=Temp", OnValue, AttributeId::Value, 100.0);
DarraUa_MonitoredItemHandle mi2 =
sub.AddNode("ns=2;s=Flow", OnValue, AttributeId::Value, 100.0);

// 3) If you really need to use the dead zone, you have no choice but to go through Layer C (DarraUa_MonitoredItemConfig / AddWithFilter)

Subscription is move-only, so Subscription sub = s.CreateSubscription(...); + sub., you cannot write sub->. A callback isOne MI per person(AddNode The second parameter,std::function<void(DataValue const&)> ), does not have a subscription-level unified callback sub.OnDataChanged(...) like this, nor does it have types such e.client_handle as / DataChangeEventArgs.

Implementation Notes​

  • There is no graceful fallback logic on the C++ side. — Since there is no e.client_handle input parameter to begin with, there’s no question of downgrading, nor is there any “caching the filter locally and restoring it upon reconnection.”
  • Percent Dead Zone Depends on the Server's EURange Property

Best Practices​

  • For analog values, use "Absolute" as the default, such as 0.5°C
  • Use "Percent" for wide-range signals
  • Digital signals do not require a filter.

Cross-Language Comparison​

ItemC#PythonJavaC++RustC
DataChangeFilterDataChangeFilterDataChangeFilterMonitoringFilter.FilterDataChangeFilterDataChangeFilterDarraUa_DataChangeFilter
Enumeration of Trigger ConditionsDataChangeTriggerDataChangeTriggerMonitoringFilter.TriggerDataChangeTriggerDataChangeTriggerDarraUa_DataChangeTrigger
Dead Zone EnumerationDeadbandTypeDeadbandTypeEnums.DeadbandTypeDeadbandTypeDeadbandTypeDarraUa_DeadbandType
Subscription entry points with filtersadd(..., filter)add(..., filter)add(..., MonitoringFilter.Filter)Noneadd(..., filter)DarraUa_MonitoredItem_AddWithFilter

Java has different type names: Yes MonitoringFilter.Filter / MonitoringFilter.Trigger(MonitoringFilter.java), No DataChangeFilter / DataChangeTrigger. C++ is the only language that does not have a "subscription entry point with a filter."

Next Step​