Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,17 @@ namespace isobus
class Section
{
public:
/// @brief Gets the width value with priority order: Actual > Maximum > Default
/// @returns The width value with the highest priority, or an empty ObjectPoolValue if none are set
ObjectPoolValue get_width_with_priority() const;

ObjectPoolValue xOffset_mm; ///< The x offset of the section in mm. X offsets are fore+/aft-.
ObjectPoolValue yOffset_mm; ///< The y offset of the section in mm. Y offsets are left-/right+.
ObjectPoolValue zOffset_mm; ///< The z offset of the section in mm. Z offsets are up+/down-.
ObjectPoolValue width_mm; ///< The width of the section in mm.
ObjectPoolValue actualWorkingWidth_mm; ///< The actual working width of the section in mm.
ObjectPoolValue maximumWorkingWidth_mm; ///< The maximum working width of the section in mm.
ObjectPoolValue defaultWorkingWidth_mm; ///< The default working width of the section in mm.
ObjectPoolValue width_mm; ///< The width of the section in mm (set based on priority: Actual > Maximum > Default).
std::vector<ProductControlInformation> rates; ///< If the section has rates, this will contain the associated data needed to control the product.
std::uint16_t elementNumber = NULL_OBJECT_ID; ///< The element number of the section, which can be used to avoid further parsing of the DDOP when issuing commands.
};
Expand Down
31 changes: 29 additions & 2 deletions isobus/src/isobus_device_descriptor_object_pool_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@

namespace isobus
{
DeviceDescriptorObjectPoolHelper::ObjectPoolValue DeviceDescriptorObjectPoolHelper::Section::get_width_with_priority() const
{
// Priority order: Actual > Maximum > Default
// Only return values that are present (have been set) and are not zero
if (actualWorkingWidth_mm.exists() && 0 != actualWorkingWidth_mm.get())
{
return actualWorkingWidth_mm;
}
if (maximumWorkingWidth_mm.exists() && 0 != maximumWorkingWidth_mm.get())
{
return maximumWorkingWidth_mm;
}
if (defaultWorkingWidth_mm.exists() && 0 != defaultWorkingWidth_mm.get())
{
return defaultWorkingWidth_mm;
}
return ObjectPoolValue(); // Return empty if none are set or all are zero
}

DeviceDescriptorObjectPoolHelper::ObjectPoolValue::operator bool() const
{
return exists();
Expand Down Expand Up @@ -235,15 +254,19 @@ namespace isobus
set_value_from_property(retVal.xOffset_mm, property, DataDescriptionIndex::DeviceElementOffsetX);
set_value_from_property(retVal.yOffset_mm, property, DataDescriptionIndex::DeviceElementOffsetY);
set_value_from_property(retVal.zOffset_mm, property, DataDescriptionIndex::DeviceElementOffsetZ);
set_value_from_property(retVal.width_mm, property, DataDescriptionIndex::ActualWorkingWidth);
set_value_from_property(retVal.actualWorkingWidth_mm, property, DataDescriptionIndex::ActualWorkingWidth);
set_value_from_property(retVal.maximumWorkingWidth_mm, property, DataDescriptionIndex::MaximumWorkingWidth);
set_value_from_property(retVal.defaultWorkingWidth_mm, property, DataDescriptionIndex::DefaultWorkingWidth);
}
else if (task_controller_object::ObjectTypes::DeviceProcessData == sectionChildObject->get_object_type())
{
auto processData = std::static_pointer_cast<task_controller_object::DeviceProcessDataObject>(sectionChildObject);
set_editable_from_process_data(retVal.xOffset_mm, processData, DataDescriptionIndex::DeviceElementOffsetX);
set_editable_from_process_data(retVal.yOffset_mm, processData, DataDescriptionIndex::DeviceElementOffsetY);
set_editable_from_process_data(retVal.zOffset_mm, processData, DataDescriptionIndex::DeviceElementOffsetZ);
set_editable_from_process_data(retVal.width_mm, processData, DataDescriptionIndex::ActualWorkingWidth);
set_editable_from_process_data(retVal.actualWorkingWidth_mm, processData, DataDescriptionIndex::ActualWorkingWidth);
set_editable_from_process_data(retVal.maximumWorkingWidth_mm, processData, DataDescriptionIndex::MaximumWorkingWidth);
set_editable_from_process_data(retVal.defaultWorkingWidth_mm, processData, DataDescriptionIndex::DefaultWorkingWidth);
}
else if ((task_controller_object::ObjectTypes::DeviceElement == sectionChildObject->get_object_type()) &&
(task_controller_object::DeviceElementObject::Type::Bin == std::static_pointer_cast<task_controller_object::DeviceElementObject>(sectionChildObject)->get_type()))
Expand All @@ -257,6 +280,10 @@ namespace isobus
}
}
}

// Set width_mm based on priority: Actual > Maximum > Default
retVal.width_mm = retVal.get_width_with_priority();

retVal.elementNumber = elementObject->get_element_number();
return retVal;
}
Expand Down
4 changes: 2 additions & 2 deletions isobus/src/isobus_task_controller_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,13 @@ namespace isobus
}
else
{
if ((ddopLocalizationLabel.empty()) ||
if ((ddopLocalizationLabel == std::array<std::uint8_t, 7>{}) ||
(ddopStructureLabel.empty()))
{
LOG_DEBUG("[TC]: Beginning a search of pre-serialized DDOP for device structure and localization labels.");
process_labels_from_ddop();

if ((ddopLocalizationLabel.empty()) ||
if ((ddopLocalizationLabel == std::array<std::uint8_t, 7>{}) ||
(ddopStructureLabel.empty()))
{
LOG_ERROR("[TC]: Failed to parse the DDOP. Ensure you provided a valid device object. TC client will now terminate.");
Expand Down
19 changes: 12 additions & 7 deletions isobus/src/isobus_task_controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,16 +694,21 @@ namespace isobus
{
std::uint8_t numberOfWorkingSetMembers = rxData[0];

if (1 <= numberOfWorkingSetMembers)
if (numberOfWorkingSetMembers == 0)
{
if (nullptr == get_active_client(rxMessage.get_source_control_function()))
{
activeClients.push_back(std::make_shared<ActiveClient>(rxMessage.get_source_control_function()));
}
LOG_ERROR("[TC Server]: Working set master reported zero members – invalid!");
return;
}

// Continue normally even with 2,3,4,... members
if (nullptr == get_active_client(rxMessage.get_source_control_function()))
{
activeClients.push_back(std::make_shared<ActiveClient>(rxMessage.get_source_control_function()));
}
else

if (numberOfWorkingSetMembers != 1)
{
LOG_ERROR("[TC Server]: Working set master message received with unsupported number of working set members: %u", numberOfWorkingSetMembers);
LOG_WARNING("[TC Server]: Working set master message received with unsupported number of working set members: %u", numberOfWorkingSetMembers);
}
}
else
Expand Down
Loading