AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
isobus::TransportProtocolSessionBase Class Referenceabstract

An object to keep track of session information internally. More...

#include <can_transport_protocol_base.hpp>

Inheritance diagram for isobus::TransportProtocolSessionBase:
[legend]

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.
 
TransportProtocolSessionBaseoperator= (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.
 
CANMessageDataget_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< ControlFunctionget_source () const
 Get the control function that is sending the message.
 
std::shared_ptr< ControlFunctionget_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< CANMessageDatadata
 The data buffer for the message.
 
std::shared_ptr< ControlFunctionsource
 The source control function.
 
std::shared_ptr< ControlFunctiondestination
 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.
 

Detailed Description

An object to keep track of session information internally.

Definition at line 20 of file can_transport_protocol_base.hpp.

Member Enumeration Documentation

◆ Direction

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.

Constructor & Destructor Documentation

◆ TransportProtocolSessionBase() [1/2]

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.

Parameters
[in]directionThe direction of the session
[in]dataData buffer (will be moved into the session)
[in]parameterGroupNumberThe PGN of the message
[in]totalMessageSizeThe total size of the message in bytes
[in]sourceThe source control function
[in]destinationThe destination control function
[in]sessionCompleteCallbackA callback for when the session completes
[in]parentPointerA generic context object for the tx complete and chunk callbacks

Definition at line 16 of file can_transport_protocol_base.cpp.

◆ TransportProtocolSessionBase() [2/2]

isobus::TransportProtocolSessionBase::TransportProtocolSessionBase ( TransportProtocolSessionBase && other)
default

The move constructor.

Parameters
[in]otherThe object to move

Member Function Documentation

◆ complete()

void isobus::TransportProtocolSessionBase::complete ( bool success) const
protected

Complete the session.

Parameters
[in]successTrue if the session was successful, false otherwise

Definition at line 94 of file can_transport_protocol_base.cpp.

Here is the call graph for this function:

◆ get_data()

CANMessageData & isobus::TransportProtocolSessionBase::get_data ( ) const

Get the data buffer for the session.

Returns
The data buffer for the session

Definition at line 50 of file can_transport_protocol_base.cpp.

◆ get_destination()

std::shared_ptr< ControlFunction > isobus::TransportProtocolSessionBase::get_destination ( ) const

Get the control function that is receiving the message.

Returns
The destination control function

Definition at line 74 of file can_transport_protocol_base.cpp.

Here is the caller graph for this function:

◆ get_direction()

TransportProtocolSessionBase::Direction isobus::TransportProtocolSessionBase::get_direction ( ) const

Get the direction of the session.

Returns
The direction of the session

Definition at line 45 of file can_transport_protocol_base.cpp.

◆ get_message_length()

std::uint32_t isobus::TransportProtocolSessionBase::get_message_length ( ) const

Get the total number of bytes that will be sent or received in this session.

Returns
The length of the message in number of bytes

Definition at line 55 of file can_transport_protocol_base.cpp.

Here is the caller graph for this function:

◆ get_parameter_group_number()

std::uint32_t isobus::TransportProtocolSessionBase::get_parameter_group_number ( ) const

Get the parameter group number of the message.

Returns
The PGN of the message

Definition at line 79 of file can_transport_protocol_base.cpp.

Here is the caller graph for this function:

◆ get_percentage_bytes_transferred()

float isobus::TransportProtocolSessionBase::get_percentage_bytes_transferred ( ) const

Get the percentage of bytes that have been sent or received in this session.

Returns
The percentage of bytes that have been sent or received (between 0 and 100)

Definition at line 65 of file can_transport_protocol_base.cpp.

Here is the call graph for this function:

◆ get_source()

std::shared_ptr< ControlFunction > isobus::TransportProtocolSessionBase::get_source ( ) const

Get the control function that is sending the message.

Returns
The source control function

Definition at line 60 of file can_transport_protocol_base.cpp.

◆ get_time_since_last_update()

std::uint32_t isobus::TransportProtocolSessionBase::get_time_since_last_update ( ) const
protected

Get the time that has passed since the last update of the timestamp.

Returns
The duration in milliseconds

Definition at line 89 of file can_transport_protocol_base.cpp.

◆ get_total_bytes_transferred()

virtual std::uint32_t isobus::TransportProtocolSessionBase::get_total_bytes_transferred ( ) const
pure virtual

Get the number of bytes that have been sent or received in this session.

Returns
The number of bytes that have been sent or received

Implemented in isobus::ExtendedTransportProtocolManager::ExtendedTransportProtocolSession, isobus::TransportProtocolManager::TransportProtocolSession, and isobus::FastPacketProtocol::FastPacketProtocolSession.

Here is the caller graph for this function:

◆ matches()

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.

Parameters
[in]other_sourceThe control function to compare with the source control function.
[in]other_destinationThe control function to compare with the destination control function.
Returns
True if the source and destination control functions match the given control functions, false otherwise.

Definition at line 40 of file can_transport_protocol_base.cpp.

◆ operator=()

TransportProtocolSessionBase & isobus::TransportProtocolSessionBase::operator= ( TransportProtocolSessionBase && other)
default

The move assignment operator.

Parameters
[in]otherThe object to move
Returns
A reference to the moved object

◆ operator==()

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.

Parameters
[in]objThe object to compare to
Returns
true if the objects are equal, false if not

Definition at line 35 of file can_transport_protocol_base.cpp.

◆ update_timestamp()

void isobus::TransportProtocolSessionBase::update_timestamp ( )
protected

Update the timestamp of the session.

Definition at line 84 of file can_transport_protocol_base.cpp.

Member Data Documentation

◆ data

std::unique_ptr<CANMessageData> isobus::TransportProtocolSessionBase::data
private

The data buffer for the message.

Definition at line 121 of file can_transport_protocol_base.hpp.

◆ destination

std::shared_ptr<ControlFunction> isobus::TransportProtocolSessionBase::destination
private

The destination control function.

Definition at line 123 of file can_transport_protocol_base.hpp.

◆ direction

Direction isobus::TransportProtocolSessionBase::direction
private

The direction of the session.

Definition at line 119 of file can_transport_protocol_base.hpp.

◆ parameterGroupNumber

std::uint32_t isobus::TransportProtocolSessionBase::parameterGroupNumber
private

The PGN of the message.

Definition at line 120 of file can_transport_protocol_base.hpp.

◆ parent

void* isobus::TransportProtocolSessionBase::parent = nullptr
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.

◆ sessionCompleteCallback

TransmitCompleteCallback isobus::TransportProtocolSessionBase::sessionCompleteCallback = nullptr
private

A callback that is to be called when the session is completed.

Definition at line 128 of file can_transport_protocol_base.hpp.

◆ source

std::shared_ptr<ControlFunction> isobus::TransportProtocolSessionBase::source
private

The source control function.

Definition at line 122 of file can_transport_protocol_base.hpp.

◆ timestamp_ms

std::uint32_t isobus::TransportProtocolSessionBase::timestamp_ms = 0
private

A timestamp used to track session timeouts.

Definition at line 124 of file can_transport_protocol_base.hpp.

◆ totalMessageSize

std::uint32_t isobus::TransportProtocolSessionBase::totalMessageSize
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.


The documentation for this class was generated from the following files: