Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Examples]: Seeder Example #292

Merged
merged 10 commits into from
Feb 12, 2024
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ if(BUILD_EXAMPLES)
add_subdirectory("examples/virtual_terminal/aux_inputs")
add_subdirectory("examples/task_controller_client")
add_subdirectory("examples/guidance")
add_subdirectory("examples/seeder_example")
endif()

if(BUILD_TESTING)
Expand Down
Binary file added examples/seeder_example/BasePool.iop
Binary file not shown.
32 changes: 32 additions & 0 deletions examples/seeder_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.16)
project(seeder_example)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT BUILD_EXAMPLES)
find_package(isobus REQUIRED)
endif()
find_package(Threads REQUIRED)

add_executable(
SeederExample
main.cpp
console_logger.cpp
vt_application.cpp
vt_application.hpp
seeder.cpp
seeder.hpp
object_pool.hpp
section_control_implement_sim.hpp
section_control_implement_sim.cpp)
target_link_libraries(
SeederExample PRIVATE isobus::Isobus isobus::HardwareIntegration
Threads::Threads isobus::Utility)

add_custom_command(
TARGET SeederExample
POST_BUILD
COMMENT "Copying BasePool.iop to build directory"
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/BasePool.iop
$<TARGET_FILE_DIR:SeederExample>/BasePool.iop)
67 changes: 67 additions & 0 deletions examples/seeder_example/console_logger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "isobus/isobus/can_stack_logger.hpp"

#include <iostream>

// A log sink for the CAN stack
class CustomLogger : public isobus::CANStackLogger
{
public:
void sink_CAN_stack_log(CANStackLogger::LoggingLevel level, const std::string &text) override
{
switch (level)
{
case LoggingLevel::Debug:
{
std::cout << "["
<< "\033[1;36m"
<< "Debug"
<< "\033[0m"
<< "]";
}
break;

case LoggingLevel::Info:
{
std::cout << "["
<< "\033[1;32m"
<< "Info"
<< "\033[0m"
<< "]";
}
break;

case LoggingLevel::Warning:
{
std::cout << "["
<< "\033[1;33m"
<< "Warn"
<< "\033[0m"
<< "]";
}
break;

case LoggingLevel::Error:
{
std::cout << "["
<< "\033[1;31m"
<< "Error"
<< "\033[0m"
<< "]";
}
break;

case LoggingLevel::Critical:
{
std::cout << "["
<< "\033[1;35m"
<< "Critical"
<< "\033[0m"
<< "]";
}
break;
}
std::cout << text << std::endl; // Write the text to stdout
}
};

static CustomLogger logger;
42 changes: 42 additions & 0 deletions examples/seeder_example/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//================================================================================================
/// @file main.cpp
///
/// @brief Defines `main` for the seeder example
/// @details This example is meant to use all the major protocols in a more "complete" application.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================
#include "seeder.hpp"

#include <atomic>
#include <csignal>

std::atomic_bool running = { true };

void signal_handler(int)
{
running = false;
}

