Skip to main content

Polls and one-time reads

A master gets measurement data by reading it from the outstation, either on a schedule with a poll or once with a one-time read. Both send the values to the association's ReadHandler, unless you pass your own handler for a one-time read.

A typical design polls events (Class 1, 2, 3) often and integrity (Class 0, 1, 2, 3) rarely. With unsolicited reporting you may need only the occasional integrity poll.

Read requests​

Polls and one-time reads both take a request that says what to read. It's a ReadRequest in Rust and a Request in the bindings, and it can ask for:

  • Classes (any of 0, 1, 2, 3)
  • A range of points of a variation
  • All the points of a variation
  • Device attributes

Polls​

Add a poll to an association with the request and the period. You usually add polls before calling MasterChannel.enable(), though you can add or remove them at any time.

let poll = association
.add_poll(
ReadRequest::ClassScan(Classes::class123()),
Duration::from_secs(5),
)
.await?;

In Rust, add_poll returns a PollHandle: call demand() on it to make the poll due at once, or remove() to remove it. The bindings return a poll id that you pass to MasterChannel.demandPoll() and MasterChannel.removePoll().

See Scheduling for when polls run and how they share the channel with other requests.

One-time reads​

Call read to read once. It completes when the outstation's whole response has been received, and the values go to the association's ReadHandler. In Rust it's a method of the AssociationHandle; in the bindings it's a MasterChannel method that takes the association id.

To send one read's values somewhere else, call read_with_handler (readWithHandler in the bindings) with a ReadHandler of your own. That read's values go to the handler you pass instead of the association's.

The device attributes example is a one-time read.