SetMonitoringMode
Each MonitoredItem has 3 monitoring modes:
enum class MonitoringMode : int32_t {
Disabled = 0,
Sampling = 1,
Reporting = 2,
};
| Mode | Server-Side Sampling | Server-Side Push | Uses |
|---|---|---|---|
| Disabled (0) | × | × | Fully stopped (neither sampling nor push) |
| Sampling (1) | ✓ | × | Sample, evaluate based on the filter, add the value to the queue MI, but do not publish (the result is reported only after switching back to Reporting). |
| Reporting (2, Default) | ✓ | ✓ | Operating Normally |
Default value source: DarraUa_MonitoredItemConfig_Init is initialized monitoring_mode to
UA_MI_MODE_REPORTING, AddNode / AddMany / DarraUa_MonitoredItem_Create all start from this initial value,
so a new is initially MI set to Reporting.
Prerequisite Reading
- To cancel your entire subscription (rather than individual issues MI), see below
SetPublishingEnabled. - To modify the sampling parameters, see Modify.
Batch Cut
std::vector<Status> SetMonitoringMode(
MonitoringMode mode,
std::vector<uint32_t> const& mi_handles);
// Temporarily suspend all data collection (e.g., during equipment maintenance)
std::vector<uint32_t> all_handles = { h1, h2, h3, h4 };
auto statuses = sub.SetMonitoringMode(MonitoringMode::Disabled, all_handles);
Returns std::vector<Status>, The order is the same mi_handles as ., The success or failure of each individual operation is determined by statuses[i];
mi_handles returns an empty vector when empty. Throws an exception when the entire transmission RPC fails Exception("Subscription_SetMonitoringMode failed", rc),
and does not return partial results.
Single MI Cut
Status SetMode(uint32_t mi_handle, MonitoringMode mode);
sub.SetMode(handle, MonitoringMode::Disabled); // Pause a certain MI
sub.SetMode(handle, MonitoringMode::Reporting); // Restore
Enable or Disable the Entire Feed (SetPublishingEnabled)
If you want to cancel the entire subscription (rather than individual issues MI), use SetPublishingEnabled:
sub.SetPublishingEnabled(true); // Open
sub.SetPublishingEnabled(false); // Pause
Comparison of Three Particle Sizes
| Particle size | API | Applicable |
|---|---|---|
| Subscribe to the entire series | sub.SetPublishingEnabled(bool) | Temporary Service Suspension (Maintenance) |
| A batch of MI | sub.SetMonitoringMode(mode, handles) | Some modules are down |
| Single MI | sub.SetMode(handle, mode) | Precise Control |
| Delete Completely | sub.Remove(handle) / Subscription destructor | I don't want it anymore—ever. |