Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GwnDaan committed Jan 30, 2024
1 parent b9fe4f2 commit a738fff
Show file tree
Hide file tree
Showing 12 changed files with 896 additions and 1,101 deletions.
44 changes: 2 additions & 42 deletions examples/seeder_example/section_control_implement_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ bool SectionControlImplementSimulator::create_ddop(std::shared_ptr<isobus::Devic
for (std::uint_fast8_t i = 0; i < get_number_of_sections(); i++)
{
std::int32_t individualSectionWidth = BOOM_WIDTH / get_number_of_sections();
retVal &= poolToPopulate->add_device_element("Section " + isobus::to_string(static_cast<int>(i)), elementCounter, 9, isobus::task_controller_object::DeviceElementObject::Type::Section, static_cast<std::uint16_t>(ImplementDDOPObjectIDs::Section1) + i);
retVal &= poolToPopulate->add_device_element("Section " + isobus::to_string(static_cast<int>(i)), elementCounter, static_cast<std::uint16_t>(ImplementDDOPObjectIDs::MainBoom), isobus::task_controller_object::DeviceElementObject::Type::Section, static_cast<std::uint16_t>(ImplementDDOPObjectIDs::Section1) + i);
retVal &= poolToPopulate->add_device_property("Offset X", -20, static_cast<std::uint16_t>(isobus::DataDescriptionIndex::DeviceElementOffsetX), static_cast<std::uint16_t>(ImplementDDOPObjectIDs::LongWidthPresentation), static_cast<std::uint16_t>(ImplementDDOPObjectIDs::Section1XOffset) + i);
retVal &= poolToPopulate->add_device_property("Offset Y", ((-BOOM_WIDTH) / 2) + (i * SECTION_WIDTH) + (SECTION_WIDTH / 2), static_cast<std::uint16_t>(isobus::DataDescriptionIndex::DeviceElementOffsetY), static_cast<std::uint16_t>(ImplementDDOPObjectIDs::LongWidthPresentation), static_cast<std::uint16_t>(ImplementDDOPObjectIDs::Section1YOffset) + i);
retVal &= poolToPopulate->add_device_property("Width", individualSectionWidth, static_cast<std::uint16_t>(isobus::DataDescriptionIndex::ActualWorkingWidth), static_cast<std::uint16_t>(ImplementDDOPObjectIDs::LongWidthPresentation), static_cast<std::uint16_t>(ImplementDDOPObjectIDs::Section1Width) + i);
Expand Down Expand Up @@ -332,46 +332,6 @@ bool SectionControlImplementSimulator::request_value_command_callback(std::uint1
}
break;

case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState1_16):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState17_32):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState33_48):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState49_64):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState65_80):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState81_96):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState97_112):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState113_128):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState129_144):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState145_160):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState161_176):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState177_192):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState193_208):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState209_224):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState225_240):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState241_256):
{
std::uint8_t sectionIndexOffset = NUMBER_SECTIONS_PER_CONDENSED_MESSAGE * (DDI - static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCondensedWorkState1_16));
value = 0;

for (std::uint_fast8_t i = 0; i < NUMBER_SECTIONS_PER_CONDENSED_MESSAGE; i++)
{
if ((i + sectionIndexOffset) < sim->get_number_of_sections())
{
value |= sim->get_section_setpoint_state(i + sectionIndexOffset) << (2 * i);
}
else
{
value |= (static_cast<std::uint32_t>(0x03) << (2 * i));
}
}
}
break;

case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SetpointCountPerAreaApplicationRate):
{
value = sim->get_target_rate();
}
break;

default:
{
value = 0;
Expand Down Expand Up @@ -437,7 +397,7 @@ bool SectionControlImplementSimulator::value_command_callback(std::uint16_t,
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::PrescriptionControlState):
case static_cast<std::uint16_t>(isobus::DataDescriptionIndex::SectionControlState):
{
// Technically the TC can set this, but we're just managing it with our auto state
sim->set_is_mode_auto(processVariableValue);
}
break;

Expand Down
4 changes: 2 additions & 2 deletions examples/seeder_example/seeder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool Seeder::initialize()
// Automatically load the desired CAN driver based on the available drivers
std::shared_ptr<isobus::CANHardwarePlugin> canDriver = nullptr;
#if defined(ISOBUS_SOCKETCAN_AVAILABLE)
canDriver = std::make_shared<isobus::SocketCANInterface>("can0");
canDriver = std::make_shared<isobus::SocketCANInterface>("can1");
#elif defined(ISOBUS_WINDOWSPCANBASIC_AVAILABLE)
canDriver = std::make_shared<isobus::PCANBasicWindowsPlugin>(PCAN_USBBUS1);
#elif defined(ISOBUS_WINDOWSINNOMAKERUSB2CAN_AVAILABLE)
Expand Down Expand Up @@ -104,7 +104,7 @@ void Seeder::terminate()
{
if (nullptr != VTApplication)
{
VTApplication->VTClientInterface.terminate();
VTApplication->VTClientInterface->terminate();
VTApplication->TCClientInterface.terminate();
}
if (nullptr != diagnosticProtocol)
Expand Down
Loading

0 comments on commit a738fff

Please sign in to comment.