ivdecision.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. #include "ivdecision.h"
  2. #include "gnss_coordinate_convert.h"
  3. #include "decition_type.h"
  4. #include "decition.pb.h"
  5. namespace iv {
  6. ivdecision::ivdecision()
  7. {
  8. }
  9. void ivdecision::modulerun()
  10. {
  11. ModuleFun fungps = std::bind(&iv::ivdecision::UpdateGPS,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  12. mpagpsmsg = iv::modulecomm::RegisterRecvPlus(mstrgpsmsgname.data(),fungps);
  13. ModuleFun funlidar = std::bind(&iv::ivdecision::UpdateLIDAR,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  14. mpalidarmsg = iv::modulecomm::RegisterRecvPlus(mstrlidarmsgname.data(),funlidar);
  15. ModuleFun funradar = std::bind(&iv::ivdecision::UpdateRADAR,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  16. mparadarmsg = iv::modulecomm::RegisterRecvPlus(mstrradarmsgname.data(),funradar);
  17. ModuleFun funmap = std::bind(&iv::ivdecision::UpdateMAP,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  18. mpamapmsg = iv::modulecomm::RegisterRecvPlus(mstrmapmsgname.data(),funmap);
  19. ModuleFun funmobileye = std::bind(&iv::ivdecision::UpdateMobileye,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  20. mpamobileyemsg = iv::modulecomm::RegisterRecvPlus(mstrmobileyemsgname.data(),funmobileye);
  21. ModuleFun funhmi = std::bind(&iv::ivdecision::UpdateHMI,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  22. mpahmimsg = iv::modulecomm::RegisterRecvPlus(mstrhmimsgname.data(),funhmi);
  23. mpapadmsg = iv::modulecomm::RegisterRecvPlus(mstrpadmsgname.data(),funhmi);
  24. ModuleFun funp900 = std::bind(&iv::ivdecision::Updatep900,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  25. mpap900msg = iv::modulecomm::RegisterRecvPlus(mstrp900msgname.data(),funp900);
  26. ModuleFun funv2x = std::bind(&iv::ivdecision::Updatev2x,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  27. mpav2xmsg = iv::modulecomm::RegisterRecvPlus(mstrv2xmsgname.data(),funv2x);
  28. ModuleFun funultra = std::bind(&iv::ivdecision::Updateultrasonic,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  29. mpaultramsg = iv::modulecomm::RegisterRecvPlus(mstrultramsgname.data(),funultra);
  30. ModuleFun funvbox = std::bind(&iv::ivdecision::UpdateVbox,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  31. mpavboxmsg = iv::modulecomm::RegisterRecvPlus(mstrvboxmsgname.data(),funvbox);
  32. ModuleFun funchassis = std::bind(&iv::ivdecision::UpdatepChassis,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
  33. mpachassismsg = iv::modulecomm::RegisterRecvPlus(mstrchassismsgname.data(),funchassis);
  34. mpaDecition = iv::modulecomm::RegisterSend(mstrdecisionmsgname.data(),10*sizeof(iv::decition::DecitionBasic),1);
  35. mpaVechicleState = iv::modulecomm::RegisterSend(mstrbrainstatemsgname.data(),10000,10);
  36. iv::brain::brainstate xbs;
  37. iv::brain::decition xdecition;
  38. qint64 nSpace = 10;
  39. qint64 nLastDecTime = 0;
  40. while(mbrun)
  41. {
  42. if((QDateTime::currentMSecsSinceEpoch() - nLastDecTime)<nSpace)
  43. {
  44. std::this_thread::sleep_for(std::chrono::milliseconds(1));
  45. continue;
  46. }
  47. nLastDecTime = QDateTime::currentMSecsSinceEpoch();
  48. std::cout<<"running."<<std::endl;
  49. int nrtn = getdecision(xdecition,xbs);
  50. if(nrtn == 1)
  51. {
  52. sharemsg(xdecition,xbs);
  53. }
  54. //RunDecision
  55. //ShareMsg
  56. }
  57. iv::modulecomm::Unregister(mpapadmsg);
  58. iv::modulecomm::Unregister(mpahmimsg);
  59. iv::modulecomm::Unregister(mpamobileyemsg);
  60. iv::modulecomm::Unregister(mpamapmsg);
  61. iv::modulecomm::Unregister(mparadarmsg);
  62. iv::modulecomm::Unregister(mpalidarmsg);
  63. iv::modulecomm::Unregister(mpagpsmsg);
  64. }
  65. void ivdecision::sharemsg(brain::decition &xdecition, brain::brainstate &xbs)
  66. {
  67. int nsize = xdecition.ByteSize();
  68. char * str = new char[nsize];
  69. std::shared_ptr<char> pstr;
  70. pstr.reset(str);
  71. if(xdecition.SerializeToArray(str,nsize))
  72. {
  73. // if(ServiceCarStatus.mbRunPause == false)
  74. // {
  75. iv::modulecomm::ModuleSendMsg(mpaDecition,str,nsize);
  76. // }
  77. }
  78. else
  79. {
  80. std::cout<<"iv::decition::BrainDecition::ShareDecition serialize error."<<std::endl;
  81. }
  82. nsize = xbs.ByteSize();
  83. str = new char[nsize];
  84. // std::shared_ptr<char> pstr;
  85. pstr.reset(str);
  86. if(xbs.SerializeToArray(str,nsize))
  87. {
  88. iv::modulecomm::ModuleSendMsg(mpaVechicleState,str,nsize);
  89. }
  90. else
  91. {
  92. std::cout<<"iv::decition::BrainDecition::ShareBrainstate serialize error."<<std::endl;
  93. }
  94. }
  95. void ivdecision::UpdateGPS(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  96. {
  97. (void )&index;
  98. (void )&dt;
  99. (void )strmemname;
  100. if(nSize<1)return;
  101. iv::gps::gpsimu xgpsimu;
  102. if(!xgpsimu.ParseFromArray(strdata,nSize))
  103. {
  104. std::cout<<"ivdecision::UpdateGPSMsg error."<<std::endl;
  105. return;
  106. }
  107. iv::GPSData data(new iv::GPS_INS);
  108. data->ins_status = xgpsimu.ins_state();
  109. data->rtk_status = xgpsimu.rtk_state();
  110. data->accel_x = xgpsimu.acce_x();
  111. data->accel_y = xgpsimu.acce_y();
  112. data->accel_z = xgpsimu.acce_z();
  113. data->ang_rate_x = xgpsimu.gyro_x();
  114. data->ang_rate_y = xgpsimu.gyro_y();
  115. data->ang_rate_z = xgpsimu.gyro_z();
  116. data->gps_lat = xgpsimu.lat();
  117. data->gps_lng = xgpsimu.lon();
  118. data->gps_z = xgpsimu.height();
  119. data->ins_heading_angle = xgpsimu.heading();
  120. data->ins_pitch_angle = xgpsimu.pitch();
  121. data->ins_roll_angle = xgpsimu.roll();
  122. data->speed = sqrt(pow(xgpsimu.ve(),2)+pow(xgpsimu.vn(),2)) * 3.6;
  123. GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
  124. mMutexGPS.lock();
  125. iv::gps::gpsimu * pgpsimu = new iv::gps::gpsimu;
  126. pgpsimu->CopyFrom(xgpsimu);
  127. mGPSIMUptr.reset(pgpsimu);
  128. mNowGPS = data;
  129. mnGPSUpdateTime = QDateTime::currentMSecsSinceEpoch();
  130. mMutexGPS.unlock();
  131. }
  132. bool ivdecision::GetGPS(GPSData &xGPSData)
  133. {
  134. if((QDateTime::currentMSecsSinceEpoch() - mnGPSUpdateTime)>mnNewThresh)
  135. {
  136. xGPSData = NULL;
  137. return false;
  138. }
  139. xGPSData = mNowGPS;
  140. return true;
  141. }
  142. void ivdecision::UpdateRADAR(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  143. {
  144. (void )&index;
  145. (void )&dt;
  146. (void )strmemname;
  147. if(nSize<1)return;
  148. iv::radar::radarobjectarray * pradar = new iv::radar::radarobjectarray;
  149. if(!pradar->ParseFromArray(strdata,nSize))
  150. {
  151. std::cout<<"ivdecision::UpdateRADARMsg Parse Error"<<std::endl;
  152. return;
  153. }
  154. mMutexRADAR.lock();
  155. mRADAR.reset(pradar);
  156. mnRADARUpdateTime = QDateTime::currentMSecsSinceEpoch();
  157. mMutexRADAR.unlock();
  158. }
  159. bool ivdecision::GetRADAR(std::shared_ptr<radar::radarobjectarray> &xRADAR)
  160. {
  161. if((QDateTime::currentMSecsSinceEpoch() - mnRADARUpdateTime)>mnNewThresh)
  162. {
  163. xRADAR = NULL;
  164. return false;
  165. }
  166. xRADAR = mRADAR;
  167. return true;
  168. }
  169. void ivdecision::UpdateLIDAR(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  170. {
  171. (void )&index;
  172. (void )&dt;
  173. (void )strmemname;
  174. if(nSize<1)return;
  175. unsigned int nCount = nSize/sizeof(iv::ObstacleBasic);
  176. std::shared_ptr<std::vector<iv::ObstacleBasic>> lidar_obs = std::shared_ptr<std::vector<iv::ObstacleBasic>>(new std::vector<iv::ObstacleBasic>);
  177. lidar_obs->resize(nCount);
  178. memcpy(lidar_obs->data(),strdata,nCount*sizeof(iv::ObstacleBasic));
  179. mMutexLIDAR.lock();
  180. mlidar_obs = lidar_obs;
  181. mnLIDARUpdateTime = QDateTime::currentMSecsSinceEpoch();
  182. mMutexLIDAR.unlock();
  183. }
  184. bool ivdecision::GetLIDARGrid(LidarGridPtr &lidargridptr)
  185. {
  186. if((QDateTime::currentMSecsSinceEpoch() - mnLIDARUpdateTime)>mnNewThresh)
  187. {
  188. lidargridptr = NULL;
  189. return false;
  190. }
  191. LidarGridPtr ptr = (Obs_grid *)malloc(sizeof(Obs_grid[iv::grx][iv::gry]));
  192. memset(ptr, 0, sizeof(Obs_grid[iv::grx][iv::gry]));
  193. for (int i = 0; i <iv::grx; i++)//复制到指针数组
  194. {
  195. for (int j = 0; j <iv::gry; j++)
  196. {
  197. // ptr[i * (iv::gry) + j].high = obs_grid[i][j].high;
  198. // ptr[i * (iv::gry) + j].low = obs_grid[i][j].low;
  199. ptr[i * (iv::gry) + j].ob = 0;
  200. // ptr[i * (iv::gry) + j].obshight = obs_grid[i][j].obshight;
  201. // ptr[i * (iv::gry) + j].pointcount = obs_grid[i][j].pointcount;
  202. }
  203. }
  204. mMutexLIDAR.lock();
  205. for(unsigned int i=0;i<mlidar_obs->size();i++)
  206. {
  207. iv::ObstacleBasic xobs = mlidar_obs->at(i);
  208. int dx,dy;
  209. dx = (xobs.nomal_x + gridwide * (double)centerx)/gridwide;
  210. dy = (xobs.nomal_y + gridwide * (double)centery)/gridwide;
  211. if((dx>=0)&&(dx<iv::grx)&&(dy>=0)&&(dy<iv::gry))
  212. {
  213. ptr[dx*(iv::gry) +dy].high = xobs.high;
  214. ptr[dx*(iv::gry) +dy].low = xobs.low;
  215. ptr[dx*(iv::gry) + dy].ob = 2;
  216. ptr[dx*(iv::gry) + dy].obshight = xobs.nomal_z;
  217. ptr[dx*(iv::gry) + dy].pointcount = 5;
  218. }
  219. }
  220. lidargridptr = ptr;
  221. mMutexLIDAR.unlock();
  222. return true;
  223. }
  224. bool ivdecision::GetLIDARObs(std::shared_ptr<std::vector<ObstacleBasic> > &xlidar_obs)
  225. {
  226. if((QDateTime::currentMSecsSinceEpoch() - mnLIDARUpdateTime)>mnNewThresh)
  227. {
  228. xlidar_obs = NULL;
  229. return false;
  230. }
  231. mMutexLIDAR.lock();
  232. xlidar_obs = mlidar_obs;
  233. mMutexLIDAR.unlock();
  234. return true;
  235. }
  236. void ivdecision::UpdateMAP(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  237. {
  238. (void )&index;
  239. (void )&dt;
  240. (void )strmemname;
  241. if(nSize<1)return;
  242. // std::cout<<"update map "<<std::endl;
  243. int gpsunitsize = sizeof(iv::GPS_INS);
  244. int nMapSize = nSize/gpsunitsize;
  245. // std::cout<<"map size is "<<nMapSize<<std::endl;
  246. if(nMapSize < 1)return;
  247. bool bUpdate = true;
  248. // if(nMapSize != mnavigation_data.size())
  249. // {
  250. // bUpdate = true;
  251. // }
  252. // else
  253. // {
  254. // iv::GPS_INS * p = (iv::GPS_INS *)mapdata;
  255. // if((p->gps_lat == navigation_data.at(0)->gps_lat)&&(p->ins_heading_angle == navigation_data.at(0)->ins_heading_angle))
  256. // {
  257. // // qDebug("same map");
  258. // bUpdate = false;
  259. // }
  260. // else
  261. // {
  262. // bUpdate = true;
  263. // }
  264. // }
  265. if(bUpdate)
  266. {
  267. mMutexMAP.lock();
  268. mnavigation_data.clear();
  269. mnavigation_data.resize(nMapSize);
  270. memcpy(mnavigation_data.data(),strdata,nMapSize * sizeof(iv::GPS_INS));
  271. mnMAPUpdateTime = QDateTime::currentMSecsSinceEpoch();
  272. mMutexMAP.unlock();
  273. }
  274. else
  275. {
  276. }
  277. }
  278. bool ivdecision::IsMAPUpdate(qint64 &nLastUpdateTime)
  279. {
  280. if(mnavigation_data.size()<1)
  281. {
  282. return false;
  283. }
  284. if(nLastUpdateTime != mnMAPUpdateTime)
  285. {
  286. return true;
  287. }
  288. return false;
  289. }
  290. bool ivdecision::GetMAP(std::vector<GPSData> &navigation_data, qint64 &nLastUpdateTime)
  291. {
  292. if(mnavigation_data.size()<1)
  293. {
  294. return false;
  295. }
  296. mMutexMAP.unlock();
  297. nLastUpdateTime = mnMAPUpdateTime;
  298. navigation_data = mnavigation_data;
  299. mMutexMAP.unlock();
  300. return true;
  301. }
  302. void ivdecision::UpdateMobileye(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  303. {
  304. (void )&index;
  305. (void )&dt;
  306. (void )strmemname;
  307. if(nSize<1)return;
  308. std::shared_ptr<iv::mobileye::mobileye> xmobileye = std::shared_ptr<iv::mobileye::mobileye>(new iv::mobileye::mobileye);
  309. if(!xmobileye->ParseFromArray(strdata,nSize))
  310. {
  311. std::cout<<"ivdecision::UpdateMobileye Parse Error."<<std::endl;
  312. return;
  313. }
  314. mMutexmobileye.lock();
  315. mmobileye = xmobileye;
  316. mnmobileyeUpdateTime = QDateTime::currentMSecsSinceEpoch();
  317. mMutexmobileye.unlock();
  318. }
  319. bool ivdecision::GetMobileye(std::shared_ptr<mobileye::mobileye> &xmobileye)
  320. {
  321. if((QDateTime::currentMSecsSinceEpoch() - mnmobileyeUpdateTime)>mnNewThresh)
  322. {
  323. xmobileye = NULL;
  324. return false;
  325. }
  326. mMutexmobileye.lock();
  327. xmobileye = mmobileye;
  328. mMutexmobileye.unlock();
  329. return true;
  330. }
  331. void ivdecision::UpdateHMI(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  332. {
  333. (void )&index;
  334. (void )&dt;
  335. (void )strmemname;
  336. if(nSize<1)return;
  337. std::shared_ptr<iv::hmi::hmimsg> xhmiptr = std::shared_ptr<iv::hmi::hmimsg>(new iv::hmi::hmimsg);
  338. if(!xhmiptr->ParseFromArray(strdata,nSize))
  339. {
  340. std::cout<<"ivdecision::UpdateHMI Parse Error."<<std::endl;
  341. return;
  342. }
  343. mMutexHMI.lock();
  344. mHMImsg = xhmiptr;
  345. mnHMIUpdateTime = QDateTime::currentMSecsSinceEpoch();
  346. mMutexHMI.unlock();
  347. }
  348. bool ivdecision::GetHMImsg(std::shared_ptr<hmi::hmimsg> &xhmimsg)
  349. {
  350. if((QDateTime::currentMSecsSinceEpoch() - mnHMIUpdateTime)>mnNewThresh)
  351. {
  352. xhmimsg = NULL;
  353. return false;
  354. }
  355. mMutexHMI.lock();
  356. xhmimsg = mHMImsg;
  357. mMutexHMI.unlock();
  358. return true;
  359. }
  360. void ivdecision::UpdateVbox(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  361. {
  362. (void )&index;
  363. (void )&dt;
  364. (void )strmemname;
  365. std::shared_ptr<iv::vbox::vbox> vbox_ptr = std::shared_ptr<iv::vbox::vbox>(new iv::vbox::vbox);
  366. if(!vbox_ptr->ParseFromArray(strdata,nSize))
  367. {
  368. std::cout<<"vdecision::UpdateVbox Parse Error"<<std::endl;
  369. return;
  370. }
  371. mMutexvbox.lock();
  372. mvboxmsg = vbox_ptr;
  373. mnvboxUpdateTime = QDateTime::currentMSecsSinceEpoch();
  374. mMutexvbox.unlock();
  375. }
  376. bool ivdecision::Getvboxmsg(std::shared_ptr<vbox::vbox> &xvboxmsg)
  377. {
  378. if((QDateTime::currentMSecsSinceEpoch() - mnvboxUpdateTime)>mnNewThresh)
  379. {
  380. xvboxmsg = NULL;
  381. return false;
  382. }
  383. mMutexvbox.lock();
  384. xvboxmsg = mvboxmsg;
  385. mMutexvbox.unlock();
  386. return true;
  387. }
  388. void ivdecision::Updatev2x(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  389. {
  390. (void )&index;
  391. (void )&dt;
  392. (void )strmemname;
  393. std::shared_ptr<iv::v2x::v2x> xv2x_ptr = std::shared_ptr<iv::v2x::v2x>(new iv::v2x::v2x);
  394. if(!xv2x_ptr->ParseFromArray(strdata,nSize))
  395. {
  396. std::cout<<"ivdecision::Updatev2x Parse Error."<<std::endl;
  397. return;
  398. }
  399. mMutexv2x.lock();
  400. mv2xmsg = xv2x_ptr;
  401. mnv2xUpdateTime = QDateTime::currentMSecsSinceEpoch();
  402. mMutexv2x.unlock();
  403. }
  404. bool ivdecision::Getv2xmsg(std::shared_ptr<v2x::v2x> &xv2xmsg)
  405. {
  406. if((QDateTime::currentMSecsSinceEpoch() - mnv2xUpdateTime)>mnNewThresh)
  407. {
  408. xv2xmsg = NULL;
  409. return false;
  410. }
  411. mMutexv2x.lock();
  412. xv2xmsg = mv2xmsg;
  413. mMutexv2x.unlock();
  414. return true;
  415. }
  416. void ivdecision::Updateultrasonic(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  417. {
  418. (void )&index;
  419. (void )&dt;
  420. (void )strmemname;
  421. std::shared_ptr<iv::ultrasonic::ultrasonic> xultrasonic_ptr
  422. = std::shared_ptr<iv::ultrasonic::ultrasonic>(new iv::ultrasonic::ultrasonic);
  423. if(!xultrasonic_ptr->ParseFromArray(strdata,nSize))
  424. {
  425. std::cout<<"ivdecision::Updateultrasonic Parse Error."<<std::endl;
  426. return;
  427. }
  428. mMutexultrasonic.lock();
  429. multrasonicmsg = xultrasonic_ptr;
  430. mnultrasonicUpdateTime = QDateTime::currentMSecsSinceEpoch();
  431. mMutexultrasonic.unlock();
  432. }
  433. bool ivdecision::Getultrasonic(std::shared_ptr<ultrasonic::ultrasonic> &xultramsg)
  434. {
  435. if((QDateTime::currentMSecsSinceEpoch() - mnultrasonicUpdateTime)>mnNewThresh)
  436. {
  437. xultramsg = NULL;
  438. return false;
  439. }
  440. mMutexultrasonic.lock();
  441. xultramsg = multrasonicmsg;
  442. mMutexultrasonic.unlock();
  443. return true;
  444. }
  445. void ivdecision::Updatep900(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  446. {
  447. (void )&index;
  448. (void )&dt;
  449. (void )strmemname;
  450. std::shared_ptr<iv::radio::radio_send> xp900_ptr
  451. = std::shared_ptr<iv::radio::radio_send>(new iv::radio::radio_send);
  452. if(!xp900_ptr->ParseFromArray(strdata,nSize))
  453. {
  454. std::cout<<"ivdecision::Updatep900 Parse Error."<<std::endl;
  455. return;
  456. }
  457. mMutexp900.lock();
  458. mp900msg = xp900_ptr;
  459. mnp900UpdateTime = QDateTime::currentMSecsSinceEpoch();
  460. mMutexp900.unlock();
  461. }
  462. bool ivdecision::Getp900(std::shared_ptr<iv::radio::radio_send> & xp900msg)
  463. {
  464. if((QDateTime::currentMSecsSinceEpoch() - mnp900UpdateTime)>mnNewThresh)
  465. {
  466. xp900msg = NULL;
  467. return false;
  468. }
  469. mMutexp900.lock();
  470. xp900msg = mp900msg;
  471. mMutexp900.unlock();
  472. return true;
  473. }
  474. void ivdecision::UpdatepChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  475. {
  476. (void )&index;
  477. (void )&dt;
  478. (void )strmemname;
  479. std::shared_ptr<iv::chassis> xchassis_ptr
  480. = std::shared_ptr<iv::chassis>(new iv::chassis);
  481. if(!xchassis_ptr->ParseFromArray(strdata,nSize))
  482. {
  483. std::cout<<"ivdecision::UpdatepChassis Parse Error."<<std::endl;
  484. return;
  485. }
  486. mMutexchassis.lock();
  487. mchassismsg = xchassis_ptr;
  488. mnchassisUpdateTime = QDateTime::currentMSecsSinceEpoch();
  489. mMutexchassis.unlock();
  490. }
  491. bool ivdecision::Getchassis(std::shared_ptr<iv::chassis> & xchassismsg)
  492. {
  493. if((QDateTime::currentMSecsSinceEpoch() - mnchassisUpdateTime)>mnNewThresh)
  494. {
  495. xchassismsg = NULL;
  496. return false;
  497. }
  498. mMutexchassis.lock();
  499. xchassismsg = mchassismsg;
  500. mMutexchassis.unlock();
  501. return true;
  502. }
  503. }