// // // 20210425, hl_dispatch 和 hl_dispatch_B的版本进行同步, 此时调度管理的功能全部完成.后续可能还需要日志记录. // #include #include "./error_code/error_code.h" //#include "LogFiles.h" #include #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 // 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 using namespace std; int main(int argc,char* argv[]) { int t_id = 2; if ( argc == 2 ) { t_id = stoi(argv[1]); } 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(t_id); 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; Dispatch_communication::Dispatch_request_from_manager_to_plc_for_data a; Dispatch_communication::Dispatch_request_from_manager_to_plc_for_key b; Dispatch_communication::Dispatch_response_from_plc_to_manager c; std::cout << " huli test :::: " << " sizeof(a) = " << sizeof(a) << std::endl; std::cout << " huli test :::: " << " sizeof(b) = " << sizeof(b) << std::endl; std::cout << " huli test :::: " << " sizeof(c) = " << sizeof(c) << std::endl; int aa = Dispatch_communication::get_instance_references().m_send_buf_map[0].m_size; int bb = Dispatch_communication::get_instance_references().m_send_buf_map[1].m_size; int cc = Dispatch_communication::get_instance_references().m_receive_buf_map[0].m_size; std::cout << " huli test :::: " << " aa = " << aa << std::endl; std::cout << " huli test :::: " << " bb = " << bb << std::endl; std::cout << " huli test :::: " << " cc = " << cc << std::endl; t_error = Dispatch_manager::get_instance_references().dispatch_manager_init(t_id); 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); //20210922 while (1) { std::string test_string; std::cin >> test_string ; if ( test_string == "9" ) { message::Dispatch_request_msg dispatch_request_msg; dispatch_request_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_request_msg); dispatch_request_msg.mutable_base_info()->set_timeout_ms(5000000); dispatch_request_msg.mutable_base_info()->set_sender(message::Communicator::eMain); dispatch_request_msg.mutable_base_info()->set_receiver(message::Communicator::eDispatch_manager); dispatch_request_msg.set_command_key("12345678901234567890123456789012"); dispatch_request_msg.set_dispatch_motion_direction(message::Dispatch_motion_direction::E_STORE_CAR); dispatch_request_msg.mutable_id_struct()->set_terminal_id(4); dispatch_request_msg.mutable_id_struct()->set_unit_id(2); message::Locate_information t_locate_information; t_locate_information.set_locate_x(-1.901); t_locate_information.set_locate_y(-5.829); t_locate_information.set_locate_angle(2); t_locate_information.set_locate_length(4.78); t_locate_information.set_locate_width(1.88); t_locate_information.set_locate_height(1.65); t_locate_information.set_locate_wheel_base(2.78); t_locate_information.set_locate_wheel_width(1.88); t_locate_information.set_locate_front_theta(0); t_locate_information.set_uniformed_car_x(0); t_locate_information.set_uniformed_car_y(0); t_locate_information.set_locate_correct(true); dispatch_request_msg.mutable_locate_information()->CopyFrom(t_locate_information); message::Parkspace_info *tp_parkspace_info = dispatch_request_msg.mutable_parkspace_info_ex()->Add(); tp_parkspace_info->set_parkingspace_index_id(167); tp_parkspace_info->set_parkingspace_type(message::Parkspace_type::MID_PARKINGSPACE); tp_parkspace_info->set_parkingspace_unit_id(3); tp_parkspace_info->set_parkingspace_label_id(11); tp_parkspace_info->set_parkingspace_room_id(5); tp_parkspace_info->set_parkingspace_direction(message::Direction::eBackward); tp_parkspace_info->set_parkingspace_floor_id(3); tp_parkspace_info->set_parkingspace_width(0); tp_parkspace_info->set_parkingspace_height(0); tp_parkspace_info->set_parkingspace_status(message::Parkspace_status::eParkspace_empty); tp_parkspace_info->set_car_type(message::Car_type::MID_CAR); dispatch_request_msg.set_car_type(message::Car_type::MID_CAR); Dispatch_manager::get_instance_references().execute_for_dispatch_request_msg(dispatch_request_msg); } std::this_thread::sleep_for(std::chrono::seconds(1)); } return 0; #endif 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; }