DataChangeFilter — Triggering and Dead-Zone Filtering
Overview
OPC UA Part 4 §7.17 DataChangeFilter lets the client tell the server "when to push data to me", cutting pointless publish traffic:
- Trigger — Trigger Conditions (Status / StatusValue / StatusValueTimestamp)
- DeadbandType — Deadband Type (None / Absolute / Percent)
- DeadbandValue — Deadband Value
SDK. There are overloads Add of this type and those with a filter, butFilter criteria are not sent to the server., Data is still being reported in full — see "Current Behavior" below for details.
API
| Class / Field | Category | Reading and Writing | Note |
|---|---|---|---|
| DataChangeFilter | Class | — | Filter Configuration (init-only) |
| .Trigger | Properties | Reading and Writing | DataChangeTrigger enumeration, default StatusValue |
| .DeadbandType | Properties | Reading and Writing | DeadbandType Enumeration, default None |
| .DeadbandValue | Properties | Reading and Writing | double, default 0.0 |
| sub.Add(nodeId, attr, samplingMs, mode, queueSize, discardOldest, filter) | Methods | Write | MI Overload with filter (the filter is currently inactive) |
Related Structures:
public enum DataChangeTrigger
{
Status = 0, // Report only when there is a change StatusCode
StatusValue = 1, // StatusCode or Value change (default)
StatusValueTimestamp = 2 // StatusCode / Value / SourceTimestamp Any change
}
public enum DeadbandType
{
None = 0, // No dead zone; any change is reported
Absolute = 1, // Absolute Dead Zone, |new - old| > DeadbandValue Just Reported
Percent = 2 // Percentage Dead Zone: Only reports when |new - old| > EURange.Range × DeadbandValue / 100
}
Code Example
using DarraOpcUa_Client;
using var ua = new DarraOpcUa("opc.tcp://localhost:4840");
ua.Connect();
using var sub = ua.CreateSubscription(publishingIntervalMs: 100);
// 1) Absolute dead zone 0.5 — Reports only when the temperature change exceeds 0.5 degrees
var filter1 = new DataChangeFilter
{
Trigger = DataChangeTrigger.StatusValue,
DeadbandType = DeadbandType.Absolute,
DeadbandValue = 0.5
};
uint mi1 = sub.Add("ns=2;s=Temp",
AttributeId.Value, samplingIntervalMs: 100,
mode: MonitoringMode.Reporting, queueSize: 1, discardOldest: true,
filter: filter1);
// 2) Percentage deadband: 2% — Flow within 2% of the full scale is not reported
var filter2 = new DataChangeFilter
{
Trigger = DataChangeTrigger.StatusValueTimestamp,
DeadbandType = DeadbandType.Percent,
DeadbandValue = 2.0
};
uint mi2 = sub.Add("ns=2;s=Flow",
AttributeId.Value, 100,
MonitoringMode.Reporting, queueSize: 1, discardOldest: true,
filter: filter2);
// 3) Status Change Only — Check for a change in the communication link status
var filter3 = new DataChangeFilter { Trigger = DataChangeTrigger.Status };
uint mi3 = sub.Add("ns=2;s=Comm.Status",
AttributeId.Value, 200, MonitoringMode.Reporting, 1, true, filter3);
sub.DataChanged += (s, e) =>
{
Console.WriteLine($"[mi={e.MonitoredItemHandle}] {e.ValueString} ({e.Status})");
};
Current Behavior (Important)
Overloads Add with "filter"The filter criteria will not be sent to the server, Behaviors that must be avoided without exception:
- MI Register as usual, Filter is not applied; all data is reported in full
- Keep only one copy of the filter locally; Do not restore during reconnection and reconstruction
- It will trigger a "Warn" event so that [subject
Diagnostic] can UI be notified.
So passing a filter now is the same as not passing one at all—dead zones and trigger filtering are required, so please filter the data yourself in the callback DataChanged.
Trigger/DeadbandType/DeadbandValuerefers to Part 4 §7.17 Specified Semantics, which is currently not active on the server- CurrentlyNo Server-side filter-related errors such
BadFilterNotAllowedas — the filter wasn't sent at all
Best Practices
Filtering is currently disabled. Here are the configuration settings (you can use them directly once filtering is enabled):
- Analog: Absolute Deadband is the Default — Intuitive engineering units, such as 0.5°C / 0.1 bar
- Use "Percent" for wide-range signals — For a sensor with a range of 0-1000, writing 1% is more intuitive than writing 10.
- Digital inputs (DI) and outputs (DO) do not require a filter — State transitions are sparse to begin with
- The dead zone shouldn't be too large. — Trend lines may be distorted
- To ensure no samples are missed, turn it up queueSize . — Default
queueSize = 1+discardOldest = trueOnly the latest value is retained; intermediate samples are discarded. If the queue is full, data will be discarded; there is no guarantee that data will not be discarded.
Cross-Language Comparison
| C# | Python | Java | C++ | Rust | C |
|---|---|---|---|---|---|
| DataChangeFilter | DataChangeFilter | DataChangeFilter | DataChangeFilter | DataChangeFilter | DarraUa_DataChangeFilter |
| DataChangeTrigger | DataChangeTrigger | DataChangeTrigger | DataChangeTrigger | DataChangeTrigger | DarraUa_DataChangeTrigger |
| DeadbandType | DeadbandType | DeadbandType | DeadbandType | DeadbandType | DarraUa_DeadbandType |