SetMonitoringMode (C)
Each MonitoredItem has 3 monitoring modes:
| Mode Enumeration | Server-Side Sampling | Server-Side Push | Uses |
|---|---|---|---|
| UA_MI_MODE_DISABLED (0) | × | × | Fully stopped (neither sampling nor push) |
| UA_MI_MODE_SAMPLING (1) | ✓ | × | Sample but Do Not Push (Log History / Dead Zone Calculation) |
| UA_MI_MODE_REPORTING (2, default) | ✓ | ✓ | Operating Normally |
Prerequisite Reading
- To cancel your entire subscription (rather than individual issues MI), see below
SetPublishingMode. - To modify the sampling parameters, see Modify.
API
OPCUA_API DarraUa_Status OPCUA_CALL DarraUa_Subscription_SetMonitoringMode(
DarraUa_SubscriptionHandle h,
DarraUa_MonitoringMode mode,
const uint32_t* mi_handles,
uint32_t count,
DarraUa_Status* out_results);
mi_handles + count Describes a target MI set, with length out_results ≥ count, allocated by the caller. The top-level return value reflects the transport-level state; individual state information is contained in out_results[i].
/* Temporarily suspend all data collection (e.g., during equipment maintenance) */
uint32_t all_mis[100] = { /* ... */ };
DarraUa_Status results[100] = { 0 };
DarraUa_Subscription_SetMonitoringMode(
sub, UA_MI_MODE_DISABLED, all_mis, 100, results);
for (int i = 0; i < 100; ++i)
if (!UA_STATUS_IS_GOOD(results[i]))
printf("mi=%u failed: %s\n", all_mis[i], DarraUa_StatusName(results[i]));
/* Restore after maintenance */
DarraUa_Subscription_SetMonitoringMode(
sub, UA_MI_MODE_REPORTING, all_mis, 100, results);
Single MI Cut
The C SDK has no "simplified single-MI version"; just pass 1 as the array length:
uint32_t one[1] = { mi };
DarraUa_Status r[1] = { 0 };
DarraUa_Subscription_SetMonitoringMode(
sub, UA_MI_MODE_DISABLED, one, 1, r);
Enable or Disable the Entire Feed (PublishingEnabled)
If you want to cancel the entire subscription (rather than individual issues MI), use _SetPublishingMode:
OPCUA_API DarraUa_Status OPCUA_CALL DarraUa_Subscription_SetPublishingMode(
DarraUa_SubscriptionHandle sub,
int32_t enabled);
DarraUa_Subscription_SetPublishingMode(sub, 0); /* Stop */
DarraUa_Subscription_SetPublishingMode(sub, 1); /* Restore */
enabled = 0 Afterward, the server continues to take samples but does not push them; = 1 resume pushing.
Comparison of Three Particle Sizes
| Particle size | API | Applicable |
|---|---|---|
| Subscribe to the entire series | _Subscription_SetPublishingMode | Temporary Service Suspension (Maintenance) |
| A batch of MI | _Subscription_SetMonitoringMode(mode, handles, n) | Some modules are down |
| Single MI | Ibid., n = 1 | Precise Control |
| Delete Completely | _MonitoredItem_Delete(sub, mi) / _Subscription_Delete(sub) | I don't want it anymore—ever. |