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

A protocol that handles PGN requests. More...

#include <can_parameter_group_number_request_protocol.hpp>

Classes

class  PGNRequestCallbackInfo
 A storage class for holding PGN callbacks and their associated PGN. More...
 
class  PGNRequestForRepetitionRateCallbackInfo
 A storage class for holding PGN callbacks and their associated PGN. More...
 

Public Member Functions

 ParameterGroupNumberRequestProtocol (std::shared_ptr< InternalControlFunction > internalControlFunction, CANLibBadge< InternalControlFunction >)
 The constructor for this protocol.
 
 ~ParameterGroupNumberRequestProtocol ()
 The destructor for this protocol.
 
 ParameterGroupNumberRequestProtocol (const ParameterGroupNumberRequestProtocol &)=delete
 Remove the copy constructor.
 
ParameterGroupNumberRequestProtocoloperator= (const ParameterGroupNumberRequestProtocol &)=delete
 Remove the copy assignment operator.
 
bool register_pgn_request_callback (std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer)
 Registers for a callback on receipt of a PGN request.
 
bool register_request_for_repetition_rate_callback (std::uint32_t pgn, PGNRequestForRepetitionRateCallback callback, void *parentPointer)
 Registers for a callback on receipt of a request for repetition rate.
 
bool remove_pgn_request_callback (std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer)
 Removes a previously registered PGN request callback.
 
bool remove_request_for_repetition_rate_callback (std::uint32_t pgn, PGNRequestForRepetitionRateCallback callback, void *parentPointer)
 Removes a callback for repetition rate requests.
 
std::size_t get_number_registered_pgn_request_callbacks () const
 Returns the number of PGN request callbacks that have been registered with this protocol instance.
 
std::size_t get_number_registered_request_for_repetition_rate_callbacks () const
 Returns the number of PGN request for repetition rate callbacks that have been registered with this protocol instance.
 

Static Public Member Functions

static bool request_parameter_group_number (std::uint32_t pgn, std::shared_ptr< InternalControlFunction > source, std::shared_ptr< ControlFunction > destination)
 Sends a PGN request to the specified control function.
 
static bool request_repetition_rate (std::uint32_t pgn, std::uint16_t repetitionRate_ms, std::shared_ptr< InternalControlFunction > source, std::shared_ptr< ControlFunction > destination)
 Sends a PGN request for repetition rate.
 

Private Member Functions

void process_message (const CANMessage &message)
 A generic way for a protocol to process a received message.
 
bool send_acknowledgement (AcknowledgementType type, std::uint32_t parameterGroupNumber, std::shared_ptr< ControlFunction > destination) const
 Sends a message using the acknowledgement PGN.
 

Static Private Member Functions

static void process_message (const CANMessage &message, void *parent)
 A generic way for a protocol to process a received message.
 

Private Attributes

std::shared_ptr< InternalControlFunctionmyControlFunction
 The internal control function that this protocol will send from.
 
std::vector< PGNRequestCallbackInfopgnRequestCallbacks
 A list of all registered PGN callbacks and the PGN associated with each callback.
 
std::vector< PGNRequestForRepetitionRateCallbackInforepetitionRateCallbacks
 A list of all registered request for repetition rate callbacks and the PGN associated with the callback.
 
Mutex pgnRequestMutex
 A mutex to protect the callback lists.
 

Static Private Attributes

static constexpr std::uint8_t PGN_REQUEST_LENGTH = 3
 The CAN data length of a PGN request.
 

Detailed Description

A protocol that handles PGN requests.

The purpose of this protocol is to simplify and standardize how PGN requests are made and responded to. It provides a way to easily send a PGN request or a request for repetition rate, as well as methods to receive PGN requests.

Definition at line 30 of file can_parameter_group_number_request_protocol.hpp.

Constructor & Destructor Documentation

◆ ParameterGroupNumberRequestProtocol()

isobus::ParameterGroupNumberRequestProtocol::ParameterGroupNumberRequestProtocol ( std::shared_ptr< InternalControlFunction > internalControlFunction,
CANLibBadge< InternalControlFunction >  )

