Creating associations
An association is how the master talks to one outstation on a channel. Add one to a MasterChannel with
addAssociation (add_association in Rust), and supply:
| What you supply | What it does |
|---|---|
| Outstation address | Which outstation on the channel the association talks to |
| AssociationConfig | The startup sequence, time synchronization, how the master reacts to the outstation, and timeouts |
| ReadHandler | Receives every value the outstation reports |
| AssociationHandler | Supplies the time for time synchronization |
| AssociationInformation | Reports the start and outcome of each task |
- Rust
- C
- C++
- Java
- C#
let association = channel
.add_association(
outstation_address,
get_association_config(),
Box::new(ExampleReadHandler),
Box::new(ExampleAssociationHandler),
Box::new(ExampleAssociationInformation),
)
.await?;
dnp3_param_error_t err = dnp3_master_channel_add_association(
channel,
OUTSTATION_ADDRESS,
get_association_config(),
get_read_handler(),
get_association_handler(),
get_association_information(),
association_id
);
// check error
auto assoc = channel.add_association(
OUTSTATION_ADDRESS,
get_association_config(),
create_read_handler(),
create_association_handler(),
create_association_information()
);
AssociationId association =
channel.addAssociation(
ushort(OUTSTATION_ADDRESS),
getAssociationConfig(),
new ExampleReadHandler(),
new ExampleAssociationHandler(),
new ExampleAssociationInformation());
var association = channel.AddAssociation(
OutstationAddress,
GetAssociationConfig(),
new ExampleReadHandler(),
new ExampleAssociationHandler(),
new ExampleAssociationInformation()
);
Each outstation address can be used once per channel: the master rejects a second association with the same address.
On a UDP channel, use addUdpAssociation (add_udp_association in Rust), which also takes the outstation's endpoint;
see UDP.
Removing
An association stays on the channel until you remove it, even if you discard what addAssociation returned. Remove it
with removeAssociation on the MasterChannel (in Rust, remove on the association or remove_association on the
channel). This stops its polls and automatic tasks, and any of its requests still waiting in the queue fail.