10#ifndef CAN_TRANSPORT_PROTOCOL_BASE_HPP
11#define CAN_TRANSPORT_PROTOCOL_BASE_HPP
40 std::unique_ptr<CANMessageData>
data,
43 std::shared_ptr<ControlFunction>
source,
76 bool matches(std::shared_ptr<ControlFunction> other_source, std::shared_ptr<ControlFunction> other_destination)
const;
96 std::shared_ptr<ControlFunction>
get_source()
const;
121 std::unique_ptr<CANMessageData>
data;
Defines a base class to represent a generic ISOBUS control function.
An abstraction of a CAN message, could be > 8 data bytes.
An interface class that represents data payload of a CAN message of arbitrary length.
A interface class that represents data payload of a CAN message of arbitrary length.
An object to keep track of session information internally.
std::shared_ptr< ControlFunction > destination
The destination control function.
std::uint32_t get_time_since_last_update() const
Get the time that has passed since the last update of the timestamp.
std::uint32_t get_message_length() const
Get the total number of bytes that will be sent or received in this session.
std::shared_ptr< ControlFunction > get_destination() const
Get the control function that is receiving the message.
bool operator==(const TransportProtocolSessionBase &obj) const
A useful way to compare session objects to each other for equality,.
CANMessageData & get_data() const
Get the data buffer for the session.
TransportProtocolSessionBase & operator=(TransportProtocolSessionBase &&other)=default
The move assignment operator.
Direction get_direction() const
Get the direction of the session.
std::uint32_t get_parameter_group_number() const
Get the parameter group number of the message.
Direction direction
The direction of the session.
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.
std::shared_ptr< ControlFunction > get_source() const
Get the control function that is sending the message.
Direction
Enumerates the possible session directions.
@ Receive
We are receiving a message.
@ Transmit
We are transmitting a message.
std::shared_ptr< ControlFunction > source
The source control function.
virtual std::uint32_t get_total_bytes_transferred() const =0
Get the number of bytes that have been sent or received in this session.
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.
TransmitCompleteCallback sessionCompleteCallback
A callback that is to be called when the session is completed.
std::uint32_t parameterGroupNumber
The PGN of the message.
std::uint32_t timestamp_ms
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 u...
void update_timestamp()
Update the timestamp of the session.
std::unique_ptr< CANMessageData > data
The data buffer for the message.
void * parent
A generic context variable that helps identify what object callbacks are destined for....
void complete(bool success) const
Complete the session.
float get_percentage_bytes_transferred() const
Get the percentage of bytes that have been sent or received in this session.
TransportProtocolSessionBase(TransportProtocolSessionBase &&other)=default
The move constructor.
virtual ~TransportProtocolSessionBase()=default
The destructor for a session.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
void(*)(std::uint32_t parameterGroupNumber, std::uint32_t dataLength, std::shared_ptr< InternalControlFunction > sourceControlFunction, std::shared_ptr< ControlFunction > destinationControlFunction, bool successful, void *parentPointer) TransmitCompleteCallback
A callback for when a transmit is completed by the stack.