AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
An object to keep track of session information internally. More...
#include <can_transport_protocol_base.hpp>
Public Types | |
enum class | Direction { Transmit , Receive } |
Enumerates the possible session directions. More... | |
Public Member Functions | |
TransportProtocolSessionBase (TransportProtocolSessionBase::Direction direction, std::unique_ptr< CANMessageData > data, std::uint32_t parameterGroupNumber, std::uint32_t totalMessageSize, std::shared_ptr< ControlFunction > source, std::shared_ptr< ControlFunction > destination, TransmitCompleteCallback sessionCompleteCallback, void *parentPointer) | |
The constructor for a session. | |
TransportProtocolSessionBase (TransportProtocolSessionBase &&other)=default | |
The move constructor. | |
TransportProtocolSessionBase & | operator= (TransportProtocolSessionBase &&other)=default |
The move assignment operator. | |
virtual | ~TransportProtocolSessionBase ()=default |
The destructor for a session. | |
Direction | get_direction () const |
Get the direction of the session. | |
bool | operator== (const TransportProtocolSessionBase &obj) const |
A useful way to compare session objects to each other for equality,. | |
bool | matches (std::shared_ptr< ControlFunction > other_source, std::shared_ptr< ControlFunction > other_destination) const |
Checks if the source and destination control functions match the given control functions. | |
CANMessageData & | get_data () const |
Get the data buffer for the session. | |
std::uint32_t | get_message_length () const |
Get the total number of bytes that will be sent or received in this session. | |
virtual std::uint32_t | get_total_bytes_transferred () const =0 |
Get the number of bytes that have been sent or received in this session. | |
float | get_percentage_bytes_transferred () const |
Get the percentage of bytes that have been sent or received in this session. | |
std::shared_ptr< ControlFunction > | get_source () const |
Get the control function that is sending the message. | |
std::shared_ptr< ControlFunction > | get_destination () const |
Get the control function that is receiving the message. | |
std::uint32_t | get_parameter_group_number () const |
Get the parameter group number of the message. | |
Protected Member Functions | |
void | update_timestamp () |
Update the timestamp of the session. | |
std::uint32_t | get_time_since_last_update () const |
Get the time that has passed since the last update of the timestamp. | |
void | complete (bool success) const |
Complete the session. | |
Private Attributes | |
Direction | direction |
The direction of the session. | |
std::uint32_t | parameterGroupNumber |
The PGN of the message. | |
std::unique_ptr< CANMessageData > | data |
The data buffer for the message. | |
std::shared_ptr< ControlFunction > | source |
The source control function. | |
std::shared_ptr< ControlFunction > | destination |
The destination control function. | |
std::uint32_t | timestamp_ms = 0 |
A timestamp used to track session timeouts. | |
std::uint32_t | totalMessageSize |
The total size of the message in bytes (the maximum size of a message is from ETP and can fit in an uint32_t) | |
TransmitCompleteCallback | sessionCompleteCallback = nullptr |
A callback that is to be called when the session is completed. | |
void * | parent = nullptr |
A generic context variable that helps identify what object callbacks are destined for. Can be nullptr. | |
An object to keep track of session information internally.
Definition at line 20 of file can_transport_protocol_base.hpp.
|
strong |
Enumerates the possible session directions.
Enumerator | |
---|---|
Transmit | We are transmitting a message. |
Receive | We are receiving a message. |
Definition at line 24 of file can_transport_protocol_base.hpp.
isobus::TransportProtocolSessionBase::TransportProtocolSessionBase | ( | TransportProtocolSessionBase::Direction | direction, |
std::unique_ptr< CANMessageData > | data, | ||
std::uint32_t | parameterGroupNumber, | ||
std::uint32_t | totalMessageSize, | ||
std::shared_ptr< ControlFunction > | source, | ||
std::shared_ptr< ControlFunction > | destination, | ||
TransmitCompleteCallback | sessionCompleteCallback, | ||
void * | parentPointer ) |
The constructor for a session.
[in] | direction | The direction of the session |
[in] | data | Data buffer (will be moved into the session) |
[in] | parameterGroupNumber | The PGN of the message |
[in] | totalMessageSize | The total size of the message in bytes |
[in] | source | The source control function |
[in] | destination | The destination control function |
[in] | sessionCompleteCallback | A callback for when the session completes |
[in] | parentPointer | A generic context object for the tx complete and chunk callbacks |
Definition at line 16 of file can_transport_protocol_base.cpp.
|
default |
The move constructor.
[in] | other | The object to move |
|
protected |
Complete the session.
[in] | success | True if the session was successful, false otherwise |
Definition at line 94 of file can_transport_protocol_base.cpp.
CANMessageData & isobus::TransportProtocolSessionBase::get_data | ( | ) | const |
Get the data buffer for the session.
Definition at line 50 of file can_transport_protocol_base.cpp.
std::shared_ptr< ControlFunction > isobus::TransportProtocolSessionBase::get_destination | ( | ) | const |
Get the control function that is receiving the message.
Definition at line 74 of file can_transport_protocol_base.cpp.
TransportProtocolSessionBase::Direction isobus::TransportProtocolSessionBase::get_direction | ( | ) | const |
Get the direction of the session.
Definition at line 45 of file can_transport_protocol_base.cpp.
std::uint32_t isobus::TransportProtocolSessionBase::get_message_length | ( | ) | const |
Get the total number of bytes that will be sent or received in this session.
Definition at line 55 of file can_transport_protocol_base.cpp.
std::uint32_t isobus::TransportProtocolSessionBase::get_parameter_group_number | ( | ) | const |
Get the parameter group number of the message.
Definition at line 79 of file can_transport_protocol_base.cpp.
float isobus::TransportProtocolSessionBase::get_percentage_bytes_transferred | ( | ) | const |
Get the percentage of bytes that have been sent or received in this session.
Definition at line 65 of file can_transport_protocol_base.cpp.
std::shared_ptr< ControlFunction > isobus::TransportProtocolSessionBase::get_source | ( | ) | const |
Get the control function that is sending the message.
Definition at line 60 of file can_transport_protocol_base.cpp.
|
protected |
Get the time that has passed since the last update of the timestamp.
Definition at line 89 of file can_transport_protocol_base.cpp.
|
pure virtual |
Get the number of bytes that have been sent or received in this session.
Implemented in isobus::ExtendedTransportProtocolManager::ExtendedTransportProtocolSession, isobus::TransportProtocolManager::TransportProtocolSession, and isobus::FastPacketProtocol::FastPacketProtocolSession.
bool isobus::TransportProtocolSessionBase::matches | ( | std::shared_ptr< ControlFunction > | other_source, |
std::shared_ptr< ControlFunction > | other_destination ) const |
Checks if the source and destination control functions match the given control functions.
[in] | other_source | The control function to compare with the source control function. |
[in] | other_destination | The control function to compare with the destination control function. |
Definition at line 40 of file can_transport_protocol_base.cpp.
|
default |
The move assignment operator.
[in] | other | The object to move |
bool isobus::TransportProtocolSessionBase::operator== | ( | const TransportProtocolSessionBase & | obj | ) | const |
A useful way to compare session objects to each other for equality,.
A session is considered equal when the source and destination control functions and parameter group number match. Note that we don't compare the super class, so this should only be used to compare sessions of the same type.
[in] | obj | The object to compare to |
Definition at line 35 of file can_transport_protocol_base.cpp.
|
protected |
Update the timestamp of the session.
Definition at line 84 of file can_transport_protocol_base.cpp.
|
private |
The data buffer for the message.
Definition at line 121 of file can_transport_protocol_base.hpp.
|
private |
The destination control function.
Definition at line 123 of file can_transport_protocol_base.hpp.
|
private |
The direction of the session.
Definition at line 119 of file can_transport_protocol_base.hpp.
|
private |
The PGN of the message.
Definition at line 120 of file can_transport_protocol_base.hpp.
|
private |
A generic context variable that helps identify what object callbacks are destined for. Can be nullptr.
Definition at line 129 of file can_transport_protocol_base.hpp.
|
private |
A callback that is to be called when the session is completed.
Definition at line 128 of file can_transport_protocol_base.hpp.
|
private |
The source control function.
Definition at line 122 of file can_transport_protocol_base.hpp.
|
private |
A timestamp used to track session timeouts.
Definition at line 124 of file can_transport_protocol_base.hpp.
|
private |
The total size of the message in bytes (the maximum size of a message is from ETP and can fit in an uint32_t)
Definition at line 126 of file can_transport_protocol_base.hpp.