Skip to main content

SetMonitoringMode

Each MonitoredItem has 3 monitoring modes:

ModeServer-Side SamplingServer-Side PushUses
Disabled (0)××Fully stopped (neither sampling nor push)
Sampling (1)✓×Sample but do not push
Reporting (2, Default)✓✓Operating Normally

(Consistent with Part 4, §5.12.2 .)

Prerequisite Reading
  • To cancel your entire subscription (rather than individual issues MI), see below PublishingEnabled.
  • To modify the sampling parameters, see Modify.

Batch Cut​

public IReadOnlyList<StatusCode> SetMonitoringMode(
MonitoringMode mode,
IReadOnlyList<uint> miHandles);
// Temporarily suspend all data collection (e.g., during equipment maintenance)
var statuses = sub.SetMonitoringMode(MonitoringMode.Disabled, allHandles);

Returns status codes item by item, in the same miHandles order as. If the entire RPC returns a status code other than "Good," a is thrown OpcUaException; if null is passed miHandles ArgumentNullException, a is thrown; if an empty array is passed, an empty list is returned. Items for which the switch was successful SDK are remembered and restored according to the new pattern when reconnecting or rebuilding (see Subscription Resumes Automatically)。

Single MI Cut​

public StatusCode SetMode(uint monitoredItemHandle, MonitoringMode mode);
sub.SetMode(handle, MonitoringMode.Disabled);   // Pause a certain MI
sub.SetMode(handle, MonitoringMode.Reporting); // Restore

Enable or Disable the Entire Feed (PublishingEnabled)​

If you want to cancel the entire subscription (rather than individual issues MI), use PublishingEnabled:

sub.PublishingEnabled = StatusCode.Good;  // Open → SetPublishingMode(1)
sub.PublishingEnabled = StatusCode.Bad; // Close → SetPublishingMode(0)
This is a set-only property

PublishingEnabled of StatusCode typeWrite only Properties, When I run it, it doesn't compile.. Any value Good other than is treated as "off." Switch resultDoes not return a status code to external systems, CallerI can't tell if this switch was turned on successfully. — You need to check whether there is any data left in your subscription.

Comparison of Three Particle Sizes​

Particle sizeAPIApplicable
Subscribe to the entire seriessub.PublishingEnabledTemporary Service Suspension (Maintenance)
A batch of MIsub.SetMonitoringMode(mode, handles)Some modules are down
Single MIsub.SetMode(handle, mode)Precise Control
Delete Completelysub.Remove(handle) / sub.Dispose()I don't want it anymore—ever.

Next Step​