|
@@ -17,32 +17,11 @@ extern std::string gstruploadInterval;
|
|
extern std::string gstrid;
|
|
extern std::string gstrid;
|
|
extern std::string gstrplateNumber;
|
|
extern std::string gstrplateNumber;
|
|
|
|
|
|
|
|
+extern char stryamlpath[256];
|
|
|
|
+
|
|
extern uint8_t gShift_Status;//3 p 4 r 5 n 6 d
|
|
extern uint8_t gShift_Status;//3 p 4 r 5 n 6 d
|
|
extern uint8_t gCtrlMode_Status; //0 auto 1 remote 2 stop 3 platform
|
|
extern uint8_t gCtrlMode_Status; //0 auto 1 remote 2 stop 3 platform
|
|
|
|
|
|
-namespace iv {
|
|
|
|
-struct msgunit
|
|
|
|
-{
|
|
|
|
- char mstrmsgname[256];
|
|
|
|
- int mnBufferSize = 10000;
|
|
|
|
- int mnBufferCount = 1;
|
|
|
|
- void * mpa;
|
|
|
|
- std::shared_ptr<char> mpstrmsgdata;
|
|
|
|
- int mndatasize = 0;
|
|
|
|
- bool mbRefresh = false;
|
|
|
|
- bool mbImportant = false;
|
|
|
|
- int mnkeeptime = 100;
|
|
|
|
-};
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-extern iv::msgunit shmPicFront;
|
|
|
|
-extern iv::msgunit shmPicRear;
|
|
|
|
-extern iv::msgunit shmPicLeft;
|
|
|
|
-extern iv::msgunit shmPicRight;
|
|
|
|
-extern iv::msgunit shmChassis;
|
|
|
|
-extern iv::msgunit shmGPSIMU;
|
|
|
|
-extern iv::msgunit shmPlatformFeedback;
|
|
|
|
-
|
|
|
|
using org::jeecg::defsDetails::grpc::Empty; ///< other message
|
|
using org::jeecg::defsDetails::grpc::Empty; ///< other message
|
|
using org::jeecg::defsDetails::grpc::GPSPoint;
|
|
using org::jeecg::defsDetails::grpc::GPSPoint;
|
|
using org::jeecg::defsDetails::grpc::MapPoint;
|
|
using org::jeecg::defsDetails::grpc::MapPoint;
|
|
@@ -93,6 +72,7 @@ DataExchangeClient::DataExchangeClient(std::shared_ptr<Channel> channel)
|
|
|
|
|
|
stub_ = DataExchange::NewStub(channel);
|
|
stub_ = DataExchange::NewStub(channel);
|
|
|
|
|
|
|
|
+ dec_yaml(stryamlpath);
|
|
shmPicFront.mpa = iv::modulecomm::RegisterRecv(shmPicFront.mstrmsgname,ListenFrontData);
|
|
shmPicFront.mpa = iv::modulecomm::RegisterRecv(shmPicFront.mstrmsgname,ListenFrontData);
|
|
shmPicRear.mpa = iv::modulecomm::RegisterRecv(shmPicRear.mstrmsgname,ListenRearData);
|
|
shmPicRear.mpa = iv::modulecomm::RegisterRecv(shmPicRear.mstrmsgname,ListenRearData);
|
|
shmPicLeft.mpa = iv::modulecomm::RegisterRecv(shmPicLeft.mstrmsgname,ListenLeftData);
|
|
shmPicLeft.mpa = iv::modulecomm::RegisterRecv(shmPicLeft.mstrmsgname,ListenLeftData);
|
|
@@ -107,6 +87,164 @@ DataExchangeClient::~DataExchangeClient(void)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void DataExchangeClient::dec_yaml(const char *stryamlpath)
|
|
|
|
+{
|
|
|
|
+ YAML::Node config;
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ config = YAML::LoadFile(stryamlpath);
|
|
|
|
+ }
|
|
|
|
+ catch(YAML::BadFile &e)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<e.what()<<std::endl;
|
|
|
|
+ qDebug("yaml file load fail.");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ catch(YAML::ParserException &e)
|
|
|
|
+ {
|
|
|
|
+ std::cout<<e.what()<<std::endl;
|
|
|
|
+ qDebug("yaml file is malformed.");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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<std::string>();
|
|
|
|
+ strncpy(shmPicFront.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicFront.mnBufferSize = config["pic_front"]["buffersize"].as<int>();
|
|
|
|
+ shmPicFront.mnBufferCount = config["pic_front"]["buffercount"].as<int>();
|
|
|
|
+// std::cout << shmPicFront.mstrmsgname << shmPicFront.mnBufferSize << shmPicFront.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picfront";
|
|
|
|
+ strncpy(shmPicFront.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicFront.mnBufferSize = 10000000;
|
|
|
|
+ shmPicFront.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["pic_rear"])
|
|
|
|
+ {
|
|
|
|
+ if(config["pic_rear"]["msgname"]&&config["pic_rear"]["buffersize"]&&config["pic_rear"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["pic_rear"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPicRear.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRear.mnBufferSize = config["pic_rear"]["buffersize"].as<int>();
|
|
|
|
+ shmPicRear.mnBufferCount = config["pic_rear"]["buffercount"].as<int>();
|
|
|
|
+// std::cout << shmPicRear.mstrmsgname << shmPicRear.mnBufferSize << shmPicRear.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picrear";
|
|
|
|
+ strncpy(shmPicRear.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRear.mnBufferSize = 10000000;
|
|
|
|
+ shmPicRear.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["pic_left"])
|
|
|
|
+ {
|
|
|
|
+ if(config["pic_left"]["msgname"]&&config["pic_left"]["buffersize"]&&config["pic_left"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["pic_left"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPicLeft.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicLeft.mnBufferSize = config["pic_left"]["buffersize"].as<int>();
|
|
|
|
+ shmPicLeft.mnBufferCount = config["pic_left"]["buffercount"].as<int>();
|
|
|
|
+// std::cout << shmPicLeft.mstrmsgname << shmPicLeft.mnBufferSize << shmPicLeft.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picleft";
|
|
|
|
+ strncpy(shmPicLeft.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicLeft.mnBufferSize = 10000000;
|
|
|
|
+ shmPicLeft.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["pic_right"])
|
|
|
|
+ {
|
|
|
|
+ if(config["pic_right"]["msgname"]&&config["pic_right"]["buffersize"]&&config["pic_right"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["pic_right"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPicRight.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRight.mnBufferSize = config["pic_right"]["buffersize"].as<int>();
|
|
|
|
+ shmPicRight.mnBufferCount = config["pic_right"]["buffercount"].as<int>();
|
|
|
|
+// std::cout << shmPicRight.mstrmsgname << shmPicRight.mnBufferSize << shmPicRight.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "picright";
|
|
|
|
+ strncpy(shmPicRight.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPicRight.mnBufferSize = 10000000;
|
|
|
|
+ shmPicRight.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["chassis"])
|
|
|
|
+ {
|
|
|
|
+ if(config["chassis"]["msgname"]&&config["chassis"]["buffersize"]&&config["chassis"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["chassis"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmChassis.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmChassis.mnBufferSize = config["chassis"]["buffersize"].as<int>();
|
|
|
|
+ shmChassis.mnBufferCount = config["chassis"]["buffercount"].as<int>();
|
|
|
|
+// std::cout << shmChassis.mstrmsgname << shmChassis.mnBufferSize << shmChassis.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "chassis";
|
|
|
|
+ strncpy(shmChassis.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmChassis.mnBufferSize = 10000;
|
|
|
|
+ shmChassis.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["platform_feedback"])
|
|
|
|
+ {
|
|
|
|
+ if(config["platform_feedback"]["msgname"]&&config["platform_feedback"]["buffersize"]&&config["platform_feedback"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["platform_feedback"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmPlatformFeedback.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPlatformFeedback.mnBufferSize = config["platform_feedback"]["buffersize"].as<int>();
|
|
|
|
+ shmPlatformFeedback.mnBufferCount = config["platform_feedback"]["buffercount"].as<int>();
|
|
|
|
+// std::cout << shmPlatformFeedback.mstrmsgname << shmPlatformFeedback.mnBufferSize << shmPlatformFeedback.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "platformFeedback";
|
|
|
|
+ strncpy(shmPlatformFeedback.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmPlatformFeedback.mnBufferSize = 10000;
|
|
|
|
+ shmPlatformFeedback.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(config["GPS_IMU"])
|
|
|
|
+ {
|
|
|
|
+ if(config["GPS_IMU"]["msgname"]&&config["GPS_IMU"]["buffersize"]&&config["GPS_IMU"]["buffercount"])
|
|
|
|
+ {
|
|
|
|
+ strmsgname = config["GPS_IMU"]["msgname"].as<std::string>();
|
|
|
|
+ strncpy(shmGPSIMU.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmGPSIMU.mnBufferSize = config["GPS_IMU"]["buffersize"].as<int>();
|
|
|
|
+ shmGPSIMU.mnBufferCount = config["GPS_IMU"]["buffercount"].as<int>();
|
|
|
|
+// std::cout << shmGPSIMU.mstrmsgname << shmGPSIMU.mnBufferSize << shmGPSIMU.mnBufferCount << std::endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ strmsgname = "hcp2_gpsimu";
|
|
|
|
+ strncpy(shmGPSIMU.mstrmsgname,strmsgname.data(),255);
|
|
|
|
+ shmGPSIMU.mnBufferSize = 10000;
|
|
|
|
+ shmGPSIMU.mnBufferCount = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
void DataExchangeClient::ListenFrontPicMsg(const char * strdata,const unsigned int nSize) // need a lock
|
|
void DataExchangeClient::ListenFrontPicMsg(const char * strdata,const unsigned int nSize) // need a lock
|
|
{
|
|
{
|
|
iv::vision::rawpic xdata;
|
|
iv::vision::rawpic xdata;
|