The constructor for this protocol.

Parameters
[in]internalControlFunctionThe internal control function that owns this protocol and will be used to send messages

Definition at line 22 of file can_parameter_group_number_request_protocol.cpp.

Here is the call graph for this function:

◆ ~ParameterGroupNumberRequestProtocol()

isobus::ParameterGroupNumberRequestProtocol::~ParameterGroupNumberRequestProtocol ( )

The destructor for this protocol.

Definition at line 30 of file can_parameter_group_number_request_protocol.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ get_number_registered_pgn_request_callbacks()

std::size_t isobus::ParameterGroupNumberRequestProtocol::get_number_registered_pgn_request_callbacks ( ) const

Returns the number of PGN request callbacks that have been registered with this protocol instance.

Returns
The number of PGN request callbacks that have been registered with this protocol instance

Definition at line 131 of file can_parameter_group_number_request_protocol.cpp.

◆ get_number_registered_request_for_repetition_rate_callbacks()

std::size_t isobus::ParameterGroupNumberRequestProtocol::get_number_registered_request_for_repetition_rate_callbacks ( ) const

Returns the number of PGN request for repetition rate callbacks that have been registered with this protocol instance.

Returns
The number of PGN request for repetition rate callbacks that have been registered with this protocol instance

Definition at line 136 of file can_parameter_group_number_request_protocol.cpp.

◆ process_message() [1/2]

void isobus::ParameterGroupNumberRequestProtocol::process_message ( const CANMessage & message)
private

A generic way for a protocol to process a received message.

Parameters
[in]messageA received CAN message

Definition at line 165 of file can_parameter_group_number_request_protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_message() [2/2]

void isobus::ParameterGroupNumberRequestProtocol::process_message ( const CANMessage & message,
void * parent )
staticprivate

A generic way for a protocol to process a received message.

Parameters
[in]messageA received CAN message
[in]parentProvides the context to the actual TP manager object

Definition at line 261 of file can_parameter_group_number_request_protocol.cpp.

Here is the call graph for this function:

◆ register_pgn_request_callback()

bool isobus::ParameterGroupNumberRequestProtocol::register_pgn_request_callback ( std::uint32_t pgn,
PGNRequestCallback callback,
void * parentPointer )

Registers for a callback on receipt of a PGN request.

Parameters
[in]pgnThe PGN you want to handle in the callback
[in]callbackThe callback function to register
[in]parentPointerGeneric context variable, usually the this pointer of the class registering the callback
Returns
true if the callback was registered, false if the callback is nullptr or is already registered for the same PGN

Definition at line 71 of file can_parameter_group_number_request_protocol.cpp.

◆ register_request_for_repetition_rate_callback()

bool isobus::ParameterGroupNumberRequestProtocol::register_request_for_repetition_rate_callback ( std::uint32_t pgn,
PGNRequestForRepetitionRateCallback callback,
void * parentPointer )

Registers for a callback on receipt of a request for repetition rate.

Parameters
[in]pgnThe PGN you want to handle in the callback
[in]callbackThe callback function to register
[in]parentPointerGeneric context variable, usually the this pointer of the class registering the callback
Returns
true if the callback was registered, false if the callback is nullptr or is already registered for the same PGN

Definition at line 85 of file can_parameter_group_number_request_protocol.cpp.

◆ remove_pgn_request_callback()

bool isobus::ParameterGroupNumberRequestProtocol::remove_pgn_request_callback ( std::uint32_t pgn,
PGNRequestCallback callback,
void * parentPointer )

Removes a previously registered PGN request callback.

Parameters
[in]pgnThe PGN associated with the callback
[in]callbackThe callback function to remove
[in]parentPointerGeneric context variable, usually the this pointer of the class that registered the callback
Returns
true if the callback was removed, false if no callback matched the parameters

Definition at line 99 of file can_parameter_group_number_request_protocol.cpp.

