#include #include "ivversion.h" #include #include "vehicle_upload.h" #include "vehicle_control.h" #include "vehicle_patrol.h" #include "modulecomm.h" #include #include #include #include namespace iv { struct msgunit { char mstrmsgname[256]; int mnBufferSize = 10000; int mnBufferCount = 1; void * mpa; std::shared_ptr mpstrmsgdata; int mndatasize = 0; bool mbRefresh = false; bool mbImportant = false; int mnkeeptime = 100; }; } uint8_t gShift_Status = 3; //3 p 4 r 5 n 6 d uint8_t gCtrlMode_Status = 0; //0 auto 1 remote 2 stop 3 platform std::string gstrserverip = "111.33.136.150";//"123.57.212.138"; std::string gstruploadPort = "10591";//"9000"; std::string gstrpatrolPort = "10592";//"9000"; std::string gstrcontrolPort = "20591";//"9000"; std::string gstruploadInterval = "500"; std::string gstrpatrolInterval = "1000"; std::string gstrcontrolInterval = "100"; std::string gstruploadMapInterval = "1000"; std::string gstrid = "1234567890123456789H"; std::string gstrplateNumber = "津A123456"; iv::msgunit shmPicFront; iv::msgunit shmPicRear; iv::msgunit shmPicLeft; iv::msgunit shmPicRight; iv::msgunit shmRemoteCtrl; iv::msgunit shmChassis; iv::msgunit shmGPSIMU; iv::msgunit shmPlatformFeedback; void dec_yaml(const char * stryamlpath) { YAML::Node config; try { config = YAML::LoadFile(stryamlpath); } catch(YAML::BadFile &e) { std::cout<(); } if(config["uploadPort"]) { gstruploadPort = config["uploadPort"].as(); } if(config["patrolPort"]) { gstrpatrolPort = config["patrolPort"].as(); } if(config["controlPort"]) { gstrcontrolPort = config["controlPort"].as(); } if(config["uploadInterval"]) { gstruploadInterval = config["uploadInterval"].as(); } if(config["patrolInterval"]) { gstrpatrolInterval = config["patrolInterval"].as(); } if(config["controlinterval"]) { gstrcontrolInterval = config["controlinterval"].as(); } if(config["uploadmapinterval"]) { gstruploadMapInterval = config["uploadmapinterval"].as(); } if(config["id"]) { gstrid = config["id"].as(); } if(config["plateNumber"]) { gstrplateNumber = config["plateNumber"].as(); } std::string strmsgname; if(config["pic_front"]) { if(config["pic_front"]["msgname"]&&config["pic_front"]["buffersize"]&&config["pic_front"]["buffercount"]) { strmsgname = config["pic_front"]["msgname"].as(); strncpy(shmPicFront.mstrmsgname,strmsgname.data(),255); shmPicFront.mnBufferSize = config["pic_front"]["buffersize"].as(); shmPicFront.mnBufferCount = config["pic_front"]["buffercount"].as(); // std::cout << shmPicFront.mstrmsgname << shmPicFront.mnBufferSize << shmPicFront.mnBufferCount << std::endl; } } if(config["pic_rear"]) { if(config["pic_rear"]["msgname"]&&config["pic_rear"]["buffersize"]&&config["pic_rear"]["buffercount"]) { strmsgname = config["pic_rear"]["msgname"].as(); strncpy(shmPicRear.mstrmsgname,strmsgname.data(),255); shmPicRear.mnBufferSize = config["pic_rear"]["buffersize"].as(); shmPicRear.mnBufferCount = config["pic_rear"]["buffercount"].as(); // std::cout << shmPicRear.mstrmsgname << shmPicRear.mnBufferSize << shmPicRear.mnBufferCount << std::endl; } } if(config["pic_left"]) { if(config["pic_left"]["msgname"]&&config["pic_left"]["buffersize"]&&config["pic_left"]["buffercount"]) { strmsgname = config["pic_left"]["msgname"].as(); strncpy(shmPicLeft.mstrmsgname,strmsgname.data(),255); shmPicLeft.mnBufferSize = config["pic_left"]["buffersize"].as(); shmPicLeft.mnBufferCount = config["pic_left"]["buffercount"].as(); // std::cout << shmPicLeft.mstrmsgname << shmPicLeft.mnBufferSize << shmPicLeft.mnBufferCount << std::endl; } } if(config["pic_right"]) { if(config["pic_right"]["msgname"]&&config["pic_right"]["buffersize"]&&config["pic_right"]["buffercount"]) { strmsgname = config["pic_right"]["msgname"].as(); strncpy(shmPicRight.mstrmsgname,strmsgname.data(),255); shmPicRight.mnBufferSize = config["pic_right"]["buffersize"].as(); shmPicRight.mnBufferCount = config["pic_right"]["buffercount"].as(); // std::cout << shmPicRight.mstrmsgname << shmPicRight.mnBufferSize << shmPicRight.mnBufferCount << std::endl; } } if(config["remote_ctrl"]) { if(config["remote_ctrl"]["msgname"]&&config["remote_ctrl"]["buffersize"]&&config["remote_ctrl"]["buffercount"]) { strmsgname = config["remote_ctrl"]["msgname"].as(); strncpy(shmRemoteCtrl.mstrmsgname,strmsgname.data(),255); shmRemoteCtrl.mnBufferSize = config["remote_ctrl"]["buffersize"].as(); shmRemoteCtrl.mnBufferCount = config["remote_ctrl"]["buffercount"].as(); // std::cout << shmRemoteCtrl.mstrmsgname << shmRemoteCtrl.mnBufferSize << shmRemoteCtrl.mnBufferCount << std::endl; } } if(config["chassis"]) { if(config["chassis"]["msgname"]&&config["chassis"]["buffersize"]&&config["chassis"]["buffercount"]) { strmsgname = config["chassis"]["msgname"].as(); strncpy(shmChassis.mstrmsgname,strmsgname.data(),255); shmChassis.mnBufferSize = config["chassis"]["buffersize"].as(); shmChassis.mnBufferCount = config["chassis"]["buffercount"].as(); // std::cout << shmChassis.mstrmsgname << shmChassis.mnBufferSize << shmChassis.mnBufferCount << std::endl; } } if(config["platform_feedback"]) { if(config["platform_feedback"]["msgname"]&&config["platform_feedback"]["buffersize"]&&config["platform_feedback"]["buffercount"]) { strmsgname = config["platform_feedback"]["msgname"].as(); strncpy(shmPlatformFeedback.mstrmsgname,strmsgname.data(),255); shmPlatformFeedback.mnBufferSize = config["platform_feedback"]["buffersize"].as(); shmPlatformFeedback.mnBufferCount = config["platform_feedback"]["buffercount"].as(); // std::cout << shmPlatformFeedback.mstrmsgname << shmPlatformFeedback.mnBufferSize << shmPlatformFeedback.mnBufferCount << std::endl; } } if(config["GPS_IMU"]) { if(config["GPS_IMU"]["msgname"]&&config["GPS_IMU"]["buffersize"]&&config["GPS_IMU"]["buffercount"]) { strmsgname = config["GPS_IMU"]["msgname"].as(); strncpy(shmGPSIMU.mstrmsgname,strmsgname.data(),255); shmGPSIMU.mnBufferSize = config["GPS_IMU"]["buffersize"].as(); shmGPSIMU.mnBufferCount = config["GPS_IMU"]["buffercount"].as(); // std::cout << shmGPSIMU.mstrmsgname << shmGPSIMU.mnBufferSize << shmGPSIMU.mnBufferCount << std::endl; } } return; } int main(int argc, char *argv[]) { showversion("driver_cloud_grpc_client_BS"); QCoreApplication a(argc, argv); char stryamlpath[256]; if(argc<2) { snprintf(stryamlpath,255,"driver_cloud_grpc_client_BS.yaml"); } else { strncpy(stryamlpath,argv[1],255); } dec_yaml(stryamlpath); std::string control_str = gstrserverip+":"; control_str = control_str + gstrcontrolPort ; std::string patrol_str = gstrserverip+":"; patrol_str = patrol_str + gstrpatrolPort; std::string upload_str = gstrserverip+":"; upload_str = upload_str + gstruploadPort ; // std::cout<start(); // std::cout<("org::jeecg::defsControl::grpc::CtrlMode"); ///< to solve the problem of signal and slot being in different threads // QObject::connect(vehiclechangectrlmode,&VehicleChangeCtrlModeClient::ctrlMode_Changed,vehiclecontrol,&VehicleControlClient::ctrlMode_Changed_Slot); // vehiclechangectrlmode->start(); // vehiclecontrol->start(); // VehicleUploadMapClient *vehicleuploadmap = new VehicleUploadMapClient(grpc::CreateChannel(control_str, grpc::InsecureChannelCredentials())); // QObject::connect(vehicleuploadmap,&VehicleUploadMapClient::patrolPOI_Recieved,vehicleuploaddata,&DataExchangeClient::patrolPOI_Recieved_Slot); // QObject::connect(vehicleuploaddata,&DataExchangeClient::uploadPath_Finished,vehicleuploadmap,&VehicleUploadMapClient::uploadPath_Finished_Slot); // vehicleuploadmap->start(); // std::cout<