Skip to content

Commit

Permalink
refactor(tc-helper): reduce duplication with common functions
Browse files Browse the repository at this point in the history
  • Loading branch information
GwnDaan committed Jan 8, 2025
1 parent fd5b1cf commit 5743f6f
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,21 @@ namespace isobus
static ProductControlInformation parse_bin(DeviceDescriptorObjectPool &ddop,
std::shared_ptr<task_controller_object::DeviceElementObject> elementObject);

/// @brief Sets the value and presence based on a DDI match.
/// @brief Sets the value and settable flag based on a DDI match for an object.
/// @param[in,out] objectPoolValue The object pool value to set.
/// @param[in] property The device property object.
/// @param[in] object The object to use to update the object pool value.
/// @param[in] ddi The DDI to check against.
static void set_value_from_property(ObjectPoolValue &objectPoolValue,
const std::shared_ptr<task_controller_object::DevicePropertyObject> &property,
DataDescriptionIndex ddi);

/// @brief Sets the settable flag based on a DDI match for process data.
/// @param[in,out] objectPoolValue The object pool value to update.
/// @param[in] processData The device process data object.
/// @param[in] ddi The DDI to check against.
static void set_editable_from_process_data(ObjectPoolValue &objectPoolValue,
const std::shared_ptr<task_controller_object::DeviceProcessDataObject> &processData,
DataDescriptionIndex ddi);
static void set_value_and_editable_from_object(ObjectPoolValue &objectPoolValue,
const std::shared_ptr<task_controller_object::Object> &object,
DataDescriptionIndex ddi);

/// @brief Sets the rate information based on the supplied object if the DDI is known to be a rate DDI.
/// @param rate The rate metadata to update.
/// @param object The object to use to update the product control information.
/// @param ddi The DDI to check against.
static void set_product_control_information_rate(RateMetadata &rate,
const std::shared_ptr<task_controller_object::Object> &object,
std::uint16_t ddi);

/// @brief Sets the max rate field of the product control information based on the supplied object
/// if the DDI is known to be a max rate DDI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef ISOBUS_TASK_CONTROLLER_CLIENT_OBJECTS_HPP
#define ISOBUS_TASK_CONTROLLER_CLIENT_OBJECTS_HPP

#include "isobus/utility/data_span.hpp"

#include <array>
#include <cstdint>
#include <string>
Expand All @@ -22,11 +24,11 @@ namespace isobus
/// @brief Enumerates the different kinds of DDOP objects
enum class ObjectTypes
{
Device, ///< The root object. Each device shall have one single Device
DeviceElement, ///< Subcomponent of a device. Has multiple sub-types
DeviceProcessData, ///< Contains a single process data variable definition
DeviceProperty, ///< A device property element
DeviceValuePresentation ///< Contains the presentation information to display the value of a DeviceProcessData or DeviceProperty object
Device, ///< The root object. Each device shall have one single Device (DVC)
DeviceElement, ///< Subcomponent of a device. Has multiple sub-types (DET)
DeviceProcessData, ///< Contains a single process data variable definition (DPD)
DeviceProperty, ///< A device property element (DPT)
DeviceValuePresentation ///< Contains the presentation information to display the value of a DeviceProcessData or DeviceProperty object (DVP)
};

/// @brief A base class for a Task Controller Object
Expand Down Expand Up @@ -272,6 +274,10 @@ namespace isobus
/// @returns true if the child object ID was found and removed, otherwise false
bool remove_reference_to_child_object(std::uint16_t childID);

/// @brief Returns a span of the child objects added with `add_reference_to_child_object`.
/// @returns A span of the child object IDs
DataSpan<const std::uint16_t> get_child_object_ids() const;

/// @brief Returns the number of child objects added with `add_reference_to_child_object`.
/// @note The maximum number of child objects is technically 65535 because the serialized
/// form of the value uses a 16-bit integer to store the count.
Expand Down Expand Up @@ -368,6 +374,11 @@ namespace isobus
/// @param[in] properties The new properties bitfield to set
void set_properties_bitfield(std::uint8_t properties);

/// @brief Tests whether a property is set in the properties bitfield
/// @param property The property to test for
/// @returns `true` if the property is set, otherwise `false`
bool has_property(DeviceProcessDataObject::PropertiesBit property);

/// @brief Returns the object's available trigger methods
/// @returns The available trigger methods bitfield for this object
std::uint8_t get_trigger_methods_bitfield() const;
Expand Down
Loading

0 comments on commit 5743f6f

Please sign in to comment.