grpcclient.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef GRPCCLIENT_H
  2. #define GRPCCLIENT_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 <iostream>
  13. #include <memory>
  14. #include <string>
  15. #include <grpcpp/grpcpp.h>
  16. namespace iv {
  17. struct msgunit
  18. {
  19. char mstrmsgname[256];
  20. int mnBufferSize = 10000;
  21. int mnBufferCount = 1;
  22. void * mpa;
  23. std::shared_ptr<char> mpstrmsgdata;
  24. int mndatasize = 0;
  25. bool mbRefresh = false;
  26. bool mbImportant = false;
  27. int mnkeeptime = 100;
  28. };
  29. }
  30. using grpc::Channel;
  31. using grpc::ClientContext;
  32. using grpc::Status;
  33. class grpcclient : public QThread
  34. {
  35. public:
  36. grpcclient(std::string stryamlpath);
  37. private:
  38. std::string gstrserverip = "139.9.235.66";//"123.57.212.138";
  39. std::string gstruploadPort = "10591";//"9000";
  40. std::string gstrpatrolPort = "10592";//"9000";
  41. std::string gstrcontrolPort = "20591";//"9000";
  42. std::string gstruploadInterval = "100";
  43. std::string gstrpatrolInterval = "100";
  44. std::string gstrcontrolInterval = "100";
  45. std::string gstrid = "1";
  46. std::string gstrplateNumber = "A00001";
  47. void * gpa;
  48. QMutex gMutexMsg;
  49. std::thread * guploadthread;
  50. std::vector<iv::msgunit> mvectormsgunit;
  51. std::vector<iv::msgunit> mvectorctrlmsgunit;
  52. int gindex = 0;
  53. public:
  54. void UpdateData(const char * strdata,const unsigned int nSize,const char * strmemname);
  55. private:
  56. void run();
  57. void dec_yaml(const char * stryamlpath);
  58. void sharectrlmsg(iv::cloud::cloudmsg * pxmsg);
  59. };
  60. #endif // GRPCCLIENT_H