grpcpc.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. using grpc::Channel;
  19. using grpc::ClientContext;
  20. using grpc::Status;
  21. namespace iv {
  22. struct msgunit
  23. {
  24. char mstrmsgname[256];
  25. int mnBufferSize = 10000;
  26. int mnBufferCount = 1;
  27. void * mpa;
  28. std::shared_ptr<char> mpstrmsgdata;
  29. int mndatasize = 0;
  30. bool mbRefresh = false;
  31. bool mbImportant = false;
  32. int mnkeeptime = 100;
  33. };
  34. }
  35. class grpcpc : public QThread
  36. {
  37. public:
  38. grpcpc(std::string stryamlpath);
  39. private:
  40. void run();
  41. private:
  42. std::string gstrserverip = "140.143.237.38";
  43. std::string gstrserverport = "9000";
  44. std::string gstruploadinterval = "100";
  45. void * gpa;
  46. QMutex gMutexMsg;
  47. std::vector<iv::msgunit> mvectormsgunit;
  48. std::vector<iv::msgunit> mvectorctrlmsgunit;
  49. std::string gstrVIN = "AAAAAAAAAAAAAAAAA";
  50. std::string gstrqueryMD5 = "5d41402abc4b2a76b9719d911017c592";
  51. std::string gstrctrlMD5 = "5d41402abc4b2a76b9719d911017c592";
  52. int gindex = 0;
  53. private:
  54. void dec_yaml(const char * stryamlpath);
  55. void sharequerymsg(iv::cloud::cloudmsg * pxmsg);
  56. public:
  57. void UpdateData(const char * strdata,const unsigned int nSize,const char * strmemname);
  58. std::string GetVIN();
  59. };
  60. #endif // GRPCPC_H