int main()
{
int retVal = 0;
Seeder seederExample;
std::signal(SIGINT, signal_handler);

if (seederExample.initialize())
{
while (running)
{
seederExample.update();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
seederExample.terminate();
}
else
{
retVal = -1; // Something wasn't right, such as CAN interface was missing.
}
return retVal;
}
222 changes: 222 additions & 0 deletions examples/seeder_example/object_pool.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
//================================================================================================
/// @file object_pool.hpp
///
/// @brief Defines the object IDs in the Seeder Example object pool
/// @details This is a file that should be auto-generated by your object pool designer application.
/// @author Adrian Del Grosso
///
/// @copyright 2023 Adrian Del Grosso
//================================================================================================

#ifndef OBJECT_POOL_HPP
#define OBJECT_POOL_HPP

#define UNDEFINED 65535 //0xFFFF
#define example_WorkingSet 0 //0x0000
#define mainRunscreen_DataMask 1000 //0x03E8
#define statisticsRunscreen_DataMask 1001 //0x03E9
#define settingsRunscreen_DataMask 1002 //0x03EA
#define alarmsRunscreen_DataMask 1003 //0x03EB
#define noSpeed_AlarmMask 2000 //0x07D0
#define noTaskController_AlarmMask 2001 //0x07D1
#define planterRunscreenStatus_Container 3000 //0x0BB8
#define credits_Container 3001 //0x0BB9
#define section1Switch_Container 3002 //0x0BBA
#define section2Switch_Container 3003 //0x0BBB
#define section3Switch_Container 3004 //0x0BBC
#define section4Switch_Container 3005 //0x0BBD
#define section5Switch_Container 3006 //0x0BBE
#define section6Switch_Container 3007 //0x0BBF
#define sectionButtons_Container 3008 //0x0BC0
#define statisticsDropdown_Container 3009 //0x0BC1
#define hamburgerMenu_Container 3010 //0x0BC2
#define canStatistics_Container 3011 //0x0BC3
#define manualMode_Container 3012 //0x0BC4
#define readoutBusLoad_Container 3013 //0x0BC5
#define readoutMyAddress_Container 3014 //0x0BC6
#define utStatistics_Container 3015 //0x0BC7
#define utVersion_Container 3016 //0x0BC8
#define utAddress_Container 3017 //0x0BC9
#define tcStatistics_Container 3018 //0x0BCA
#define tcVersion_Container 3019 //0x0BCB
#define tcAddress_Container 3020 //0x0BCC
#define tcNumberSupportedBooms_Container 3021 //0x0BCD
#define tcNumberSectionsSupported_Container 3022 //0x0BCE
#define tcControlChannels_Container 3023 //0x0BCF
#define autoManual_Container 3024 //0x0BD0
#define autoMode_Container 3025 //0x0BD1
#define speedReadout_Container 3026 //0x0BD2
#define noTcAlarmLine_Container 3027 //0x0BD3
#define noSpeedAlarmLine_Container 3028 //0x0BD4
#define enableAlarms_Container 3029 //0x0BD5
#define mainRunscreen_SoftKeyMask 4000 //0x0FA0
#define alarm_SKeyMask 4001 //0x0FA1
#define returnHome_SKeyMask 4002 //0x0FA2
#define home_Key 5000 //0x1388
#define acknowledgeAlarm_SoftKey 5001 //0x1389
#define settings_Key 5002 //0x138A
#define alarms_Key 5003 //0x138B
#define statistics_Key 5004 //0x138C
#define section1Toggle_Button 6000 //0x1770
#define section2Toggle_Button 6001 //0x1771
#define section3Toggle_Button 6002 //0x1772
#define section4Toggle_Button 6003 //0x1773
#define section5Toggle_Button 6004 //0x1774
#define section6Toggle_Button 6005 //0x1775
#define autoManualToggle_Button 6006 //0x1776
#define enableAlarms_InBool 7000 //0x1B58
#define statistics_InList 10000 //0x2710
#define Title_OutStr 11000 //0x2AF8
#define onOffIconCredit_OutStr 11001 //0x2AF9
#define speed_OutStr 11002 //0x2AFA
#define temp_OutStr_ID_11003 11003 //0x2AFB
#define noMachineSpeedTitle_OutStr 11004 //0x2AFC
#define longTest_OutStr 11005 //0x2AFD
#define credits_OutStr 11006 //0x2AFE
#define planterIconCredit_OutStr 11007 //0x2AFF
#define settingsHeader_OutStr 11008 //0x2B00
#define homeIconCredit_OutStr 11009 //0x2B01
#define statisticsHeader_OutStr 11010 //0x2B02
#define busload_OutStr 11011 //0x2B03
#define unitPercent_OutStr 11012 //0x2B04
#define statisticsChoose_OutStr 11013 //0x2B05
#define listItemTaskController_OutStr 11014 //0x2B06
#define listItemCANBus_OutStr 11015 //0x2B07
#define listItemUniversalTerminal_OutStr 11016 //0x2B08
#define currentAddress_OutStr 11017 //0x2B09
#define reportedVersion_OutStr 11018 //0x2B0A
#define utAddress_OutStr 11019 //0x2B0B
#define tcAddress_OutStr 11020 //0x2B0C
#define tcNumberSupportedBooms_OutStr 11021 //0x2B0D
#define tcNumberSectionsSupported_OutStr 11022 //0x2B0E
#define tcControlChannels_OutStr 11023 //0x2B0F
#define autoIconCredit_OutStr 11024 //0x2B10
#define autoManual_OutStr 11025 //0x2B11
#define infoIconCredit_OutStr 11026 //0x2B12
#define statisticsIconCredit_OutStr 11027 //0x2B13
#define listItemCredits_OutStr 11028 //0x2B14
#define unitKph_OutStr 11029 //0x2B15
#define unitMph_OutStr 11030 //0x2B16
#define machineSpeedNotDetectedSummary_OutStr 11031 //0x2B17
#define noTCTitle_OutStr 11032 //0x2B18
#define TCNotConnectedSummary_OutStr 11033 //0x2B19
#define currentAlarmsHeader_OutStr 11034 //0x2B1A
#define noActiveAlarms_OutStr 11035 //0x2B1B
#define NoTaskController_OutStr 11036 //0x2B1C
#define NoMachineSpeed_OutStr 11037 //0x2B1D
#define enableAlarms_OutStr 11038 //0x2B1E
#define busload_OutNum 12000 //0x2EE0
#define canAddress_OutNum 12001 //0x2EE1
#define utVersion_OutNum 12002 //0x2EE2
#define utAddress_OutNum 12003 //0x2EE3
#define tcVersion_OutNum 12004 //0x2EE4
#define tcAddress_OutNum 12005 //0x2EE5
#define tcNumberBoomsSupported_OutNum 12006 //0x2EE6
#define tcSupportedSections_OutNum 12007 //0x2EE7
#define tcControlChannels_OutNum 12008 //0x2EE8
#define speed_OutNum 12009 //0x2EE9
#define ten_OutNum 12010 //0x2EEA
#define zero_OutNum 12011 //0x2EEB
#define twenty_OutNum 12012 //0x2EEC
#define thirty_OutNum 12013 //0x2EED
#define headerBorder_OutLine 13000 //0x32C8
#define Title_OutRect 14000 //0x36B0
#define MainRunscreenBackground_OutRect 14001 //0x36B1
#define section1Status_OutRect 14002 //0x36B2
#define section2Status_OutRect 14003 //0x36B3
#define section3Status_OutRect 14004 //0x36B4
#define section4Status_OutRect 14005 //0x36B5
#define section5Status_OutRect 14006 //0x36B6
#define section6Status_OutRect 14007 //0x36B7
#define dropdown_OutRect 14008 //0x36B8
#define hamburgerLine_OutRect 14009 //0x36B9
#define readoutGeneric_OutRect 14010 //0x36BA
#define buttonCover_OutRect 14011 //0x36BB
#define temp_OutEllipse 15000 //0x3A98
#define currentSpeed_OutMeter 17000 //0x4268
#define avatar_OutPict 20000 //0x4E20
#define warningIcon_OutPict 20001 //0x4E21
#define warning_OutPict 20002 //0x4E22
#define greenCheck_OutPict 20003 //0x4E23
#define gear_OutPict 20004 //0x4E24
#define planter_OutPict 20005 //0x4E25
#define offButtonSliderSmall_OutPict 20006 //0x4E26
#define onButtonSliderSmall_OutPict 20007 //0x4E27
#define home_OutPict 20008 //0x4E28
#define auto_OutPict 20009 //0x4E29
#define manual_OutPict 20010 //0x4E2A
#define info_OutPict 20011 //0x4E2B
#define stats_OutPict 20012 //0x4E2C
#define Copy1_info_OutPict 20013 //0x4E2D
#define ButtonExampleNumber_VarNum 21000 //0x5208
#define statisticsSelection_VarNum 21001 //0x5209
#define busload_VarNum 21002 //0x520A
#define canAddress_VarNum 21003 //0x520B
#define utVersion_VarNum 21004 //0x520C
#define utAddress_VarNum 21005 //0x520D
#define tcVersion_VarNum 21006 //0x520E
#define tcAddress_VarNum 21007 //0x520F
#define tcNumberBoomsSupported_VarNum 21008 //0x5210
#define tcSupportedSections_VarNum 21009 //0x5211
#define tcControlChannels_VarNum 21010 //0x5212
#define currentSpeedMeter_VarNum 21011 //0x5213
#define currentSpeedReadout_VarNum 21012 //0x5214
#define enableAlarms_VarNum 21013 //0x5215
#define title_OutStr 22000 //0x55F0
#define onOffIconsCredit_VarStr 22001 //0x55F1
#define alarmMaskTitle_VarStr 22002 //0x55F2
#define ExampleAlarmMask_VarStr 22003 //0x55F3
#define planterIconsCredit_VarStr 22004 //0x55F4
#define credits_VarStr 22005 //0x55F5
#define settingsHeader_VarStr 22006 //0x55F6
#define statisticsHeader_VarStr 22007 //0x55F7
#define homeIconsCredit_VarStr 22008 //0x55F8
#define busload_VarStr 22009 //0x55F9
#define statisticsChoose_VarStr 22010 //0x55FA
#define canBus_VarStr 22011 //0x55FB
#define taskController_VarStr 22012 //0x55FC
#define universalTerminal_VarStr 22013 //0x55FD
#define currentAddress_VarStr 22014 //0x55FE
#define utVersion_VarStr 22015 //0x55FF
#define utAddress_VarStr 22016 //0x5600
#define tcAddress_VarStr 22017 //0x5601
#define tcNumberBoomsSupported_VarStr 22018 //0x5602
#define tcNumberSectionsSupported_VarStr 22019 //0x5603
#define tcControlChannels_VarStr 22020 //0x5604
#define managementIconsCredit_VarStr 22021 //0x5605
#define autoManual_VarStr 22022 //0x5606
#define infoIconsCredit_VarStr 22023 //0x5607
#define statisticsIconsCredit_VarStr 22024 //0x5608
#define speed_VarStr 22025 //0x5609
#define machineSpeedNotDetectedSummary_VarStr 22026 //0x560A
#define noTaskController_VarStr 22027 //0x560B
#define noTCSummary_VarStr 22028 //0x560C
#define currentAlarms_VarStr 22029 //0x560D
#define noActiveAlarms_VarStr 22030 //0x560E
#define enableAlarms_VarStr 22031 //0x560F
#define temp_FontAttr_ID_23000 23000 //0x59D8
#define temp_FontAttr_ID_23001 23001 //0x59D9
#define black48x64_FontAttr 23002 //0x59DA
#define unitFont_FontAttr 23003 //0x59DB
#define listItem_FontAttr 23004 //0x59DC
#define blackBold24x32_FontAttr 23005 //0x59DD
#define solidBlack_LineAttr 24000 //0x5DC0
#define suppressed_LineAttr 24001 //0x5DC1
#define solidWhite_FillAttr 25000 //0x61A8
#define solidRed_FillAttr 25001 //0x61A9
#define solidGreen_FillAttr 25002 //0x61AA
#define solidYellow_FillAttr 25003 //0x61AB
#define solidBlack_FillAttr 25004 //0x61AC
#define speedUnits_ObjPtr 27000 //0x6978
#define section1EnableState_ObjPtr 27001 //0x6979
#define section2EnableState_ObjPtr 27002 //0x697A
#define section3EnableState_ObjPtr 27003 //0x697B
#define section4EnableState_ObjPtr 27004 //0x697C
#define section5EnableState_ObjPtr 27005 //0x697D
#define section6EnableState_ObjPtr 27006 //0x697E
#define selectedStatisticsContainer_ObjPtr 27007 //0x697F
#define autoManual_ObjPtr 27008 //0x6980
#define currentAlarms1_ObjPtr 27009 //0x6981
#define currentAlarms2_ObjPtr 27010 //0x6982

#endif // OBJECT_POOL_HPP
Loading
Loading