AssociationInformation
AssociationInformation tells you what the master does with an outstation: every task it runs, whether yours or
automatic, and every unsolicited response it receives. Use it for alarms and metrics. A failing
automatic task, such as a rejected enable-unsolicited, shows up here before anywhere else.
| Callback | Called when |
|---|---|
taskStart | The master starts a task. It receives the task type, function code and sequence number |
taskSuccess | A task completes successfully |
taskFail | A task fails. It receives the reason |
unsolicitedResponse | The master processes an unsolicited response, or receives a repeat of the last one |
Keep-alives and link status checks aren't reported, and neither is a request that fails before it starts, for example because the channel isn't connected: only its caller sees that error.
A successful file read task doesn't mean that the transfer succeeded. The FileReader is the source of truth for the transfer.
- Rust
- C
- C++
- Java
- C#
#[derive(Copy, Clone)]
struct ExampleAssociationInformation;
impl AssociationInformation for ExampleAssociationInformation {}
note
In Rust, every AssociationInformation callback does nothing by default, so you implement only the ones you need.
dnp3_association_information_t get_association_information(void)
{
// NULL callbacks keep their default: do nothing
return (dnp3_association_information_t){
.on_destroy = NULL,
.ctx = NULL,
};
}
// every method keeps the default behavior: do nothing
class AssociationInformation : public dnp3::AssociationInformation {
void task_start(dnp3::TaskType task_type, dnp3::FunctionCode function_code, uint8_t seq) override {}
void task_success(dnp3::TaskType task_type, dnp3::FunctionCode function_code, uint8_t seq) override {}
void task_fail(dnp3::TaskType task_type, dnp3::TaskError error) override {}
void unsolicited_response(bool is_duplicate, uint8_t seq) override {}
};
std::unique_ptr<dnp3::AssociationInformation> create_association_information()
{
return std::make_unique<AssociationInformation>();
}
class ExampleAssociationInformation implements AssociationInformation {
@Override
public void taskStart(TaskType taskType, FunctionCode fc, UByte seq) {}
@Override
public void taskSuccess(TaskType taskType, FunctionCode fc, UByte seq) {}
@Override
public void taskFail(TaskType taskType, TaskError error) {}
@Override
public void unsolicitedResponse(boolean isDuplicate, UByte seq) {}
}
// C# interfaces have no default methods: these keep the default behavior (do nothing)
class ExampleAssociationInformation : IAssociationInformation
{
public void TaskStart(TaskType taskType, FunctionCode functionCode, byte seq) { }
public void TaskSuccess(TaskType taskType, FunctionCode functionCode, byte seq) { }
public void TaskFail(TaskType taskType, TaskError error) { }
public void UnsolicitedResponse(bool isDuplicate, byte seq) { }
}