AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
isobus_task_controller_client_objects.hpp
Go to the documentation of this file.
1//================================================================================================
8//================================================================================================
9#ifndef ISOBUS_TASK_CONTROLLER_CLIENT_OBJECTS_HPP
10#define ISOBUS_TASK_CONTROLLER_CLIENT_OBJECTS_HPP
11
12#include <array>
13#include <cstdint>
14#include <string>
15#include <vector>
16
17namespace isobus
18{
20 namespace task_controller_object
21 {
31
33 class Object
34 {
35 public:
39 Object(std::string objectDesignator, std::uint16_t uniqueID);
40
42 virtual ~Object() = default;
43
46 std::string get_designator() const;
47
50 void set_designator(const std::string &newDesignator);
51
54 std::uint16_t get_object_id() const;
55
58 void set_object_id(std::uint16_t id);
59
62 virtual std::string get_table_id() const = 0;
63
66 virtual ObjectTypes get_object_type() const = 0;
67
70 virtual std::vector<std::uint8_t> get_binary_object() const = 0;
71
73 static constexpr std::uint16_t MAX_OBJECT_ID = 65534;
74
76 static constexpr std::size_t MAX_DESIGNATOR_LENGTH = 128;
77
79 static constexpr std::size_t MAX_DESIGNATOR_LEGACY_LENGTH = 32;
80
81 protected:
82 std::string designator;
83 std::uint16_t objectID;
84 };
85
88 class DeviceObject : public Object
89 {
90 public:
100 DeviceObject(std::string deviceDesignator,
101 std::string deviceSoftwareVersion,
102 std::string deviceSerialNumber,
103 std::string deviceStructureLabel,
104 std::array<std::uint8_t, 7> deviceLocalizationLabel,
105 std::vector<std::uint8_t> deviceExtendedStructureLabel,
106 std::uint64_t clientIsoNAME,
107 bool shouldUseExtendedStructureLabel);
108
110 ~DeviceObject() override = default;
111
114 std::string get_table_id() const override;
115
118 ObjectTypes get_object_type() const override;
119
122 std::vector<std::uint8_t> get_binary_object() const override;
123
126 std::string get_software_version() const;
127
130 void set_software_version(const std::string &version);
131
134 std::string get_serial_number() const;
135
138 void set_serial_number(const std::string &serial);
139
142 std::string get_structure_label() const;
143
146 void set_structure_label(const std::string &label);
147
150 std::array<std::uint8_t, 7> get_localization_label() const;
151
154 void set_localization_label(std::array<std::uint8_t, 7> label);
155
158 std::vector<std::uint8_t> get_extended_structure_label() const;
159
162 void set_extended_structure_label(const std::vector<std::uint8_t> &label);
163
166 std::uint64_t get_iso_name() const;
167
170 void set_iso_name(std::uint64_t name);
171
176
181 void set_use_extended_structure_label(bool shouldUseExtendedStructureLabel);
182
184 static constexpr std::size_t MAX_STRUCTURE_AND_LOCALIZATION_LABEL_LENGTH = 7;
185
187 static constexpr std::size_t MAX_EXTENDED_STRUCTURE_LABEL_LENGTH = 32;
188
189 private:
190 static const std::string tableID;
191 std::string serialNumber;
192 std::string softwareVersion;
193 std::string structureLabel;
194 std::array<std::uint8_t, task_controller_object::DeviceObject::MAX_STRUCTURE_AND_LOCALIZATION_LABEL_LENGTH> localizationLabel;
195 std::vector<std::uint8_t> extendedStructureLabel;
196 std::uint64_t NAME;
198 };
199
204 {
205 public:
207 enum class Type : std::uint8_t
208 {
209 Device = 1,
210 Function = 2,
211 Bin = 3,
212 Section = 4,
213 Unit = 5,
214 Connector = 6,
216 };
217
224 DeviceElementObject(std::string deviceElementDesignator,
225 std::uint16_t deviceElementNumber,
226 std::uint16_t parentObjectID,
227 Type deviceEelementType,
228 std::uint16_t uniqueID);
229
231 ~DeviceElementObject() override = default;
232
235 std::string get_table_id() const override;
236
239 ObjectTypes get_object_type() const override;
240
243 std::vector<std::uint8_t> get_binary_object() const override;
244
247 std::uint16_t get_element_number() const;
248
251 void set_element_number(std::uint16_t newElementNumber);
252
255 std::uint16_t get_parent_object() const;
256
259 void set_parent_object(std::uint16_t parentObjectID);
260
263 Type get_type() const;
264
268 void add_reference_to_child_object(std::uint16_t childID);
269
273 bool remove_reference_to_child_object(std::uint16_t childID);
274
279 std::uint16_t get_number_child_objects() const;
280
284 std::uint16_t get_child_object_id(std::size_t index);
285
286 private:
287 static const std::string tableID;
288 std::vector<std::uint16_t> referenceList;
289 std::uint16_t elementNumber;
290 std::uint16_t parentObject;
292 };
293
298 {
299 public:
301 enum class PropertiesBit : std::uint8_t
302 {
303 MemberOfDefaultSet = 0x01,
304 Settable = 0x02,
305 ControlSource = 0x04
306 };
307
310 {
311 TimeInterval = 0x01,
312 DistanceInterval = 0x02,
313 ThresholdLimits = 0x04,
314 OnChange = 0x08,
315 Total = 0x10
316 };
317
325 DeviceProcessDataObject(std::string processDataDesignator,
326 std::uint16_t processDataDDI,
327 std::uint16_t deviceValuePresentationObjectID,
328 std::uint8_t processDataProperties,
329 std::uint8_t processDataTriggerMethods,
330 std::uint16_t uniqueID);
331
333 ~DeviceProcessDataObject() override = default;
334
337 std::string get_table_id() const override;
338
341 ObjectTypes get_object_type() const override;
342
345 std::vector<std::uint8_t> get_binary_object() const override;
346
349 std::uint16_t get_ddi() const;
350
353 void set_ddi(std::uint16_t newDDI);
354
357 std::uint16_t get_device_value_presentation_object_id() const;
358
361 void set_device_value_presentation_object_id(std::uint16_t id);
362
365 std::uint8_t get_properties_bitfield() const;
366
369 void set_properties_bitfield(std::uint8_t properties);
370
373 std::uint8_t get_trigger_methods_bitfield() const;
374
377 void set_trigger_methods_bitfield(std::uint8_t methods);
378
379 private:
380 static const std::string tableID;
381 std::uint16_t ddi;
383 std::uint8_t propertiesBitfield;
385 };
386
391 {
392 public:
399 DevicePropertyObject(std::string propertyDesignator,
400 std::int32_t propertyValue,
401 std::uint16_t propertyDDI,
402 std::uint16_t valuePresentationObject,
403 std::uint16_t uniqueID);
404
406 ~DevicePropertyObject() override = default;
407
410 std::string get_table_id() const override;
411
414 ObjectTypes get_object_type() const override;
415
418 std::vector<std::uint8_t> get_binary_object() const override;
419
422 std::int32_t get_value() const;
423
426 void set_value(std::int32_t newValue);
427
430 std::uint16_t get_ddi() const;
431
434 void set_ddi(std::uint16_t newDDI);
435
438 std::uint16_t get_device_value_presentation_object_id() const;
439
442 void set_device_value_presentation_object_id(std::uint16_t id);
443
444 private:
445 static const std::string tableID;
446 std::int32_t value;
447 std::uint16_t ddi;
449 };
450
456 {
457 public:
464 DeviceValuePresentationObject(std::string unitDesignator,
465 std::int32_t offsetValue,
466 float scaleFactor,
467 std::uint8_t numberDecimals,
468 std::uint16_t uniqueID);
469
471 ~DeviceValuePresentationObject() override = default;
472
475 std::string get_table_id() const override;
476
479 ObjectTypes get_object_type() const override;
480
483 std::vector<std::uint8_t> get_binary_object() const override;
484
487 std::int32_t get_offset() const;
488
491 void set_offset(std::int32_t newOffset);
492
495 float get_scale() const;
496
499 void set_scale(float newScale);
500
503 std::uint8_t get_number_of_decimals() const;
504
507 void set_number_of_decimals(std::uint8_t decimals);
508
509 private:
510 static const std::string tableID;
511 std::int32_t offset;
512 float scale;
513 std::uint8_t numberOfDecimals;
514 };
515 } // namespace task_controller_object
516} // namespace isobus
517
518#endif // ISOBUS_TASK_CONTROLLER_CLIENT_OBJECTS_HPP
DeviceElementObject is the object definition of the XML element DeviceElement. The attribute Type spe...
~DeviceElementObject() override=default
Destructor for a DeviceElementObject.
std::string get_table_id() const override
Returns the XML namespace for the object.
void set_element_number(std::uint16_t newElementNumber)
Update the object's element number to a new value.
ObjectTypes get_object_type() const override
Returns the object type.
std::uint16_t elementNumber
Element number for process data variable addressing.
std::uint16_t parentObject
Object ID of parent DeviceElementObject or DeviceObject in order to establish a hierarchical order of...
void add_reference_to_child_object(std::uint16_t childID)
This function can be called to add an object as a child of this object.
std::uint16_t get_number_child_objects() const
Returns the number of child objects added with add_reference_to_child_object.
std::vector< std::uint8_t > get_binary_object() const override
Returns the binary representation of the TC object, or an empty vector if object is invalid.
bool remove_reference_to_child_object(std::uint16_t childID)
Removes a child object reference from this object.
std::uint16_t get_element_number() const
Returns the element number.
std::uint16_t get_parent_object() const
Returns the parent object ID.
DeviceElementObject(std::string deviceElementDesignator, std::uint16_t deviceElementNumber, std::uint16_t parentObjectID, Type deviceEelementType, std::uint16_t uniqueID)
Constructor for a DeviceElementObject.
std::uint16_t get_child_object_id(std::size_t index)
Returns a child object ID by index.
Type get_type() const
Returns the type of the element object.
static const std::string tableID
XML element namespace for DeviceElement.
std::vector< std::uint16_t > referenceList
List of references to DeviceProcessDataObjects or DevicePropertyObjects.
Type elementType
See the comments on Type or ISO11783-10 table A.2.
void set_parent_object(std::uint16_t parentObjectID)
Updates the object ID associated to this object's parent object.
@ Unit
This device element type is, for example, used for spray boom nozzles, seeder openers,...
@ Bin
This is, for instance, the tank of a sprayer or the bin of a seeder.
@ Function
This device element type can be used as a generic device element to define individually accessible co...
@ NavigationReference
This device element type defines the navigation reference position for navigation devices such as GPS...
@ Section
This is, for instance, the section of a spray boom, seed toolbar, or planter toolbar.
@ Device
The device descriptor object pool shall have one device element of type device.
@ Connector
This device element type specifies the mounting/connection position of the device.
Each device shall have one single DeviceObject in its device descriptor object pool....
~DeviceObject() override=default
Destructor for a DeviceObject.
DeviceObject(std::string deviceDesignator, std::string deviceSoftwareVersion, std::string deviceSerialNumber, std::string deviceStructureLabel, std::array< std::uint8_t, 7 > deviceLocalizationLabel, std::vector< std::uint8_t > deviceExtendedStructureLabel, std::uint64_t clientIsoNAME, bool shouldUseExtendedStructureLabel)
Constructor for a DeviceObject.
std::string get_serial_number() const
Returns the serial number for the device.
std::array< std::uint8_t, 7 > get_localization_label() const
Returns the localization label for this DDOP.
void set_localization_label(std::array< std::uint8_t, 7 > label)
Changes the localization label to a new value.
void set_structure_label(const std::string &label)
Sets the device structure label to a new value.
void set_serial_number(const std::string &serial)
Sets the serial number for the device as reported in the DDOP.
std::vector< std::uint8_t > extendedStructureLabel
Continuation of the Label given by Device to identify the Device descriptor Structure.
void set_software_version(const std::string &version)
Sets the software version for the device, as reported in the DDOP.
std::string serialNumber
Device and manufacturer-specific serial number of the Device.
ObjectTypes get_object_type() const override
Returns the object type.
std::uint64_t get_iso_name() const
Returns the ISO NAME associated with this DDOP.
void set_extended_structure_label(const std::vector< std::uint8_t > &label)
Sets the extended structure label to a new value. Only used for TCs with version 4+.
std::vector< std::uint8_t > get_extended_structure_label() const
Returns the extended structure label (if applicable)
std::string structureLabel
Label given by device to identify the device descriptor structure.
bool useExtendedStructureLabel
Tells the device if it should generate binary info using the extended structure label or ignore it.
std::string get_structure_label() const
Returns the structure label for this DDOP.
std::string get_software_version() const
Returns the software version of the device.
std::array< std::uint8_t, task_controller_object::DeviceObject::MAX_STRUCTURE_AND_LOCALIZATION_LABEL_LENGTH > localizationLabel
Label given by device to identify the device descriptor localization.
static constexpr std::size_t MAX_STRUCTURE_AND_LOCALIZATION_LABEL_LENGTH
Defines the max length of the device structure label and device localization label (in bytes)
bool get_use_extended_structure_label() const
Returns if the class will append the extended structure label to its serialized form.
static const std::string tableID
XML element namespace for device.
void set_iso_name(std::uint64_t name)
Changes the stored ISO NAME to a new value.
std::uint64_t NAME
The NAME of client device as defined in ISO 11783-5. MUST match your address claim.
std::string get_table_id() const override
Returns the XML namespace for the object.
void set_use_extended_structure_label(bool shouldUseExtendedStructureLabel)
Sets the class' behavior for dealing with the extended structure label.
static constexpr std::size_t MAX_EXTENDED_STRUCTURE_LABEL_LENGTH
Defines the max length of the device extended structure label (in bytes)
std::vector< std::uint8_t > get_binary_object() const override
Returns the binary representation of the TC object, or an empty vector if object is invalid.
The DeviceProcessDataObject is the object definition of the XML element DeviceProcessData....
ObjectTypes get_object_type() const override
Returns the object type.
void set_ddi(std::uint16_t newDDI)
Updates the DDI associated to this DPD object.
DeviceProcessDataObject(std::string processDataDesignator, std::uint16_t processDataDDI, std::uint16_t deviceValuePresentationObjectID, std::uint8_t processDataProperties, std::uint8_t processDataTriggerMethods, std::uint16_t uniqueID)
Constructor for a DeviceProcessDataObject.
std::string get_table_id() const override
Returns the XML element namespace for DeviceProcess-Data.
std::vector< std::uint8_t > get_binary_object() const override
Returns the binary representation of the TC object, or an empty vector if object is invalid.
std::uint8_t propertiesBitfield
A bitset of properties for this object.
PropertiesBit
Enumerates the properties in the properties bitset of this object.
std::uint8_t get_trigger_methods_bitfield() const
Returns the object's available trigger methods.
std::uint16_t get_device_value_presentation_object_id() const
Returns Object identifier of the DeviceValuePresentation-Object for this object, or the null ID.
void set_trigger_methods_bitfield(std::uint8_t methods)
Updates the object's available trigger methods bitfield to a new value.
void set_device_value_presentation_object_id(std::uint16_t id)
Updates the object ID to use as an associated presentation for this object.
std::uint16_t deviceValuePresentationObject
Object identifier of DeviceValuePresentation-Object.
std::uint8_t get_properties_bitfield() const
Returns the object's properties bitfield.
AvailableTriggerMethods
Enumerates the trigger methods that can be set in the available trigger bitset of this object.
@ DistanceInterval
The device can provide these device process data based on a distance interval.
@ TimeInterval
The device can provide these device process data based on a time interval.
@ ThresholdLimits
The device can provide these device process data based on a surpassing of the value threshold.
@ OnChange
The device can provide these device process data when its value changes.
void set_properties_bitfield(std::uint8_t properties)
Updates the properties bitfield to a new value.
~DeviceProcessDataObject() override=default
Destructor for a DeviceProcessDataObject.
static const std::string tableID
XML element namespace for DeviceProcessData.
DevicePropertyObject is the object definition of the XML element DeviceProperty. Each object contains...
~DevicePropertyObject() override=default
Destructor for a DevicePropertyObject.
std::vector< std::uint8_t > get_binary_object() const override
Returns the binary representation of the TC object, or an empty vector if object is invalid.
std::string get_table_id() const override
Returns the XML element namespace for DeviceProperty.
ObjectTypes get_object_type() const override
Returns the object type.
void set_device_value_presentation_object_id(std::uint16_t id)
Updates the object ID to use as an associated presentation for this object.
DevicePropertyObject(std::string propertyDesignator, std::int32_t propertyValue, std::uint16_t propertyDDI, std::uint16_t valuePresentationObject, std::uint16_t uniqueID)
Constructor for a DevicePropertyObject.
void set_ddi(std::uint16_t newDDI)
Updates the DDI associated with this DPT object to a new value.
std::uint16_t get_device_value_presentation_object_id() const
Returns the object identifier of an associated DeviceValuePresentationObject.
std::uint16_t deviceValuePresentationObject
Object identifier of DeviceValuePresentationObject.
void set_value(std::int32_t newValue)
Sets the property value.
std::uint16_t get_ddi() const
Returns the DDI for this object.
static const std::string tableID
XML element namespace for DeviceProperty.
std::uint16_t ddi
Identifier of property (DDI) according to definitions in Annex B and ISO 11783 - 11.
This object contains the presentation information to display the value of a DeviceProcessData or Devi...
std::int32_t get_offset() const
Returns the offset that is applied to the value for presentation.
std::string get_table_id() const override
Returns the XML element namespace for DeviceValuePresentation.
void set_number_of_decimals(std::uint8_t decimals)
Sets the number of decimals to show when presenting objects associated with this presentation.
std::vector< std::uint8_t > get_binary_object() const override
Returns the binary representation of the TC object, or an empty vector if object is invalid.
float get_scale() const
Returns the scale that is applied to the value for presentation.
DeviceValuePresentationObject(std::string unitDesignator, std::int32_t offsetValue, float scaleFactor, std::uint8_t numberDecimals, std::uint16_t uniqueID)
The constructor for a DeviceValuePresentationObject.
void set_offset(std::int32_t newOffset)
Sets the offset that is applied to the value for presentation.
std::int32_t offset
Offset to be applied to the value for presentation.
void set_scale(float newScale)
Sets the scale which will be applied to the value for presentation.
std::uint8_t get_number_of_decimals() const
Returns the number of decimals shown after the decimal point.
~DeviceValuePresentationObject() override=default
Destructor for a DeviceValuePresentationObject.
static const std::string tableID
XML element namespace for DeviceValuePresentation.
std::uint8_t numberOfDecimals
Specify number of decimals to display after the decimal point.
static constexpr std::size_t MAX_DESIGNATOR_LEGACY_LENGTH
Defines the max length of a designator (in bytes) for TCs older than version 4.
static constexpr std::size_t MAX_DESIGNATOR_LENGTH
Defines the max length of a designator (in bytes)
virtual std::vector< std::uint8_t > get_binary_object() const =0
Returns the binary representation of the TC object, or an empty vector if object is invalid.
void set_designator(const std::string &newDesignator)
Updates the designator to a new value.
void set_object_id(std::uint16_t id)
Updates the object ID of the object to a new value.
virtual ~Object()=default
Destructor for a TC Object.
std::string get_designator() const
Returns the Descriptive text for this object, UTF-8 encoded, 32 characters max.
static constexpr std::uint16_t MAX_OBJECT_ID
The max allowable "valid" object ID.
std::uint16_t get_object_id() const
Returns the object ID of the object.
virtual ObjectTypes get_object_type() const =0
Returns the derived TC object type fot the object.
std::string designator
UTF-8 Descriptive text to identify this object. Max length of 32.
std::uint16_t objectID
Unique object ID in the DDOP.
Object(std::string objectDesignator, std::uint16_t uniqueID)
Constructor for the TC object base class.
virtual std::string get_table_id() const =0
Returns the XML namespace for the object.
ObjectTypes
Enumerates the different kinds of DDOP objects.
@ DeviceProperty
A device property element.
@ DeviceProcessData
Contains a single process data variable definition.
@ DeviceElement
Subcomponent of a device. Has multiple sub-types.
@ DeviceValuePresentation
Contains the presentation information to display the value of a DeviceProcessData or DeviceProperty o...
@ Device
The root object. Each device shall have one single Device.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...