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.
- Rust
- C
- C++
- Java
- C#
let poll = association
.add_poll(
ReadRequest::ClassScan(Classes::class123()),
Duration::from_secs(5),
)
.await?;
dnp3_request_t *poll_request = dnp3_request_new_class(false, true, true, true);
dnp3_poll_id_t poll_id;
dnp3_param_error_t err = dnp3_master_channel_add_poll(channel, association_id, poll_request, 5000, &poll_id);
dnp3_request_destroy(poll_request);
// check error
auto event_scan = dnp3::Request::class_request(false, true, true, true);
const auto event_poll = channel.add_poll(assoc, event_scan, std::chrono::seconds(5));
PollId poll =
channel.addPoll(
association, Request.classRequest(false, true, true, true), Duration.ofSeconds(5));
var poll = channel.AddPoll(association, Request.ClassRequest(false, true, true, true), TimeSpan.FromSeconds(5));
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.