AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
isobus_language_command_interface.hpp
Go to the documentation of this file.
1//================================================================================================
9//================================================================================================
10#ifndef ISOBUS_LANGUAGE_COMMAND_INTERFACE_HPP
11#define ISOBUS_LANGUAGE_COMMAND_INTERFACE_HPP
12
15
16#include <memory>
17#include <string>
18
19namespace isobus
20{
21 class InternalControlFunction;
22 class PartneredControlFunction;
23 class ControlFunction;
24
32 {
33 public:
36 enum class DecimalSymbols : std::uint8_t
37 {
38 Comma = 0,
39 Point = 1,
40 Reserved = 2,
41 NoAction = 3
42 };
43
45 enum class DateFormats : std::uint8_t
46 {
47 ddmmyyyy = 0,
48 ddyyyymm = 1,
49 mmyyyydd = 2,
50 mmddyyyy = 3,
51 yyyymmdd = 4,
52 yyyyddmm = 5,
53
54 ReservedStart = 6,
55 ReservedEnd = 250
56 };
57
59 enum class TimeFormats : std::uint8_t
60 {
61 TwentyFourHour = 0,
62 TwelveHourAmPm = 1,
63 Reserved = 2,
64 NoAction = 3
65 };
66
68 enum class DistanceUnits : std::uint8_t
69 {
70 Metric = 0,
71 ImperialUS = 1,
72 Reserved = 2,
73 NoAction = 3
74 };
75
77 enum class AreaUnits : std::uint8_t
78 {
79 Metric = 0,
80 ImperialUS = 1,
81 Reserved = 2,
82 NoAction = 3
83 };
84
86 enum class VolumeUnits : std::uint8_t
87 {
88 Metric = 0,
89 Imperial = 1,
90 US = 2,
91 NoAction = 3
92 };
93
95 enum class MassUnits : std::uint8_t
96 {
97 Metric = 0,
98 Imperial = 1,
99 US = 2,
100 NoAction = 3
101 };
102
104 enum class TemperatureUnits : std::uint8_t
105 {
106 Metric = 0,
107 ImperialUS = 1,
108 Reserved = 2,
109 NoAction = 3
110 };
111
113 enum class PressureUnits : std::uint8_t
114 {
115 Metric = 0,
116 ImperialUS = 1,
117 Reserved = 2,
118 NoAction = 3
119 };
120
122 enum class ForceUnits : std::uint8_t
123 {
124 Metric = 0,
125 ImperialUS = 1,
126 Reserved = 2,
127 NoAction = 3
128 };
129
132 enum class UnitSystem : std::uint8_t
133 {
134 Metric = 0,
135 Imperial = 1,
136 US = 2,
137 NoAction = 3
138 };
139
144 LanguageCommandInterface(std::shared_ptr<InternalControlFunction> sourceControlFunction, bool shouldRespondToRequests = false);
145
151 LanguageCommandInterface(std::shared_ptr<InternalControlFunction> sourceControlFunction, std::shared_ptr<PartneredControlFunction> filteredControlFunction);
152
155
158
163 void initialize();
164
167 void set_partner(std::shared_ptr<PartneredControlFunction> filteredControlFunction);
168
171 std::shared_ptr<PartneredControlFunction> get_partner() const;
172
175 bool get_initialized() const;
176
181
186
190 std::string get_country_code() const;
191
196 void set_country_code(std::string country);
197
201 std::string get_language_code() const;
202
206 void set_language_code(std::string language);
207
210 std::uint32_t get_language_command_timestamp() const;
211
215
220
224
229
233
238
242
247
251
256
260
265
269
274
278
283
287
292
296
301
305
310
313 const std::array<std::uint8_t, 7> get_localization_raw_data() const;
314
318 static void process_rx_message(const CANMessage &message, void *parentPointer);
319
320 private:
328 static bool on_language_request(std::uint32_t parameterGroupNumber,
329 std::shared_ptr<ControlFunction> requestingControlFunction,
330 bool &acknowledge,
331 AcknowledgementType &acknowledgeType,
332 void *parentPointer);
333
334 std::shared_ptr<InternalControlFunction> myControlFunction;
335 std::shared_ptr<PartneredControlFunction> myPartner;
336 std::string countryCode;
337 std::string languageCode;
338 std::uint32_t languageCommandTimestamp_ms = 0;
350 bool initialized = false;
351 bool respondToRequests = false;
352 };
353} // namespace isobus
354
355#endif // ISOBUS_LANGUAGE_COMMAND_INTERFACE_HPP
An object to represent common callbacks used within this CAN stack.
An abstraction of a CAN message, could be > 8 data bytes.
A class that represents a generic CAN message of arbitrary length.
An interface for requesting and parsing the ISO11783 language command PGN, 0xFE0F.
static bool on_language_request(std::uint32_t parameterGroupNumber, std::shared_ptr< ControlFunction > requestingControlFunction, bool &acknowledge, AcknowledgementType &acknowledgeType, void *parentPointer)
This is a callback to handle clients requesting the content of our language data for things like VT/T...
~LanguageCommandInterface()
Destructor for the LanguageCommandInterface.
ForceUnits forceUnitSystem
The force units that were commanded by the last language command message.
DecimalSymbols get_commanded_decimal_symbol() const
Returns the commanded decimal symbol parsed from the last language command.
PressureUnits get_commanded_pressure_units() const
Returns the commanded pressure units parsed from the last received language command.
ForceUnits get_commanded_force_units() const
Returns the commanded force units parsed from the last received language command.
UnitSystem genericUnitSystem
The "unit system" that was commanded by the last language command message.
void set_commanded_generic_units(UnitSystem units)
Sets the commanded generic unit system.
MassUnits
Command specifying a mass unit. (SPN 2417)
void set_commanded_date_format(DateFormats format)
Sets the commanded date format.
std::string get_language_code() const
Returns the commanded language code parsed from the last language command.
bool respondToRequests
Stores if the class should respond to PGN requests for the language command.
TemperatureUnits get_commanded_temperature_units() const
Returns the commanded temperature units parsed from the last received language command.
void set_commanded_force_units(ForceUnits units)
Sets the commanded force units.
bool initialized
Tracks if initialize has been called yet for this interface.
std::shared_ptr< InternalControlFunction > myControlFunction
The control function to send messages as.
bool send_request_language_command() const
Sends a PGN request for the language command PGN to the interface's partner, or the global address de...
VolumeUnits
Command specifying a volume unit. (SPN 2416)
void set_country_code(std::string country)
Sets the country code specifying the operator's desired language dialect.
DistanceUnits get_commanded_distance_units() const
Returns the commanded distance units parsed from the last language command.
void set_commanded_decimal_symbol(DecimalSymbols decimals)
Sets the decimal symbol to be used.
TemperatureUnits temperatureUnitSystem
The temperature units that were commanded by the last language command message.
LanguageCommandInterface(std::shared_ptr< InternalControlFunction > sourceControlFunction, bool shouldRespondToRequests=false)
Constructor for a LanguageCommandInterface.
TimeFormats
Command sent to all CFs specifying the displayed format of the time. (SPN 2413)
AreaUnits
Command specifying an area unit. (SPN 2415)
std::string get_country_code() const
Returns the commanded country code parsed from the last language command specifying the operator's de...
MassUnits get_commanded_mass_units() const
Returns the commanded mass units parsed from the last received language command.
ForceUnits
Command specifying a force unit (SPN 5196)
MassUnits massUnitSystem
The mass units that were commanded by the last language command message.
DateFormats dateFormat
The date format that was commanded by the last language command message.
std::shared_ptr< PartneredControlFunction > get_partner() const
Returns the current partner being used by the interface.
DateFormats
Command sent to all CFs specifying the displayed format of the date. (SPN 2412)
@ ReservedStart
Reserved range begins here.
void set_commanded_mass_units(MassUnits units)
Sets the commanded mass units.
void set_partner(std::shared_ptr< PartneredControlFunction > filteredControlFunction)
Changes the partner being used by the interface to a new partner.
void set_commanded_pressure_units(PressureUnits units)
Sets the commanded pressure units.
LanguageCommandInterface(LanguageCommandInterface &)=delete
Deleted copy constructor for LanguageCommandInterface.
bool get_initialized() const
Returns if initialize has been called yet.
UnitSystem get_commanded_generic_units() const
Returns the commanded "unit system" generic value that was parsed from the last received language com...
std::uint32_t get_language_command_timestamp() const
Returns a timestamp (in ms) corresponding to when the interface last received a language command.
AreaUnits get_commanded_area_units() const
Returns the commanded area units parsed from the last received language command.
const std::array< std::uint8_t, 7 > get_localization_raw_data() const
Returns The raw bytes that comprise the current localization data as defined in ISO11783-7.
bool send_language_command()
Sends a language command based on the current content of this class as a broadcast.
UnitSystem
May be used for the display of any unit, or a unit other than those explicitly specified (SPN 5197)
DistanceUnits distanceUnitSystem
The distance units that were commanded by the last language command message.
void set_language_code(std::string language)
Sets the language.
AreaUnits areaUnitSystem
The area units that were commanded by the last language command message.
void set_commanded_volume_units(VolumeUnits units)
Sets the commanded volume units.
DistanceUnits
Command specifying a distance unit. (SPN 2414)
DecimalSymbols decimalSymbol
The decimal symbol that was commanded by the last language command message.
VolumeUnits volumeUnitSystem
The volume units that were commanded by the last language command message.
PressureUnits
Command specifying a pressure unit (SPN 5195)
TimeFormats timeFormat
The time format that was commanded by the last language command message.
TemperatureUnits
Command specifying a temperature unit. (SPN 5194)
@ Metric
Degrees Celsius, Degrees Kelvin.
void set_commanded_temperature_units(TemperatureUnits units)
Sets the commanded temperature units.
static void process_rx_message(const CANMessage &message, void *parentPointer)
Parses incoming CAN messages into usable unit and language settings.
void set_commanded_area_units(AreaUnits units)
Sets the commanded area units.
std::shared_ptr< PartneredControlFunction > myPartner
The partner to talk to, or nullptr to listen to all CFs.
TimeFormats get_commanded_time_format() const
Returns the commanded time format parsed from the last language command.
DecimalSymbols
Command sent to all CFs that determines whether a point or a comma will be displayed as the decimal s...
std::string languageCode
The last received language code, such as "en", "es", "de", etc.
DateFormats get_commanded_date_format() const
Returns the commanded date format parsed from the last language command.
std::uint32_t languageCommandTimestamp_ms
A millisecond timestamp correlated to the last received language command message.
std::string countryCode
The last received alpha-2 country code as specified by ISO 3166-1, such as "NL, FR,...
void set_commanded_distance_units(DistanceUnits units)
Sets the commanded distance units.
VolumeUnits get_commanded_volume_units() const
Returns the commanded volume units parsed from the last received language command.
void set_commanded_time_format(TimeFormats format)
Sets the commanded time format.
PressureUnits pressureUnitSystem
The pressure units that were commanded by the last language command message.
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.