OPC UA客户端MonitoredDataItem:MonitoringMode.Reporting与Sampling的区别咨询
OPC UA MonitoringMode.Reporting vs. MonitoringMode.Sampling: Key Differences
Great question—this is one of those OPC UA details that’s easy to gloss over but critical when building reliable client applications. Let’s break down the two modes clearly:
Core Behavior Breakdown
MonitoringMode.Sampling
- What it does: The server will regularly sample the data item’s value at your configured sampling interval (as you noted, this interval can’t be smaller than the Subscription’s
PublishingInterval—the server enforces this to avoid conflicting timing). - The big catch: The server does NOT send these sampled values to your client automatically. It only stores the sampled results locally. To get the latest data, your client has to explicitly request it via a
Readservice call. - Best for: Scenarios where you don’t need real-time updates, and only need to pull data on demand (e.g., periodic status checks where latency isn’t a priority). This mode uses less server resources since it avoids managing publish queues and outgoing messages.
MonitoringMode.Reporting
- What it does: This is the standard "active monitoring" mode. The server samples the data item just like in Sampling mode, but it also tracks when the sampled data meets your trigger conditions (e.g., value changes beyond a deadband, quality status changes, or timestamp updates).
- Automatic delivery: When conditions are met, the server adds the updated value to the Subscription’s publish queue. At each
PublishingIntervalcycle, it bundles all qualifying updates from the Subscription’s monitored items and sends them to the client in a single message. - Best for: Real-time use cases where you need immediate notifications of data changes (e.g., industrial sensor alerts, process monitoring). Note that this mode uses more server resources due to queue management and active message delivery.
Quick Recap
- Sampling = Server collects data, client pulls it when needed.
- Reporting = Server collects data, pushes updates to client when changes happen.
And yes, you’re right about the PublishingInterval constraint: no matter which mode you use, the sampling interval can’t be shorter than the Subscription’s publish interval—since the server can’t sample more frequently than it can potentially publish data.
内容的提问来源于stack exchange,提问作者JasonG
相关产品推荐
相关产品推荐

