Skip to content

Commit

Permalink
feat: add helper formatters for data dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
GwnDaan committed Jan 16, 2025
1 parent 0e7cc8b commit 89bf4ab
Show file tree
Hide file tree
Showing 7 changed files with 1,802 additions and 765 deletions.
1 change: 1 addition & 0 deletions examples/seeder_example/section_control_implement_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ bool SectionControlImplementSimulator::create_ddop(std::shared_ptr<isobus::Devic
auto product = std::static_pointer_cast<isobus::task_controller_object::DeviceElementObject>(poolToPopulate->get_object_by_id(static_cast<std::uint16_t>(ImplementDDOPObjectIDs::GranularProduct)));

sprayer->add_reference_to_child_object(static_cast<std::uint16_t>(ImplementDDOPObjectIDs::DeviceActualWorkState));
sprayer->add_reference_to_child_object(static_cast<std::uint16_t>(ImplementDDOPObjectIDs::SetpointWorkState));
sprayer->add_reference_to_child_object(static_cast<std::uint16_t>(ImplementDDOPObjectIDs::DeviceTotalTime));

connector->add_reference_to_child_object(static_cast<std::uint16_t>(ImplementDDOPObjectIDs::ConnectorXOffset));
Expand Down
42 changes: 37 additions & 5 deletions isobus/include/isobus/isobus/isobus_data_dictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
///
/// @brief This file contains the definition of an auto-generated lookup of all ISOBUS DDIs
/// as defined in ISO11783-11, exported from isobus.net.
/// This file was generated January 25, 2024.
/// This file was generated January 16, 2025.
///
/// @author Adrian Del Grosso
/// @author Daan Steenbergen
/// @copyright 2024 The Open-Agriculture Developers
//================================================================================================
#ifndef ISOBUS_DATA_DICTIONARY_HPP
Expand All @@ -20,16 +21,47 @@ namespace isobus
class DataDictionary
{
public:
/// @brief A struct containing the information for a single DDI
struct Entry
/// @brief A class containing the information for a single DDI
class Entry
{
public:
const std::uint16_t ddi; ///< The DDI number

const std::string name; ///< The name of the DDI
const std::string units; ///< The units of the DDI
const std::string unitSymbol; ///< The symbol of the unit of the DDI, if any
const std::string unitDescription; ///< The description of the unit of the DDI, or "n.a." if no unit
const float resolution; ///< The resolution of the DDI
const std::pair<float, float> displayRange; ///< The display range of the DDI

/**
* @brief Get the string representation of this Entry
* @return The string representation
*/
std::string to_string() const;

/**
* @brief Format a value to a string based on this Entry
* @param value The value to format
* @return The formatted value
*/
std::string format_value(std::int32_t value) const;
};

/**
* @brief Get the string representation of a device data identifier
* @param ddi The device data identifier
* @return The string representation
*/
static std::string ddi_to_string(std::uint16_t ddi);

/**
* @brief Format a value to a string based on a device data identifier
* @param ddi The device data identifier
* @param value The value to format
* @return The formatted value
*/
static std::string format_value_with_ddi(std::uint16_t ddi, std::int32_t value);

/// @brief Checks the ISO 11783-11 database for the given DDI number
/// and returns the corresponding entry if found.
/// @param dataDictionaryIdentifier The DDI number to look up
Expand All @@ -38,7 +70,7 @@ namespace isobus

private:
#ifndef DISABLE_ISOBUS_DATA_DICTIONARY
static const Entry DDI_ENTRIES[715]; ///< A lookup table of all DDI entries in ISO11783-11
static const Entry DDI_ENTRIES[724]; ///< A lookup table of all DDI entries in ISO11783-11
#endif
static const Entry DEFAULT_ENTRY; ///< A default "unknown" DDI to return if a DDI is not in the database
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ namespace isobus
LifetimeHaulCounter = 0x01D1, ///< The number of haul cycles done by a machine over its entire lifetime
ActualRelativeConnectorAngle = 0x01D2, ///< The DDI Actual relative connector angle shall be placed in the device element of type connector in the DDOP of the TC-SC Client.
ActualPercentageContent = 0x01D3, ///< Actual Device Element Content specified as percent.
SoilSnowFrozenCondition = 0x01D4, ///< The Soil/Snow Frozen Condition DDI is used to indicate the current state of the soil or snow.
EstimatedSoilWaterCondition = 0x01D5, ///< The Estimated Soil Water Condition DDI to document the estimated soil water condition.
SoilCompaction = 0x01D6, ///< The Soil Compaction DDI to document the soil compaction.
SetpointCulturalPractice = 0x01D7, ///< The setpoint value of the cultural practice to be performed by the machine.
SetpointLengthOfCut = 0x01D8, ///< Setpoint length of cut for harvested material, e.g. Forage Harvester or Tree Harvester.
MinimumLengthOfCut = 0x01D9, ///< Minimum length of cut for harvested material, e.g. Forage Harvester or Tree Harvester.
MaximumLengthOfCut = 0x01DA, ///< Maximum length of cut for harvested material, e.g. Forage Harvester or Tree Harvester.
Expand Down Expand Up @@ -540,7 +544,49 @@ namespace isobus
LifetimeMeshBaleTotalCount = 0x020D, ///< Entire total number of mesh product units for which Net binding method was used during operation, of a device lifetime
ActualCoolingFluidTemperature = 0x020E, ///< The actual temperature of the cooling fluid for the machine.
LastBaleCapacity = 0x0210, ///< The capacity of the bale that leaves the machine.
PGNBasedData = 0xDFFE, ///< This DDI is used in the XML files to identify PGN based data.
PresentWeatherConditions = 0x022C, ///< DDI to document the current weather conditions.
PreviousRainfall = 0x022D, ///< DDI to document the previous rainfall.
TractionType = 0x0251, ///< The type of traction system used for a machine.
SteeringType = 0x0252, ///< Steering Type DDI is used to define the current active steering type of a machine.
MachineMode = 0x0253, ///< This mode does represent the overall current machine mode and shall be used only one time within the DDOP below the device element of type device.
ActualTramlineCondensedWorkState17_32 = 0x025B, ///< Combination of the Actual States of individual Tramline Valves number 17 to 32 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState33_48 = 0x025C, ///< Combination of the Actual States of individual Tramline Valves number 33 to 48 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState49_64 = 0x025D, ///< Combination of the Actual States of individual Tramline Valves number 49 to 64 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState65_80 = 0x025E, ///< Combination of the Actual States of individual Tramline Valves number 65 to 80 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState81_96 = 0x025F, ///< Combination of the Actual States of individual Tramline Valves number 81 to 96 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState97_112 = 0x0260, ///< Combination of the Actual States of individual Tramline Valves number 97 to 112 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState113_128 = 0x0261, ///< Combination of the Actual States of individual Tramline Valves number 113 to 128 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState129_144 = 0x0262, ///< Combination of the Actual States of individual Tramline Valves number 129 to 144 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState145_160 = 0x0263, ///< Combination of the Actual States of individual Tramline Valves number 145 to 160 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState161_176 = 0x0264, ///< Combination of the Actual States of individual Tramline Valves number 161 to 176 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState177_192 = 0x0265, ///< Combination of the Actual States of individual Tramline Valves number 177 to 192 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState193_208 = 0x0266, ///< Combination of the Actual States of individual Tramline Valves number 193 to 208 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState209_224 = 0x0267, ///< Combination of the Actual States of individual Tramline Valves number 209 to 224 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState225_240 = 0x0268, ///< Combination of the Actual States of individual Tramline Valves number 225 to 240 into a single Actual Tramline State of their parent DeviceElement.
ActualTramlineCondensedWorkState241_256 = 0x0269, ///< Combination of the Actual States of individual Tramline Valves number 241 to 256 into a single Actual Tramline State of their parent DeviceElement.
SetpointTramlineCondensedWorkState17_32 = 0x026A, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState33_48 = 0x026B, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState49_64 = 0x026C, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState65_80 = 0x026D, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState81_96 = 0x026E, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState97_112 = 0x026F, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState113_128 = 0x0270, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState129_144 = 0x0271, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState145_160 = 0x0272, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState161_176 = 0x0273, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState177_192 = 0x0274, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState193_208 = 0x0275, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState209_224 = 0x0276, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState225_240 = 0x0277, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
SetpointTramlineCondensedWorkState241_256 = 0x0278, ///< The Setpoint Tramline Condensed Work State DDIs are the control command counterparts to the Actual Tramline Condensed Work States DDIs.
BindingMethod = 0x0284, ///< Specification of the method used to bind bales.
ActualCO2Equivalent = 0x0297, ///< Actual CO2 equivalent specified as mass per count.
WorkingDirection = 0x029A, ///< This DDI defines the intended Working Direction in the field and also defines the numbering of the Bouts (direction is compared to AB-reference line).
MaximumDropletSize = 0x8000, ///< The maximum droplet size the system can produce.
MinimumDropletSize = 0x8001, ///< The minimum droplet size the system can produce.
DefaultDropletSize = 0xA000, ///< The default droplet size the system is producing.
ActualDropletSize = 0xB000, ///< The actual droplet size the system is producing.
SetpointDropletSize = 0xC000, ///< The setpoint for droplet size.
RequestDefaultProcessData = 0xDFFF, ///< Request Default Process Data. This DDE is the highest ISO assigned entity. The range above this number is reserved for manufacture specific DDE's.
Reserved = 0xFFFF
};
Expand Down
Loading

0 comments on commit 89bf4ab

Please sign in to comment.