Skip to content

Commit

Permalink
[TC]: Add distance thresholds and handling of default process data
Browse files Browse the repository at this point in the history
  • Loading branch information
ad3154 committed Jul 27, 2024
1 parent c44ce96 commit 447f766
Show file tree
Hide file tree
Showing 8 changed files with 798 additions and 112 deletions.
105 changes: 105 additions & 0 deletions examples/seeder_example/section_control_implement_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,111 @@ bool SectionControlImplementSimulator::create_ddop(std::shared_ptr<isobus::Devic
return retVal;
}

bool SectionControlImplementSimulator::default_process_data_request_callback(std::uint16_t elementNumber,
std::uint16_t DDI,
isobus::TaskControllerClient::DefaultProcessDataSettings &returnedSettings,
void *parentPointer)
{
bool retVal = false;

if (nullptr != parentPointer)
{
switch (elementNumber)
{
case static_cast<std::uint16_t>(ImplementDDOPElementNumbers::BinElement):
{
switch (DDI)
{
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCountPerAreaApplicationRate):
{
returnedSettings.enableChangeThresholdTrigger = true;
returnedSettings.changeThreshold = 1;
retVal = true;
}
break;

case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::MaximumCountContent):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::ActualCountContent):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::ActualCountPerAreaApplicationRate):
{
returnedSettings.enableChangeThresholdTrigger = true;
returnedSettings.enableTimeTrigger = true;
returnedSettings.changeThreshold = 1;
returnedSettings.timeTriggerInterval_ms = 1000;
retVal = true;
}
break;

case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::PrescriptionControlState):
{
returnedSettings.enableChangeThresholdTrigger = true;
returnedSettings.enableTimeTrigger = true;
returnedSettings.changeThreshold = 1;
returnedSettings.timeTriggerInterval_ms = 5000;
retVal = true;
}
break;

default:
{
}
break;
}
}
break;

case static_cast<std::uint16_t>(ImplementDDOPElementNumbers::BoomElement):
{
switch (DDI)
{
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::ActualWorkingWidth):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointWorkState):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::ActualCondensedWorkState1_16):
{
returnedSettings.enableChangeThresholdTrigger = true;
returnedSettings.changeThreshold = 1;
retVal = true;
}
break;

case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SectionControlState):
{
returnedSettings.enableChangeThresholdTrigger = true;
returnedSettings.enableTimeTrigger = true;
returnedSettings.changeThreshold = 1;
returnedSettings.timeTriggerInterval_ms = 1000;
retVal = true;
}
break;

default:
{
}
break;
}
}
break;

case static_cast<std::uint16_t>(ImplementDDOPElementNumbers::DeviceElement):
{
if (static_cast<std::uint16_t>(isobus::DataDescriptionIndex::ActualWorkState) == DDI)
{
returnedSettings.enableChangeThresholdTrigger = true;
returnedSettings.changeThreshold = 1;
retVal = true;
}
}
break;

default:
{
}
break;
}
}
return retVal;
}

bool SectionControlImplementSimulator::request_value_command_callback(std::uint16_t,
std::uint16_t DDI,
std::int32_t &value,
Expand Down
24 changes: 23 additions & 1 deletion examples/seeder_example/section_control_implement_sim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "isobus/isobus/can_NAME.hpp"
#include "isobus/isobus/can_message.hpp"
#include "isobus/isobus/isobus_device_descriptor_object_pool.hpp"
#include "isobus/isobus/isobus_task_controller_client.hpp"

/// @brief Simulates a planter rate controller with section control
/// @note This is just an example. A real rate controller will obviously need to control rate and section
Expand Down Expand Up @@ -105,6 +105,17 @@ class SectionControlImplementSimulator
CountPerAreaPresentation ///< Describes to the TC how to display volume per area units
};

/// @brief Enumerates the elements in the DDOP for easier reference in the application
enum class ImplementDDOPElementNumbers : std::uint16_t
{
DeviceElement = 0,
ConnectorElement = 1,
BoomElement = 2,
BinElement = 3,
Section1Element = 4,
SectionMaxElement = Section1Element + (MAX_NUMBER_SECTIONS_SUPPORTED - 1)
};

