grpcpc.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "uploadstreammsg.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 = "127.0.0.1";
  43. std::string gstrserverport = "50051";
  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. void threadsend(std::shared_ptr<::grpc::ClientReaderWriter<iv::queryReqStream, iv::queryReplyStream> > writer,bool * pbrun);
  60. };
  61. #endif // GRPCPC_H