commif.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "modulecomm.h"
  2. #include "commif.h"
  3. #include <memory>
  4. #include <thread>
  5. static mcommCall gpgpscall;
  6. static int64_t gnLastFusionGPSUpdate = 0;
  7. void UpdateGPS(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
  8. {
  9. (void)index;
  10. (void)dt;
  11. (void)strmemname;
  12. int64_t nNow = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
  13. if(strncmp(strmemname,"fusion_gpsimu",256)!= 0)
  14. {
  15. if(abs(nNow - gnLastFusionGPSUpdate)<1000)
  16. {
  17. return;
  18. }
  19. }
  20. else
  21. {
  22. gnLastFusionGPSUpdate = nNow;
  23. }
  24. (*gpgpscall)(strdata,nSize);
  25. // std::shared_ptr<iv::gps::gpsimu> xgpsimu_ptr = std::shared_ptr<iv::gps::gpsimu>(new iv::gps::gpsimu);
  26. // if(!xgpsimu_ptr->ParseFromArray(strdata,nSize))
  27. // {
  28. // qDebug("MainWindow::UpdateGPS Parse Error. nSize is ",nSize);
  29. // return;
  30. // }
  31. // mMutex.lock();
  32. // mgpsimu_ptr = xgpsimu_ptr;
  33. // mbUpdate = true;
  34. // mMutex.unlock();
  35. }
  36. void * RegisterSend(char * strmemname,const unsigned int nmemsize,const unsigned int nbufpacket)
  37. {
  38. void * pa = iv::modulecomm::RegisterSend(strmemname,nmemsize,nbufpacket);
  39. return pa;
  40. }
  41. void SendMsg(void * pa,char * strdata,unsigned int nsize)
  42. {
  43. iv::modulecomm::ModuleSendMsg(pa,strdata,nsize);
  44. }
  45. void * RegisterRecvGPS(char * strmemname,mcommCall pcall)
  46. {
  47. gpgpscall = pcall;
  48. void * pa = iv::modulecomm::RegisterRecv(strmemname,UpdateGPS);
  49. return pa;
  50. }