◆ remove_request_for_repetition_rate_callback()

bool isobus::ParameterGroupNumberRequestProtocol::remove_request_for_repetition_rate_callback ( std::uint32_t pgn,
PGNRequestForRepetitionRateCallback callback,
void * parentPointer )

Removes a callback for repetition rate requests.

Parameters
[in]pgnThe PGN associated with the callback
[in]callbackThe callback function to remove
[in]parentPointerGeneric context variable, usually the this pointer of the class that registered the callback
Returns
true if the callback was registered, false if the callback is nullptr or is already registered for the same PGN

Definition at line 115 of file can_parameter_group_number_request_protocol.cpp.

◆ request_parameter_group_number()

bool isobus::ParameterGroupNumberRequestProtocol::request_parameter_group_number ( std::uint32_t pgn,
std::shared_ptr< InternalControlFunction > source,
std::shared_ptr< ControlFunction > destination )
static

Sends a PGN request to the specified control function.

Parameters
[in]pgnThe PGN to request
[in]sourceThe internal control function to send from
[in]destinationThe control function to request pgn from
Returns
true if the request was successfully sent

Definition at line 36 of file can_parameter_group_number_request_protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ request_repetition_rate()

bool isobus::ParameterGroupNumberRequestProtocol::request_repetition_rate ( std::uint32_t pgn,
std::uint16_t repetitionRate_ms,
std::shared_ptr< InternalControlFunction > source,
std::shared_ptr< ControlFunction > destination )
static

Sends a PGN request for repetition rate.

Use this if you want the destination CF to send you the specified PGN at some fixed interval

Parameters
[in]pgnThe PGN to request
[in]repetitionRate_msThe repetition rate to request in milliseconds
[in]sourceThe internal control function to send from
[in]destinationThe control function to send the request to
Returns
true if the request was sent

Definition at line 51 of file can_parameter_group_number_request_protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_acknowledgement()

bool isobus::ParameterGroupNumberRequestProtocol::send_acknowledgement ( AcknowledgementType type,
std::uint32_t parameterGroupNumber,
std::shared_ptr< ControlFunction > destination ) const
private

Sends a message using the acknowledgement PGN.

Parameters
[in]typeThe type of acknowledgement to send (Ack, vs Nack, etc)
[in]parameterGroupNumberThe PGN to acknowledge
[in]destinationThe destination control function to send the acknowledgement to
Returns
true if the message was sent, false otherwise

Definition at line 269 of file can_parameter_group_number_request_protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ myControlFunction

std::shared_ptr<InternalControlFunction> isobus::ParameterGroupNumberRequestProtocol::myControlFunction
private

The internal control function that this protocol will send from.

Definition at line 159 of file can_parameter_group_number_request_protocol.hpp.

◆ PGN_REQUEST_LENGTH

constexpr std::uint8_t isobus::ParameterGroupNumberRequestProtocol::PGN_REQUEST_LENGTH = 3
staticconstexprprivate

The CAN data length of a PGN request.

Definition at line 141 of file can_parameter_group_number_request_protocol.hpp.

◆ pgnRequestCallbacks

std::vector<PGNRequestCallbackInfo> isobus::ParameterGroupNumberRequestProtocol::pgnRequestCallbacks
private

A list of all registered PGN callbacks and the PGN associated with each callback.

Definition at line 160 of file can_parameter_group_number_request_protocol.hpp.

◆ pgnRequestMutex

Mutex isobus::ParameterGroupNumberRequestProtocol::pgnRequestMutex
private

A mutex to protect the callback lists.

Definition at line 162 of file can_parameter_group_number_request_protocol.hpp.

◆ repetitionRateCallbacks

std::vector<PGNRequestForRepetitionRateCallbackInfo> isobus::ParameterGroupNumberRequestProtocol::repetitionRateCallbacks
private

A list of all registered request for repetition rate callbacks and the PGN associated with the callback.

Definition at line 161 of file can_parameter_group_number_request_protocol.hpp.


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