![]() |
dnp3 (C++ API) 1.1.0
|
Represents a communication channel for a master station. More...
#include <dnp3.hpp>
Public Member Functions | |
| MasterChannel (MasterChannel &&other) noexcept | |
| Transfer ownership of the underlying C-type to this instance and invalidate the other instance. More... | |
| ~MasterChannel () | |
| Shutdown a MasterChannel and release all resources. More... | |
| void | enable () |
| start communications More... | |
| void | disable () |
| stop communications More... | |
| AssociationId | add_association (uint16_t address, const AssociationConfig &config, std::unique_ptr< ReadHandler > read_handler, std::unique_ptr< AssociationHandler > association_handler, std::unique_ptr< AssociationInformation > association_information) |
| Add an association to the channel. More... | |
| void | remove_association (const AssociationId &id) |
| Remove an association from the channel. More... | |
| void | set_decode_level (const DecodeLevel &decode_level) |
| Set the decoding level for the channel. More... | |
| DecodeLevel | get_decode_level () |
| Get the decoding level for the channel. More... | |
| PollId | add_poll (const AssociationId &id, Request &request, std::chrono::steady_clock::duration period) |
| Add a periodic poll to an association. More... | |
| void | remove_poll (const PollId &poll_id) |
| Add a periodic poll to an association. More... | |
| void | demand_poll (const PollId &poll_id) |
| Demand the immediate execution of a poll previously created with MasterChannel::add_poll(). More... | |
| void | read (const AssociationId &association, Request &request, std::unique_ptr< ReadTaskCallback > callback) |
| Perform a read on the association. More... | |
| void | read_with_handler (const AssociationId &association, Request &request, std::unique_ptr< ReadHandler > handler, std::unique_ptr< ReadTaskCallback > callback) |
| Perform a read on the association. More... | |
| void | operate (const AssociationId &association, CommandMode mode, CommandSet &command, std::unique_ptr< CommandTaskCallback > callback) |
| Asynchronously perform a command operation on the association. More... | |
| void | synchronize_time (const AssociationId &association, TimeSyncMode mode, std::unique_ptr< TimeSyncTaskCallback > callback) |
| Asynchronously perform a time sync operation to the association. More... | |
| void | cold_restart (const AssociationId &association, std::unique_ptr< RestartTaskCallback > callback) |
| Asynchronously perform a cold restart operation to the association. More... | |
| void | warm_restart (const AssociationId &association, std::unique_ptr< RestartTaskCallback > callback) |
| Asynchronously perform a warm restart operation to the association. More... | |
| void | check_link_status (const AssociationId &association, std::unique_ptr< LinkStatusCallback > callback) |
| Asynchronously perform a link status check. More... | |
Static Public Member Functions | |
| static MasterChannel | create_tcp_channel (Runtime &runtime, LinkErrorMode link_error_mode, const MasterChannelConfig &config, EndpointList &endpoints, const ConnectStrategy &connect_strategy, std::unique_ptr< ClientStateListener > listener) |
| Create a master channel that connects to the specified TCP endpoint(s) More... | |
| static MasterChannel | create_tls_channel (Runtime &runtime, LinkErrorMode link_error_mode, const MasterChannelConfig &config, EndpointList &endpoints, const ConnectStrategy &connect_strategy, std::unique_ptr< ClientStateListener > listener, const TlsClientConfig &tls_config) |
| Create a master channel that connects to the specified TCP endpoint(s) and establish a TLS session with the remote. More... | |
| static MasterChannel | create_serial_channel (Runtime &runtime, const MasterChannelConfig &config, const std::string &path, const SerialSettings &serial_params, std::chrono::steady_clock::duration open_retry_delay, std::unique_ptr< PortStateListener > listener) |
| Create a master channel on the specified serial port. More... | |
Friends | |
| class | CppMasterChannelFriend |
Represents a communication channel for a master station.
To communicate with a particular outstation, you need to add an association with MasterChannel::add_association().
|
inlinenoexcept |
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
| other | Class from which ownership will be transfer to this instance |
| dnp3::MasterChannel::~MasterChannel | ( | ) |
Shutdown a MasterChannel and release all resources.
| AssociationId dnp3::MasterChannel::add_association | ( | uint16_t | address, |
| const AssociationConfig & | config, | ||
| std::unique_ptr< ReadHandler > | read_handler, | ||
| std::unique_ptr< AssociationHandler > | association_handler, | ||
| std::unique_ptr< AssociationInformation > | association_information | ||
| ) |
Add an association to the channel.
| address | DNP3 data-link address of the remote outstation |
| config | Association configuration |
| read_handler | Interface uses to load measurement data |
| association_handler | Association specific callbacks such as time synchronization |
| association_information | Association information interface |
| ParamException |
| PollId dnp3::MasterChannel::add_poll | ( | const AssociationId & | id, |
| Request & | request, | ||
| std::chrono::steady_clock::duration | period | ||
| ) |
Add a periodic poll to an association.
Each result of the poll will be sent to the ReadHandler of the association.
| id | Association on which to add the poll |
| request | Request to perform |
| period | Period to wait between each poll (in ms) |
| ParamException |
| void dnp3::MasterChannel::check_link_status | ( | const AssociationId & | association, |
| std::unique_ptr< LinkStatusCallback > | callback | ||
| ) |
Asynchronously perform a link status check.
| association | Id of the association |
| callback | callback invoked when the operation completes |
| ParamException |
| void dnp3::MasterChannel::cold_restart | ( | const AssociationId & | association, |
| std::unique_ptr< RestartTaskCallback > | callback | ||
| ) |
Asynchronously perform a cold restart operation to the association.
| association | Id of the association |
| callback | callback invoked when the operation completes |
| ParamException |
|
static |
Create a master channel on the specified serial port.
The returned master must be gracefully shutdown with MasterChannel::~MasterChannel() when done.
| runtime | Runtime to use to drive asynchronous operations of the master |
| config | Generic configuration for the channel |
| path | Path to the serial device. Generally /dev/tty0 on Linux and COM1 on Windows. |
| serial_params | Serial port settings |
| open_retry_delay | delay between attempts to open the serial port |
| listener | Listener to receive updates on the status of the serial port |
NULL if an error occurred | ParamException |
|
static |
Create a master channel that connects to the specified TCP endpoint(s)
| runtime | Runtime to use to drive asynchronous operations of the master |
| link_error_mode | Controls how link errors are handled with respect to the TCP session |
| config | Generic configuration for the channel |
| endpoints | List of IP endpoints. |
| connect_strategy | Controls the timing of (re)connection attempts |
| listener | TCP connection listener used to receive updates on the status of the connection |
NULL if an error occurred | ParamException |
|
static |
Create a master channel that connects to the specified TCP endpoint(s) and establish a TLS session with the remote.
| runtime | Runtime to use to drive asynchronous operations of the master |
| link_error_mode | Controls how link errors are handled with respect to the TCP session |
| config | Generic configuration for the channel |
| endpoints | List of IP endpoints. |
| connect_strategy | Controls the timing of (re)connection attempts |
| listener | TCP connection listener used to receive updates on the status of the connection |
| tls_config | TLS client configuration |
NULL if an error occurred | ParamException |
| void dnp3::MasterChannel::demand_poll | ( | const PollId & | poll_id | ) |
Demand the immediate execution of a poll previously created with MasterChannel::add_poll().
This method returns immediately. The result will be sent to the registered ReadHandler.
This method resets the internal timer of the poll.
| poll_id | Id of the poll |
| ParamException |
| void dnp3::MasterChannel::disable | ( | ) |
stop communications
| ParamException |
| void dnp3::MasterChannel::enable | ( | ) |
start communications
| ParamException |
| DecodeLevel dnp3::MasterChannel::get_decode_level | ( | ) |
| void dnp3::MasterChannel::operate | ( | const AssociationId & | association, |
| CommandMode | mode, | ||
| CommandSet & | command, | ||
| std::unique_ptr< CommandTaskCallback > | callback | ||
| ) |
Asynchronously perform a command operation on the association.
| association | Id of the association |
| mode | Operation mode |
| command | Command to send |
| callback | callback invoked when the operation completes |
| ParamException |
| void dnp3::MasterChannel::read | ( | const AssociationId & | association, |
| Request & | request, | ||
| std::unique_ptr< ReadTaskCallback > | callback | ||
| ) |
Perform a read on the association.
The callback will be called once the read is completely received, but the actual values will be sent to the ReadHandler of the association.
| association | Association on which to perform the read |
| request | Request to send |
| callback | callback invoked when the operation completes |
| ParamException |
| void dnp3::MasterChannel::read_with_handler | ( | const AssociationId & | association, |
| Request & | request, | ||
| std::unique_ptr< ReadHandler > | handler, | ||
| std::unique_ptr< ReadTaskCallback > | callback | ||
| ) |
Perform a read on the association.
The callback will be called once the read is completely received, but the actual values will be sent to the ReadHandler passed as a parameter.
| association | Association on which to perform the read |
| request | Request to send |
| handler | Custom ReadHandler to send the data to |
| callback | callback invoked when the operation completes |
| ParamException |
| void dnp3::MasterChannel::remove_association | ( | const AssociationId & | id | ) |
Remove an association from the channel.
| id | Id of the association |
| ParamException |
| void dnp3::MasterChannel::remove_poll | ( | const PollId & | poll_id | ) |
Add a periodic poll to an association.
Each result of the poll will be sent to the ReadHandler of the association.
| poll_id | Id of the created poll |
| ParamException |
| void dnp3::MasterChannel::set_decode_level | ( | const DecodeLevel & | decode_level | ) |
Set the decoding level for the channel.
| decode_level | Decoding level |
| ParamException |
| void dnp3::MasterChannel::synchronize_time | ( | const AssociationId & | association, |
| TimeSyncMode | mode, | ||
| std::unique_ptr< TimeSyncTaskCallback > | callback | ||
| ) |
Asynchronously perform a time sync operation to the association.
| association | Id of the association |
| mode | Time sync mode |
| callback | callback invoked when the operation completes |
| ParamException |
| void dnp3::MasterChannel::warm_restart | ( | const AssociationId & | association, |
| std::unique_ptr< RestartTaskCallback > | callback | ||
| ) |
Asynchronously perform a warm restart operation to the association.
| association | Id of the association |
| callback | callback invoked when the operation completes |
| ParamException |