vehicle_patrol.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef VEHICLE_PATROL_H
  2. #define VEHICLE_PATROL_H
  3. #include <QObject>
  4. #include <QTimer>
  5. #include <QDateTime>
  6. #include <QVector>
  7. #include <QThread>
  8. #include <QMutex>
  9. #include <iostream>
  10. #include <memory>
  11. #include <string>
  12. #include <yaml-cpp/yaml.h>
  13. #include <grpcpp/grpcpp.h>
  14. #include "VehiclePatrol_service.grpc.pb.h"
  15. #include "VehiclePatrol.grpc.pb.h"
  16. #ifndef IV_MSGUNIT
  17. #define IV_MSGUNIT
  18. namespace iv {
  19. struct msgunit
  20. {
  21. char mstrmsgname[256];
  22. int mnBufferSize = 10000;
  23. int mnBufferCount = 1;
  24. void * mpa = nullptr;
  25. std::shared_ptr<char> mpstrmsgdata;
  26. int mndatasize = 0;
  27. bool mbRefresh = false;
  28. bool mbImportant = false;
  29. int mnkeeptime = 100;
  30. };
  31. }
  32. #endif
  33. using grpc::Channel;
  34. using grpc::ClientContext;
  35. using grpc::Status;
  36. using org::jeecg::defsPatrol::grpc::VehiclePatrolException; ///< service name
  37. using org::jeecg::defsPatrol::grpc::PatrolRequest;
  38. class VehiclePatrolExceptionClient : public QThread{
  39. Q_OBJECT
  40. public:
  41. VehiclePatrolExceptionClient(std::shared_ptr<Channel> channel);
  42. ~VehiclePatrolExceptionClient(void);
  43. std::string uploadVehiclePatrolInfo(void);
  44. void updatePatrolData(void);
  45. void dec_yaml(const char * stryamlpath);
  46. void ListenGPSIMUMsg(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
  47. protected:
  48. void run();
  49. private:
  50. std::unique_ptr<VehiclePatrolException::Stub> stub_;
  51. iv::msgunit shmGPSIMU;
  52. iv::msgunit shmPicFront;
  53. iv::msgunit shmPicRear;
  54. iv::msgunit shmPicLeft;
  55. iv::msgunit shmPicRight;
  56. iv::msgunit shmStartTurnstile;
  57. iv::msgunit shmTurnstile;
  58. QMutex mutex_GPSIMU;
  59. org::jeecg::defsPatrol::grpc::GPSPoint currentPosition;
  60. double currentSpeed;
  61. std::string id;
  62. bool isTVR = false; ///< Traffic Violation Recognition
  63. int32_t violationStatus; ///< 0 no violation 1 overspeed 2 illegal parking 3 direction wrong 4 run the red light
  64. std::string vehicleLicenseNumber;
  65. QByteArray violationImage;
  66. uint64_t violationTime; ///< time when get violationImage
  67. org::jeecg::defsPatrol::grpc::GPSPoint violationPosition; ///< positon when get violationImage
  68. bool isFSM = false; ///< Fire and Smoke Monitor
  69. int32_t fireStatus; ///< 0 no fire 1 has fire
  70. QByteArray fireImage;
  71. uint64_t fireTime; ///< time when get fireImage
  72. org::jeecg::defsPatrol::grpc::GPSPoint firePosition; ///< positon when get fireImage
  73. bool isTSGM = false; ///< Turn Stile Gate Monitor
  74. int32_t gateStatus; ///< 0 no gate 1 gate close 2 gate open
  75. QByteArray gateImage;
  76. uint64_t gateTime; ///< time when get gateImage
  77. org::jeecg::defsPatrol::grpc::GPSPoint gatePosition; ///< positon when get gateImage
  78. bool isNeedTSGM = false;
  79. QTime timerTSGM;
  80. uint8_t statusTSGM = 0; ///< 0 ready 1 wait for result 2 has result 3 timeout but no result
  81. org::jeecg::defsPatrol::grpc::GPSPoint gateDestination;
  82. std::string plateNumber;
  83. };
  84. #endif // VEHICLE_PATROL_H