AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
isobus_functionalities.hpp
Go to the documentation of this file.
1//================================================================================================
12//================================================================================================
13#ifndef ISOBUS_FUNCTIONALITIES_HPP
14#define ISOBUS_FUNCTIONALITIES_HPP
15
18#include "isobus/utility/processing_flags.hpp"
19#include "isobus/utility/thread_synchronization.hpp"
20
21#include <list>
22#include <vector>
23
24namespace isobus
25{
26 class DiagnosticProtocol; // Forward declaration
27
30 {
31 public:
34 enum class Functionalities : std::uint8_t
35 {
36 MinimumControlFunction = 0,
37 UniversalTerminalServer = 1,
38 UniversalTerminalWorkingSet = 2,
39 AuxOInputs = 3,
40 AuxOFunctions = 4,
41 AuxNInputs = 5,
42 AuxNFunctions = 6,
43 TaskControllerBasicServer = 7,
44 TaskControllerBasicClient = 8,
45 TaskControllerGeoServer = 9,
46 TaskControllerGeoClient = 10,
47 TaskControllerSectionControlServer = 11,
48 TaskControllerSectionControlClient = 12,
49 BasicTractorECUServer = 13,
50 BasicTractorECUImplementClient = 14,
51 TractorImplementManagementServer = 15,
52 TractorImplementManagementClient = 16,
53 FileServer = 17,
54 FileServerClient = 18,
55
56 ReservedRangeBegin = 19,
57 MaxFunctionalityReserved = 255
58 };
59
61 enum class MinimumControlFunctionOptions : std::uint8_t
62 {
63 NoOptions = 0x00,
64 Type1ECUInternalWeakTermination = 0x01,
65 Type2ECUInternalEndPointTermination = 0x02,
66 SupportOfHeartbeatProducer = 0x04,
67 SupportOfHeartbeatConsumer = 0x08,
68
69 Reserved = 0xF0
70 };
71
74 enum class AuxOOptions : std::uint8_t
75 {
76 NoOptions = 0x00,
77 SupportsType0Function = 0x01,
78 SupportsType1Function = 0x02,
79 SupportsType2Function = 0x04,
80
81 Reserved = 0xF8
82 };
83
86 enum class AuxNOptions : std::uint16_t
87 {
88 NoOptions = 0x00,
89 SupportsType0Function = 0x01,
90 SupportsType1Function = 0x02,
91 SupportsType2Function = 0x04,
92 SupportsType3Function = 0x08,
93 SupportsType4Function = 0x10,
94 SupportsType5Function = 0x20,
95 SupportsType6Function = 0x40,
96 SupportsType7Function = 0x80,
97 SupportsType8Function = 0x100,
98 SupportsType9Function = 0x200,
99 SupportsType10Function = 0x400,
100 SupportsType11Function = 0x800,
101 SupportsType12Function = 0x1000,
102 SupportsType13Function = 0x2000,
103 SupportsType14Function = 0x4000,
104
105 Reserved = 0x8000
106 };
107
110 enum class TaskControllerGeoServerOptions : std::uint8_t
111 {
112 NoOptions = 0x00,
113 PolygonBasedPrescriptionMapsAreSupported = 0x01,
114
115 Reserved = 0xFE
116 };
117
120 enum class BasicTractorECUOptions : std::uint8_t
121 {
122 TECUNotMeetingCompleteClass1Requirements = 0x00,
123 Class1NoOptions = 0x01,
124 Class2NoOptions = 0x02,
125 ClassRequiredLighting = 0x04,
126 NavigationOption = 0x08,
127 FrontHitchOption = 0x10,
128 GuidanceOption = 0x20,
129 Reserved = 0xC0
130 };
131
135 {
136 NoOptions = 0,
137 FrontPTODisengagementIsSupported,
138 FrontPTOEngagementCCWIsSupported,
139 FrontPTOengagementCWIsSupported,
140 FrontPTOspeedCCWIsSupported,
141 FrontPTOspeedCWIsSupported,
142 RearPTODisengagementIsSupported,
143 RearPTOEngagementCCWIsSupported,
144 RearPTOEngagementCWIsSupported,
145 RearPTOSpeedCCWIsSupported,
146 RearPTOSpeedCWIsSupported,
147 FrontHitchMotionIsSupported,
148 FrontHitchPositionIsSupported,
149 RearHitchMotionIsSupported,
150 RearHitchPositionIsSupported,
151 VehicleSpeedInForwardDirectionIsSupported,
152 VehicleSpeedInReverseDirectionIsSupported,
153 VehicleSpeedStartMotionIsSupported,
154 VehicleSpeedStopMotionIsSupported,
155 VehicleSpeedForwardSetByServerIsSupported,
156 VehicleSpeedReverseSetByServerIsSupported,
157 VehicleSpeedChangeDirectionIsSupported,
158 GuidanceCurvatureIsSupported
159 };
160
163 explicit ControlFunctionFunctionalities(std::shared_ptr<InternalControlFunction> sourceControlFunction);
164
167
173 void set_functionality_is_supported(Functionalities functionality, std::uint8_t functionalityGeneration, bool isSupported);
174
179
184 std::uint8_t get_functionality_generation(Functionalities functionality);
185
192
197
203 void set_aux_O_inputs_option_state(AuxOOptions option, bool optionState);
204
209
215 void set_aux_O_functions_option_state(AuxOOptions option, bool optionState);
216
221
227 void set_aux_N_inputs_option_state(AuxNOptions option, bool optionState);
228
233
239 void set_aux_N_functions_option_state(AuxNOptions option, bool optionState);
240
245
252
257
262 void set_task_controller_geo_client_option(std::uint8_t numberOfControlChannels);
263
267
272 void set_task_controller_section_control_server_option_state(std::uint8_t numberOfSupportedBooms, std::uint8_t numberOfSupportedSections);
273
277
281
286 void set_task_controller_section_control_client_option_state(std::uint8_t numberOfSupportedBooms, std::uint8_t numberOfSupportedSections);
287
291
295
301
306
312
317
323
328
334 void set_tractor_implement_management_server_aux_valve_option(std::uint8_t auxValveIndex, bool stateSupported, bool flowSupported);
335
340
345
351
356
362 void set_tractor_implement_management_client_aux_valve_option(std::uint8_t auxValveIndex, bool stateSupported, bool flowSupported);
363
368
373
375 void update();
376
377 protected:
380 void get_message_content(std::vector<std::uint8_t> &messageData);
381
382 private:
386 {
387 public:
390 explicit FunctionalityData(Functionalities functionalityToStore);
391
395
401 void set_bit_in_option(std::uint8_t byteIndex, std::uint8_t bit, bool value);
402
408 bool get_bit_in_option(std::uint8_t byteIndex, std::uint8_t bit);
409
410 Functionalities functionality = Functionalities::MinimumControlFunction;
411 std::vector<std::uint8_t> serializedValue;
412 std::uint8_t generation = 1;
413 };
414
416 enum class TransmitFlags : std::uint32_t
417 {
419
421 };
422
427 std::list<FunctionalityData>::iterator get_functionality(Functionalities functionalityToRetrieve);
428
434 bool get_functionality_byte_option(Functionalities functionality, std::uint8_t byteIndex, std::uint8_t option);
435
441
447
455 static bool pgn_request_handler(std::uint32_t parameterGroupNumber,
456 std::shared_ptr<ControlFunction> requestingControlFunction,
457 bool &acknowledge,
458 AcknowledgementType &acknowledgeType,
459 void *parentPointer);
460
464 static void process_flags(std::uint32_t flag, void *parentPointer);
465
466 static constexpr std::uint8_t NUMBER_TIM_AUX_VALVES_PER_BYTE = 4;
467 static constexpr std::uint8_t NUMBER_TIM_AUX_VALVES = 32;
468
469 std::shared_ptr<InternalControlFunction> myControlFunction;
470 std::list<FunctionalityData> supportedFunctionalities;
471 ProcessingFlags txFlags;
473 };
474} // namespace isobus
475#endif // ISOBUS_FUNCTIONALITIES_HPP
A representation of an ISOBUS ECU that we can send from. Use this class when defining your own contro...
A protocol that handles PGN requests.
Stores the raw byte data associated with a functionality based on what the user has enabled and what ...
void configure_default_data()
Sets up default data associated to the functionality the object is representing.
bool get_bit_in_option(std::uint8_t byteIndex, std::uint8_t bit)
A helper function to get a particular bit's value in the specified option byte.
void set_bit_in_option(std::uint8_t byteIndex, std::uint8_t bit, bool value)
A helper function to set a particular option bit to some value within an option byte.
FunctionalityData(Functionalities functionalityToStore)
Constructor for a FunctionalityData object.
std::uint8_t generation
The generation of the functionality supported.
Functionalities functionality
The functionality associated with this data.
std::vector< std::uint8_t > serializedValue
The raw message data value for this functionality.
Manages the control function functionalities message.
void set_tractor_implement_management_client_option_state(TractorImplementManagementOptions option, bool optionState)
Sets a tractor implement management (TIM) client functionality option to a new state.
TractorImplementManagementOptions
This parameter reports which TIM options are supported by a TIM server or an implement working set ma...
bool get_functionality_is_supported(Functionalities functionality)
Returns if a functionality was previously configured with set_functionality_is_supported.
BasicTractorECUOptions
This parameter reports which tractor ECU class and functionality options are supported by an implemen...
std::uint8_t get_task_controller_section_control_client_number_supported_sections()
Gets the number of supported sections for the TC section control client functionality.
ProcessingFlags txFlags
Handles retries for sending the CF functionalities message.
std::list< FunctionalityData >::iterator get_functionality(Functionalities functionalityToRetrieve)
Checks for the existence of a functionality in the list of previously configured functionalities and ...
std::list< FunctionalityData > supportedFunctionalities
A list of all configured functionalities and their data.
TaskControllerGeoServerOptions
This option byte reports which task controller geo functionality options are supported by an implemen...
void set_functionality_is_supported(Functionalities functionality, std::uint8_t functionalityGeneration, bool isSupported)
Adds or removes a supported functionality.
std::uint8_t get_task_controller_section_control_client_number_supported_booms()
Gets the number of supported booms for the TC section control client functionality.
void set_basic_tractor_ECU_server_option_state(BasicTractorECUOptions option, bool optionState)
Sets a tractor ECU server functionality option to a new state.
static void process_flags(std::uint32_t flag, void *parentPointer)
Processes set transmit flags to send messages.
void set_task_controller_section_control_client_option_state(std::uint8_t numberOfSupportedBooms, std::uint8_t numberOfSupportedSections)
Sets a task controller section control client's options.
static bool pgn_request_handler(std::uint32_t parameterGroupNumber, std::shared_ptr< ControlFunction > requestingControlFunction, bool &acknowledge, AcknowledgementType &acknowledgeType, void *parentPointer)
Handles PGN requests for the control function functionalities message.
bool get_tractor_implement_management_client_option_state(TractorImplementManagementOptions option)
Gets the state of a TIM client functionality option.
bool get_functionality_byte_option(Functionalities functionality, std::uint8_t byteIndex, std::uint8_t option)
A wrapper to to get an option from the first byte of a functionalities' data.
bool get_aux_N_inputs_option_state(AuxNOptions option)
Gets the state of an AUX-N inputs functionality option.
bool get_tractor_implement_management_server_aux_valve_flow_supported(std::uint8_t auxValveIndex)
Returns if a particular aux valve's flow control is supported in the TIM server functionality.
void set_aux_O_inputs_option_state(AuxOOptions option, bool optionState)
Sets an AUX-O inputs functionality option to a new state.
std::uint8_t get_task_controller_section_control_server_number_supported_sections()
Gets the number of supported sections for the TC section control server functionality.
bool get_basic_tractor_ECU_server_option_state(BasicTractorECUOptions option)
Gets the state of a basic tractor ECU server functionality option.
std::uint8_t get_tim_option_byte_index(TractorImplementManagementOptions option) const
Returns the byte index of the specified TIM option in the CF Functionalities message data associated ...
void set_task_controller_geo_client_option(std::uint8_t numberOfControlChannels)
Sets a task controller geo client's only functionality option, which is the number of control channel...
bool get_aux_N_functions_option_state(AuxNOptions option)
Gets the state of an AUX-N functions functionality option.
void set_aux_N_functions_option_state(AuxNOptions option, bool optionState)
Sets an AUX-N functions functionality option to a new state.
void set_tractor_implement_management_client_aux_valve_option(std::uint8_t auxValveIndex, bool stateSupported, bool flowSupported)
Sets a tractor implement management (TIM) client aux valve's functionality options to a new state.
std::uint8_t get_task_controller_geo_client_option()
Gets the state of the only TC GEO client functionality option, which is the number of control channel...
Mutex functionalitiesMutex
Since messages come in on a different thread than the main app (probably), this mutex protects the fu...
Functionalities
Enumerates the different functionalities that an ISOBUS ECU can report in the control function functi...
std::uint8_t get_tim_option_bit_index(TractorImplementManagementOptions option) const
Returns the bit offset of a specified TIM functionality option into the TIM client and server functio...
void set_tractor_implement_management_server_aux_valve_option(std::uint8_t auxValveIndex, bool stateSupported, bool flowSupported)
Sets a tractor implement management (TIM) server aux valve's functionality options to a new state.
void set_task_controller_section_control_server_option_state(std::uint8_t numberOfSupportedBooms, std::uint8_t numberOfSupportedSections)
Sets a task controller section control server's options.
static constexpr std::uint8_t NUMBER_TIM_AUX_VALVES
The max number of TIM aux valves.
bool get_tractor_implement_management_server_aux_valve_state_supported(std::uint8_t auxValveIndex)
Returns if a particular aux valve's state control is supported in the TIM server functionality.
bool get_aux_O_functions_option_state(AuxOOptions option)
Gets the state of an AUX-O functions functionality option.
std::shared_ptr< InternalControlFunction > myControlFunction
The control function to send messages as.
bool get_tractor_implement_management_client_aux_valve_state_supported(std::uint8_t auxValveIndex)
Returns if a particular aux valve's state control is supported in the TIM client functionality.
bool get_tractor_implement_management_client_aux_valve_flow_supported(std::uint8_t auxValveIndex)
Returns if a particular aux valve's flow control is supported in the TIM client functionality.
bool get_minimum_control_function_option_state(MinimumControlFunctionOptions option)
Returns the current state of the specified minimum control function functionality option.
void set_task_controller_geo_server_option_state(TaskControllerGeoServerOptions option, bool optionState)
Sets a task controller geo server functionality option to a new state.
std::uint8_t get_task_controller_section_control_server_number_supported_booms()
Gets the number of supported booms for the TC section control server functionality.
void set_minimum_control_function_option_state(MinimumControlFunctionOptions option, bool optionState)
Sets a minimum control function functionality option to a new state.
bool get_basic_tractor_ECU_implement_client_option_state(BasicTractorECUOptions option)
Gets the state of a basic tractor ECU implement client functionality option.
MinimumControlFunctionOptions
This parameter reports which minimum control function functionality options are supported.
~ControlFunctionFunctionalities()
Destructor for a ControlFunctionFunctionalities object.
AuxNOptions
This parameter reports which auxiliary control type 2 functionality type functions are supported by a...
bool get_aux_O_inputs_option_state(AuxOOptions option)
Gets the state of an AUX-O inputs functionality option.
bool get_tractor_implement_management_server_option_state(TractorImplementManagementOptions option)
Gets the state of a basic tractor implement management client functionality option.
void set_basic_tractor_ECU_implement_client_option_state(BasicTractorECUOptions option, bool optionState)
Sets a tractor ECU client functionality option to a new state.
static constexpr std::uint8_t NUMBER_TIM_AUX_VALVES_PER_BYTE
The number of aux valves per byte of TIM functionality message data.
void set_aux_O_functions_option_state(AuxOOptions option, bool optionState)
Sets an AUX-O functions functionality option to a new state.
void set_tractor_implement_management_server_option_state(TractorImplementManagementOptions option, bool optionState)
Sets a tractor implement management (TIM) server functionality option to a new state.
void get_message_content(std::vector< std::uint8_t > &messageData)
Populates a vector with the message data needed to send PGN 0xFC8E.
AuxOOptions
This parameter reports which auxiliary control type 1 functionality type functions are supported by a...
std::uint8_t get_functionality_generation(Functionalities functionality)
Returns the generation that was set for the specified functionality when set_functionality_is_support...
void set_aux_N_inputs_option_state(AuxNOptions option, bool optionState)
Sets an AUX-N inputs functionality option to a new state.
void update()
The diagnostic protocol will call this update function, make sure to call DiagnosticProtocol::update(...
bool get_task_controller_geo_server_option_state(TaskControllerGeoServerOptions option)
Gets the state of a TC GEO server functionality option.
TransmitFlags
Enumerates a set of flags representing messages to be transmitted by this interfaces.
@ ControlFunctionFunctionalitiesMessage
A flag to send the CF Functionalities message.
@ NumberOfFlags
The number of flags enumerated in this enum.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
AcknowledgementType
The types of acknowledgement that can be sent in the Ack PGN.