pub struct SyncSampler { /* private fields */ }Expand description
Utility for periodically sampling a list of nodes/attributes.
When using this you should call run to start the sampler once you have access
to the server context.
Implementations§
Source§impl SyncSampler
impl SyncSampler
Sourcepub fn new() -> SyncSampler
pub fn new() -> SyncSampler
Create a new sync sampler.
Sourcepub fn run(&self, interval: Duration, subscriptions: Arc<SubscriptionCache>)
pub fn run(&self, interval: Duration, subscriptions: Arc<SubscriptionCache>)
Start the sampler. You should avoid calling this multiple times, typically
this is called in build_nodes or init. The sampler will automatically shut down
once it is dropped.
Sourcepub fn add_sampler(
&self,
node_id: NodeId,
attribute: AttributeId,
sampler: impl FnMut() -> Option<DataValue> + Send + 'static,
mode: MonitoringMode,
handle: MonitoredItemHandle,
sampling_interval: Duration,
)
pub fn add_sampler( &self, node_id: NodeId, attribute: AttributeId, sampler: impl FnMut() -> Option<DataValue> + Send + 'static, mode: MonitoringMode, handle: MonitoredItemHandle, sampling_interval: Duration, )
Add a periodic sampler for a monitored item. Note that if a sampler for the given nodeId/attributeId pair already exists, no new sampler will be created. It is assumed that each nodeId/attributeId pair has a single sampler function.
Sourcepub fn update_sampler(
&self,
node_id: &NodeId,
attribute: AttributeId,
handle: MonitoredItemHandle,
sampling_interval: Duration,
)
pub fn update_sampler( &self, node_id: &NodeId, attribute: AttributeId, handle: MonitoredItemHandle, sampling_interval: Duration, )
Update the sample rate of a monitored item. The smallest registered sampling interval for each nodeId/attributeId pair is used. This is also bounded from below by the rate of the SyncSampler itself.
Sourcepub fn set_sampler_mode(
&self,
node_id: &NodeId,
attribute: AttributeId,
handle: MonitoredItemHandle,
mode: MonitoringMode,
)
pub fn set_sampler_mode( &self, node_id: &NodeId, attribute: AttributeId, handle: MonitoredItemHandle, mode: MonitoringMode, )
Set the sampler mode for a node.
Sourcepub fn remove_sampler(
&self,
node_id: &NodeId,
attribute: AttributeId,
handle: MonitoredItemHandle,
)
pub fn remove_sampler( &self, node_id: &NodeId, attribute: AttributeId, handle: MonitoredItemHandle, )
Remove a sampler. The actual sampler will only be fully removed once all samplers for the attribute are gone.