grpcpc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef GRPCPC_H
  2. #define GRPCPC_H
  3. #include <QThread>
  4. #include <yaml-cpp/yaml.h>
  5. #include <QDateTime>
  6. #include <iostream>
  7. #include <vector>
  8. #include <memory>
  9. #include <QMutex>
  10. #include <thread>
  11. #include "modulecomm.h"
  12. #include "cloud.pb.h"
  13. #include <iostream>
  14. #include <memory>
  15. #include <string>
  16. #include <grpcpp/grpcpp.h>
  17. #include "uploadthreadmsg.grpc.pb.h"
  18. #ifndef NUM_CAM
  19. #define NUM_CAM 4
  20. #endif
  21. #ifndef NUM_THREAD_PERCAM
  22. #define NUM_THREAD_PERCAM 1
  23. //int NUM_THREAD_PERCAM = 1;
  24. #endif
  25. using grpc::Channel;
  26. using grpc::ClientContext;
  27. using grpc::Status;
  28. namespace iv {
  29. struct msgunit
  30. {
  31. char mstrmsgname[256];
  32. int mnBufferSize = 10000;
  33. int mnBufferCount = 1;
  34. void * mpa;
  35. std::shared_ptr<char> mpstrmsgdata;
  36. int mndatasize = 0;
  37. bool mbRefresh = false;
  38. bool mbImportant = false;
  39. int mnkeeptime = 100;
  40. };
  41. }
  42. class grpcpc : public QThread
  43. {
  44. public:
  45. grpcpc(std::string stryamlpath);
  46. private:
  47. void run();
  48. private:
  49. std::string gstrserverip = "192.168.14.98";//"111.33.136.149";//"127.0.0.1";// "140.143.237.38";
  50. std::string gstrserverport = "50051";//"9000";
  51. std::string gstruploadinterval = "100";
  52. void * gpa;
  53. QMutex gMutexMsg;
  54. std::vector<iv::msgunit> mvectormsgunit;
  55. std::vector<iv::msgunit> mvectorctrlmsgunit;
  56. std::string gstrVIN = "AAAAAAAAAAAAAAAAA";
  57. std::string gstrqueryMD5 = "5d41402abc4b2a76b9719d911017c592";
  58. std::string gstrctrlMD5 = "5d41402abc4b2a76b9719d911017c592";
  59. int gindex = 0;
  60. private:
  61. void dec_yaml(const char * stryamlpath);
  62. void sharequerymsg(iv::cloud::cloudmsg * pxmsg);
  63. public:
  64. void UpdateData(const char * strdata,const unsigned int nSize,const char * strmemname);
  65. std::string GetVIN();
  66. private:
  67. void threadpicdownload(int nCamPos);
  68. void * mpaPic[NUM_CAM];
  69. std::string mstrpicmsgname[NUM_CAM];
  70. std::thread * mpThread[NUM_CAM * NUM_THREAD_PERCAM];
  71. QMutex mMutexPic[NUM_CAM];
  72. qint64 mnPicUpLatency[NUM_CAM];
  73. int mnFrameRate[NUM_CAM];
  74. int mnPicDownLatency[NUM_CAM];
  75. public:
  76. qint64 GetPicLatency(int nCamPos);
  77. int GetFrameRate(int nCamPos);
  78. qint64 GetPicDownLatency(int nCamPos);
  79. public:
  80. void setserverip(std::string strip);
  81. void setserverport(std::string strport);
  82. void setqueryinterval(std::string strinterval);
  83. void setVIN(std::string strVIN);
  84. void setqueryMD5(std::string strmd5);
  85. void setctrlMD5(std::string strmd5);
  86. };
  87. #endif // GRPCPC_H