AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
can_parameter_group_number_request_protocol.hpp
Go to the documentation of this file.
1//================================================================================================
10//================================================================================================
11#ifndef CAN_PARAMETER_GROUP_NUMBER_REQUEST_PROTOCOL_HPP
12#define CAN_PARAMETER_GROUP_NUMBER_REQUEST_PROTOCOL_HPP
13
17
18#include <memory>
19
20namespace isobus
21{
22 //================================================================================================
29 //================================================================================================
31 {
32 public:
35 ParameterGroupNumberRequestProtocol(std::shared_ptr<InternalControlFunction> internalControlFunction, CANLibBadge<InternalControlFunction>);
36
39
42
45
51 static bool request_parameter_group_number(std::uint32_t pgn, std::shared_ptr<InternalControlFunction> source, std::shared_ptr<ControlFunction> destination);
52
60 static bool request_repetition_rate(std::uint32_t pgn, std::uint16_t repetitionRate_ms, std::shared_ptr<InternalControlFunction> source, std::shared_ptr<ControlFunction> destination);
61
67 bool register_pgn_request_callback(std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer);
68
74 bool register_request_for_repetition_rate_callback(std::uint32_t pgn, PGNRequestForRepetitionRateCallback callback, void *parentPointer);
75
81 bool remove_pgn_request_callback(std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer);
82
88 bool remove_request_for_repetition_rate_callback(std::uint32_t pgn, PGNRequestForRepetitionRateCallback callback, void *parentPointer);
89
93
97
98 private:
101 {
102 public:
107 PGNRequestCallbackInfo(PGNRequestCallback callback, std::uint32_t parameterGroupNumber, void *parentPointer);
108
113 bool operator==(const PGNRequestCallbackInfo &obj) const;
114
116 std::uint32_t pgn;
117 void *parent;
118 };
119
122 {
123 public:
128 PGNRequestForRepetitionRateCallbackInfo(PGNRequestForRepetitionRateCallback callback, std::uint32_t parameterGroupNumber, void *parentPointer);
129
135
137 std::uint32_t pgn;
138 void *parent;
139 };
140
141 static constexpr std::uint8_t PGN_REQUEST_LENGTH = 3;
142
145 void process_message(const CANMessage &message);
146
150 static void process_message(const CANMessage &message, void *parent);
151
157 bool send_acknowledgement(AcknowledgementType type, std::uint32_t parameterGroupNumber, std::shared_ptr<ControlFunction> destination) const;
158
159 std::shared_ptr<InternalControlFunction> myControlFunction;
160 std::vector<PGNRequestCallbackInfo> pgnRequestCallbacks;
161 std::vector<PGNRequestForRepetitionRateCallbackInfo> repetitionRateCallbacks;
163 };
164}
165
166#endif // CAN_PARAMETER_GROUP_NUMBER_REQUEST_PROTOCOL_HPP
A way to only allow certain object types to access certain functions that is enforced at compile time...
Defines a base class to represent a generic ISOBUS control function.
The main class that manages the ISOBUS stack including: callbacks, Name to Address management,...
This is a way to protect functions on public interfaces from being accessed by objects that shouldn't...
A class that represents a generic CAN message of arbitrary length.
PGNRequestCallbackInfo(PGNRequestCallback callback, std::uint32_t parameterGroupNumber, void *parentPointer)
Constructor for PGNRequestCallbackInfo.
bool operator==(const PGNRequestCallbackInfo &obj) const
A utility function for determining if the data in the object is equal to another object.
void * parent
Pointer to the class that registered the callback, or nullptr
bool operator==(const PGNRequestForRepetitionRateCallbackInfo &obj) const
A utility function for determining if the data in the object is equal to another object.
PGNRequestForRepetitionRateCallbackInfo(PGNRequestForRepetitionRateCallback callback, std::uint32_t parameterGroupNumber, void *parentPointer)
Constructor for PGNRequestCallbackInfo.
ParameterGroupNumberRequestProtocol & operator=(const ParameterGroupNumberRequestProtocol &)=delete
Remove the copy assignment operator.
std::shared_ptr< InternalControlFunction > myControlFunction
The internal control function that this protocol will send from.
std::vector< PGNRequestCallbackInfo > pgnRequestCallbacks
A list of all registered PGN callbacks and the PGN associated with each callback.
bool remove_pgn_request_callback(std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer)
Removes a previously registered PGN request callback.
void process_message(const CANMessage &message)
A generic way for a protocol to process a received message.
ParameterGroupNumberRequestProtocol(const ParameterGroupNumberRequestProtocol &)=delete
Remove the copy constructor.
static constexpr std::uint8_t PGN_REQUEST_LENGTH
The CAN data length of a PGN request.
bool register_pgn_request_callback(std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer)
Registers for a callback on receipt of a PGN request.
bool remove_request_for_repetition_rate_callback(std::uint32_t pgn, PGNRequestForRepetitionRateCallback callback, void *parentPointer)
Removes a callback for repetition rate requests.
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.
ParameterGroupNumberRequestProtocol(std::shared_ptr< InternalControlFunction > internalControlFunction, CANLibBadge< InternalControlFunction >)
The constructor for this protocol.
std::vector< PGNRequestForRepetitionRateCallbackInfo > repetitionRateCallbacks
A list of all registered request for repetition rate callbacks and the PGN associated with the callba...
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.
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.
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 p...
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.
bool send_acknowledgement(AcknowledgementType type, std::uint32_t parameterGroupNumber, std::shared_ptr< ControlFunction > destination) const
Sends a message using the acknowledgement PGN.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
bool(*)(std::uint32_t parameterGroupNumber, std::shared_ptr< ControlFunction > requestingControlFunction, std::shared_ptr< ControlFunction > targetControlFunction, std::uint32_t repetitionRate, void *parentPointer) PGNRequestForRepetitionRateCallback
A callback for handling a request for repetition rate for a specific PGN.
bool(*)(std::uint32_t parameterGroupNumber, std::shared_ptr< ControlFunction > requestingControlFunction, bool &acknowledge, AcknowledgementType &acknowledgeType, void *parentPointer) PGNRequestCallback
A callback for handling a PGN request.
AcknowledgementType
The types of acknowledgement that can be sent in the Ack PGN.