123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- //
- //
- // 20210425, hl_dispatch 和 hl_dispatch_B的版本进行同步, 此时调度管理的功能全部完成.后续可能还需要日志记录.
- //
- #include <iostream>
- #include "./error_code/error_code.h"
- //#include "LogFiles.h"
- #include <glog/logging.h>
- #include "./communication/communication_socket_base.h"
- #include "./tool/thread_pool.h"
- #include "./system/system_communication.h"
- #include "./system/system_executor.h"
- #include "./dispatch/dispatch_manager.h"
- #include "./dispatch/dispatch_communication.h"
- #include "./dispatch/dispatch_coordinates.h"
- #include "./tool/common_data.h"
- #include <algorithm> // std::for_each
- #define LIVOX_NUMBER 2
- GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
- {
- time_t tt;
- time( &tt );
- tt = tt + 8*3600; // transform the time zone
- tm* t= gmtime( &tt );
- char buf[255]={0};
- sprintf(buf,"./%d%02d%02d-%02d%02d%02d-dump.txt",
- t->tm_year + 1900,
- t->tm_mon + 1,
- t->tm_mday,
- t->tm_hour,
- t->tm_min,
- t->tm_sec);
- FILE* tp_file=fopen(buf,"w");
- fprintf(tp_file,data,strlen(data));
- fclose(tp_file);
- }
- #include <chrono>
- using namespace std;
- class AAA
- {
- public:
- int a;
- };
- class BBB:public AAA
- {
- public:
- int b;
- };
- int main(int argc,char* argv[])
- {
- // char buf[4];
- // sprintf(buf, "ads");
- // std::cout << " huli test :::: " << " buf = " << buf << std::endl;
- // std::string str = buf;
- // std::cout << " huli test :::: " << " str = " << str << std::endl;
- // std::cout << " huli test :::: " << " str.size() = " << str.size() << std::endl;
- //
- // return 0;
- Error_manager t_error;
- const char* logPath = "./";
- google::InitGoogleLogging("LidarMeasurement");
- google::SetStderrLogging(google::INFO);
- google::SetLogDestination(0, logPath);
- google::SetLogFilenameExtension("zxlog");
- google::InstallFailureSignalHandler();
- google::InstallFailureWriter(&shut_down_logging);
- FLAGS_colorlogtostderr = true; // Set log color
- FLAGS_logbufsecs = 0; // Set log output speed(s)
- FLAGS_max_log_size = 1024; // Set max log file size(GB)
- FLAGS_stop_logging_if_full_disk = true;
- //#define MAIN_TEST 1
- #ifdef MAIN_TEST
- t_error = Dispatch_coordinates::get_instance_references().dispatch_coordinates_init();
- std::cout << " huli test :::: " << " Dispatch_coordinates::get_instance_references().dispatch_coordinates_init() = " << t_error.to_string() << std::endl;
- t_error = Dispatch_communication::get_instance_references().communication_init();
- std::cout << " huli test :::: " << " Dispatch_communication::get_instance_references().communication_init() = " << t_error.to_string() << std::endl;
- std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
- t_error = Dispatch_manager::get_instance_references().dispatch_manager_init(0);
- std::cout << " huli test :::: " << " Dispatch_manager::get_instance_references().dispatch_manager_init(0) = " << t_error.to_string() << std::endl;
- std::cout << "Dispatch_manager = " << Dispatch_manager::get_instance_references().get_dispatch_manager_status() << std::endl;
- System_executor::get_instance_references().system_executor_init(10);
- std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
- System_communication::get_instance_references().communication_init();
- System_communication::get_instance_references().set_encapsulate_cycle_time(1000);
- while (1)
- {
- std::this_thread::sleep_for(std::chrono::seconds(1));
- }
- return 0;
- #endif
- // Error_manager t_error;
- t_error = Dispatch_communication::get_instance_references().communication_init();
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
- std::this_thread::sleep_for(std::chrono::seconds(2));
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- Catcher t_catcher;
- t_error = t_catcher.dispatch_device_base_init(1, 102);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(2));
- std::shared_ptr<Task_Base> tp_task_Base1(new Catcher_task);
- Catcher_task * tp_catcher_task1 = (Catcher_task *)tp_task_Base1.get();
- tp_catcher_task1->task_init(NULL,std::chrono::milliseconds(15000));
- tp_catcher_task1->m_request_key = "x23456789012345678901234567890r1";
- tp_catcher_task1->m_request_x = 21000;
- tp_catcher_task1->m_request_y = 3000;
- tp_catcher_task1->m_request_b = 90;
- tp_catcher_task1->m_request_z = 5410;
- tp_catcher_task1->m_request_d1 = 355;
- tp_catcher_task1->m_request_d2 = 455;
- tp_catcher_task1->m_request_wheelbase = 2800;
- tp_catcher_task1->m_request_clamp_motion = Catcher_task::E_CLAMP_LOOSE;
- t_error = t_catcher.execute_task(tp_task_Base1, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- Carrier t_carrier20;
- t_error = t_carrier20.dispatch_device_base_init(0, 200);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(2));
- std::shared_ptr<Task_Base> tp_task_Base20(new Carrier_task);
- Carrier_task * tp_carrier_task20 = (Carrier_task *)tp_task_Base20.get();
- tp_carrier_task20->task_init(NULL,std::chrono::milliseconds(15000));
- tp_carrier_task20->m_request_key = "x23456789012345678901234567890c0";
- tp_carrier_task20->m_request_x = 1;
- // tp_carrier_task20->m_request_x = 25400;
- // tp_carrier_task20->m_request_x = 32600;
- tp_carrier_task20->m_request_y = 3000;
- tp_carrier_task20->m_request_z = 2525;
- tp_carrier_task20->m_request_z = 15525;
- tp_carrier_task20->m_request_y1 = 4500;
- tp_carrier_task20->m_request_y2 = 1700;
- tp_carrier_task20->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
- tp_carrier_task20->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
- tp_carrier_task20->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
- tp_carrier_task20->m_request_space_id = 555;
- tp_carrier_task20->m_request_floor_id = 555;
- tp_carrier_task20->m_request_wheelbase = 555;
- t_error = t_carrier20.execute_task(tp_task_Base20, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- Carrier t_carrier21;
- t_error = t_carrier21.dispatch_device_base_init(1, 207);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(2));
- std::shared_ptr<Task_Base> tp_task_Base21(new Carrier_task);
- Carrier_task * tp_carrier_task21 = (Carrier_task *)tp_task_Base21.get();
- tp_carrier_task21->task_init(NULL,std::chrono::milliseconds(15000));
- tp_carrier_task21->m_request_key = "x23456789012345678901234567890c1";
- // tp_carrier_task21->m_request_x = 1;
- tp_carrier_task21->m_request_x = 32600;
- tp_carrier_task21->m_request_y = 3000;
- tp_carrier_task21->m_request_z = 2525;
- tp_carrier_task21->m_request_z = 5125;
- tp_carrier_task21->m_request_y1 = 4500;
- tp_carrier_task21->m_request_y2 = 1700;
- tp_carrier_task21->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
- tp_carrier_task21->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
- tp_carrier_task21->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
- tp_carrier_task21->m_request_space_id = 555;
- tp_carrier_task21->m_request_floor_id = 555;
- tp_carrier_task21->m_request_wheelbase = 555;
- t_error = t_carrier21.execute_task(tp_task_Base21, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- Carrier t_carrier22;
- t_error = t_carrier22.dispatch_device_base_init(2, 203);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(2));
- std::shared_ptr<Task_Base> tp_task_Base22(new Carrier_task);
- Carrier_task * tp_carrier_task22 = (Carrier_task *)tp_task_Base22.get();
- tp_carrier_task22->task_init(NULL,std::chrono::milliseconds(15000));
- tp_carrier_task22->m_request_key = "x23456789012345678901234567890c2";
- tp_carrier_task22->m_request_x = 21000;
- // tp_carrier_task22->m_request_x = 4700;
- tp_carrier_task22->m_request_y = 3000;
- tp_carrier_task22->m_request_z = 5125;
- tp_carrier_task22->m_request_y1 = 4500;
- tp_carrier_task22->m_request_y2 = 1700;
- tp_carrier_task22->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
- tp_carrier_task22->m_request_joint_motion_x = Carrier_task::E_JOINT_HOLD_OUT;
- tp_carrier_task22->m_request_joint_motion_y = Carrier_task::E_JOINT_HOLD_OUT;
- tp_carrier_task22->m_request_space_id = 555;
- tp_carrier_task22->m_request_floor_id = 555;
- tp_carrier_task22->m_request_wheelbase = 555;
- t_error = t_carrier22.execute_task(tp_task_Base22, Dispatch_device_base::DISPATCH_TASK_ONE_LEVEL);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- /*
- Passageway t_passageway;
- t_error = t_passageway.dispatch_device_base_init(1);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(2));
- std::shared_ptr<Task_Base> tp_task_Base3(new Passageway_task);
- Passageway_task * tp_passageway_task = (Passageway_task *)tp_task_Base3.get();
- tp_passageway_task->task_init(NULL,std::chrono::milliseconds(15000));
- tp_passageway_task->m_request_key = "ABCDEF";
- tp_passageway_task->m_request_inside_door_motion = Passageway_task::DOOR_OPEN;
- tp_passageway_task->m_request_outside_door_motion = Passageway_task::DOOR_CLOSE;
- tp_passageway_task->m_request_turntable_direction = Passageway_task::TURNTABLE_DIRECTION_OUTSIDE;
- t_error = t_passageway.execute_task(tp_task_Base3, Dispatch_device_base::E_ONE_LEVEL);
- std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- char zxczxcxzc3 ;
- std::cin >> zxczxcxzc3 ;
- while ( 1 )
- {
- std::cout << " huli test :::: " << " ===================================== " << std::endl;
- std::cout << " huli test :::: " << " tp_passageway_task->get_task_statu = " << tp_passageway_task->get_task_statu() << std::endl;
- std::cout << " huli test :::: " << " tp_passageway_task->m_respons_status = " << tp_passageway_task->m_respons_status << std::endl;
- std::cout << " huli test :::: " << " m_respons_key = " << tp_passageway_task->m_respons_key << std::endl;
- std::cout << " huli test :::: " << " m_respons_status = " << tp_passageway_task->m_respons_status << std::endl;
- std::cout << " huli test :::: " << " m_respons_inside_door_motion = " << tp_passageway_task->m_respons_inside_door_motion << std::endl;
- std::cout << " huli test :::: " << " m_respons_outside_door_motion = " << tp_passageway_task->m_respons_outside_door_motion << std::endl;
- std::cout << " huli test :::: " << " m_respons_turntable_direction = " << tp_passageway_task->m_respons_turntable_direction << std::endl;
- std::cout << " ---------------------------------------------------" << std::endl;
- std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
- std::cout << " huli test :::: " << " t_passageway_base.get_passageway_status() = " << t_passageway.get_dispatch_device_status() << std::endl;
- int heat = t_passageway.m_last_heartbeat;
- std::cout << " huli test :::: " << " m_last_heartbeat = " << heat << std::endl;
- std::cout << " huli test :::: " << " m_actual_device_status = " << t_passageway.m_actual_device_status << std::endl;
- std::cout << " huli test :::: " << " m_actual_inside_load_status = " << t_passageway.m_actual_inside_load_status << std::endl;
- std::cout << " huli test :::: " << " m_actual_outside_load_status = " << t_passageway.m_actual_outside_load_status << std::endl;
- std::cout << " huli test :::: " << " m_actual_front_overstep_the_boundary = " << t_passageway.m_actual_front_overstep_the_boundary << std::endl;
- std::cout << " huli test :::: " << " m_actual_back_overstep_the_boundary = " << t_passageway.m_actual_back_overstep_the_boundary << std::endl;
- std::cout << " huli test :::: " << " m_actual_height_overstep_the_boundary = " << t_passageway.m_actual_height_overstep_the_boundary << std::endl;
- std::cout << " huli test :::: " << " m_actual_outside_door_sensor = " << t_passageway.m_actual_outside_door_sensor << std::endl;
- std::cout << " huli test :::: " << " m_actual_inside_door_motion = " << t_passageway.m_actual_inside_door_motion << std::endl;
- std::cout << " huli test :::: " << " m_actual_outside_door_motion = " << t_passageway.m_actual_outside_door_motion << std::endl;
- std::cout << " huli test :::: " << " m_actual_turntable_load_status = " << t_passageway.m_actual_turntable_load_status << std::endl;
- std::cout << " huli test :::: " << " m_actual_turntable_direction = " << t_passageway.m_actual_turntable_direction << std::endl;
- std::cout << " huli test :::: " << " m_actual_error_code = " << std::endl;
- for (int i = 0; i < 50; ++i)
- {
- printf("0x%x ", t_passageway.m_actual_error_code[i]);
- }
- std::cout << std::endl;
- std::cout << " huli test :::: " << " m_actual_warning_code = " << std::endl;
- for (int i = 0; i < 50; ++i)
- {
- printf("0x%x ", t_passageway.m_actual_warning_code[i]);
- }
- std::cout << std::endl;
- std::cout << " huli test :::: " << " m_actual_error_description = " << t_passageway.m_actual_error_description << std::endl;
- std::cout << " huli test :::: " << " *********************************************** = " << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- }
- */
- while (1)
- {
- }
- char ch123 ;
- std::cin >> ch123 ;
- Dispatch_communication::get_instance_references().communication_uninit();
- return 0;
- int t_dispatch_id = 0;
- // std::cin >> t_dispatch_id ;
- if ( argc == 2 )
- {
- std::cout << " huli test :::: " << " argv[1] = " << argv[1] << std::endl;
- t_dispatch_id = atoi(argv[1]);
- }
- std::cout << " huli test :::: " << " t_dispatch_id = " << t_dispatch_id << std::endl;
- Dispatch_manager::get_instance_references().dispatch_manager_init(t_dispatch_id);
- std::cout << "Dispatch_manager = " << Dispatch_manager::get_instance_references().get_dispatch_manager_status() << std::endl;
- System_executor::get_instance_references().system_executor_init(8);
- std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
- System_communication::get_instance_references().communication_init();
- char ch ;
- std::cin >> ch ;
- System_communication::get_instance_references().communication_uninit();
- System_executor::get_instance_references().system_executor_uninit();
- Dispatch_manager::get_instance_references().dispatch_manager_uninit();
- return 0;
- }
|