pub struct PlcWorker { /* private fields */ }Expand description
The poller of one PLC; methods are called from the hub, the thread does the I/O.
Implementations§
Source§impl PlcWorker
impl PlcWorker
Sourcepub fn new(
cfg: PlcConfig,
factory: Factory,
options: WorkerOptions,
rules: Arc<Rules>,
on_event: Arc<dyn Fn(Event) + Send + Sync>,
) -> Self
pub fn new( cfg: PlcConfig, factory: Factory, options: WorkerOptions, rules: Arc<Rules>, on_event: Arc<dyn Fn(Event) + Send + Sync>, ) -> Self
A worker of cfg, not started.
Sourcepub fn stop(&self)
pub fn stop(&self)
Stops the thread; writes queued until then still run (a momentary release must reach the PLC).
Sourcepub fn subscriptions(&self) -> usize
pub fn subscriptions(&self) -> usize
Number of tags with a tier.
Sourcepub fn tier_counts(&self) -> Map<String, Json>
pub fn tier_counts(&self) -> Map<String, Json>
{"tier1": n, "tier2": n, "tier3": n}.
Sourcepub fn group_stats(&self) -> Map<String, Json>
pub fn group_stats(&self) -> Map<String, Json>
{group: {rate_ms, tags (at tier 1 now), last_period_ms}} for /stats: the poll groups, and the decorators
(or "tag" for a rate_ms set inline) whose rate a tag was read at.
Sourcepub fn set_tier(&self, tag: &str, tier: Option<u8>)
pub fn set_tier(&self, tag: &str, tier: Option<u8>)
A tag’s tier, None when nothing subscribes it. A tag leaving tier 1 for tier 3 or nothing is read at tier 2 for grace_s first, so a page visited again finds its values fresh.
Sourcepub fn write(&self, tag: &str, value: Value, done: WriteDone)
pub fn write(&self, tag: &str, value: Value, done: WriteDone)
Queues a write, run between the packets of the current tick; done gets the result. Never retried.
Sourcepub fn type_info(&self, tag: &str) -> TypeInfo
pub fn type_info(&self, tag: &str) -> TypeInfo
The type of a tag from the connected controller; a bit is BOOL, the type is None while not connected.
Sourcepub fn description(&self, tag: &str) -> Option<String>
pub fn description(&self, tag: &str) -> Option<String>
The controller description of a tag, if read.