/// @brief Constructor for the simulator
/// @param[in] value The number of sections to track for section control
explicit SectionControlImplementSimulator(std::uint8_t value);
Expand Down Expand Up @@ -167,6 +178,17 @@ class SectionControlImplementSimulator
/// @returns true if the DDOP was successfully created, otherwise false
bool create_ddop(std::shared_ptr<isobus::DeviceDescriptorObjectPool> poolToPopulate, isobus::NAME clientName) const;

/// @brief Sets up default triggers for various elements in the DDOP when the TC requests it.
/// @param[in] elementNumber The element number to set up triggers for if applicable
/// @param[in] DDI The DDI to set up triggers for if applicable
/// @param[out] returnedSettings The settings to return to the TC
/// @param[in] parentPointer A pointer to the class instance this callback is for
/// @returns true if the triggers were set up successfully, otherwise false if no triggers needed to be configured
static bool default_process_data_request_callback(std::uint16_t elementNumber,
std::uint16_t DDI,
isobus::TaskControllerClient::DefaultProcessDataSettings &returnedSettings,
void *parentPointer);

/// @brief A callback that will be used by the TC client to read values
/// @param[in] elementNumber The element number associated to the value being requested
/// @param[in] DDI The ddi of the value in the element being requested
Expand Down
3 changes: 3 additions & 0 deletions examples/seeder_example/vt_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ bool SeederVtApplication::initialize()
TCClientInterface.configure(ddop, 1, 255, 255, true, true, true, false, true);
TCClientInterface.add_request_value_callback(SectionControlImplementSimulator::request_value_command_callback, &sectionControl);
TCClientInterface.add_value_command_callback(SectionControlImplementSimulator::value_command_callback, &sectionControl);
TCClientInterface.add_default_process_data_requested_callback(SectionControlImplementSimulator::default_process_data_request_callback, &sectionControl);
TCClientInterface.initialize(true);
}
else
Expand Down Expand Up @@ -184,6 +185,8 @@ void SeederVtApplication::handle_vt_key_events(const isobus::VirtualTerminalClie
{
update_section_objects(i);
}
TCClientInterface.on_value_changed_trigger(static_cast<std::uint16_t>(SectionControlImplementSimulator::ImplementDDOPElementNumbers::BoomElement),
static_cast<std::uint16_t>(isobus::DataDescriptionIndex::RequestDefaultProcessData));
}
break;

Expand Down
6 changes: 3 additions & 3 deletions isobus/include/isobus/isobus/can_network_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace isobus
/// @brief Sets the minimum time to wait between sending BAM frames
/// (default is 50 ms for maximum J1939 compatibility)
/// @details The acceptable range as defined by ISO-11783 is 10 to 200 ms.
/// This is a minumum time, so if you set it to some value, like 10 ms, the
/// This is a minimum time, so if you set it to some value, like 10 ms, the
/// stack will attempt to transmit it as close to that time as it can, but it is
/// not possible to 100% ensure it.
/// @param[in] value The minimum time to wait between sending BAM frames
Expand Down Expand Up @@ -74,13 +74,13 @@ namespace isobus
/// @returns The max number of frames to use in transport protocols in each network manager update
std::uint8_t get_max_number_of_network_manager_protocol_frames_per_update() const;

/// @brief Set the the number of packets per CTS message for TP sessions. The default
/// @brief Set the number of packets per CTS message for TP sessions. The default
/// is 16. Note that the receiving control function may not support this limitation, or choose
/// to ignore it and use a different number of packets per CTS packet.
/// @param[in] numberPackets The number of packets per CTS packet for TP sessions.
void set_number_of_packets_per_cts_message(std::uint8_t numberPackets);

/// @brief Get the the number of packets per CTS packet for TP sessions.
/// @brief Get the number of packets per CTS packet for TP sessions.
/// @returns The number of packets per CTS packet for TP sessions.
std::uint8_t get_number_of_packets_per_cts_message() const;

Expand Down
Loading

0 comments on commit 447f766

Please sign in to comment.