DeviceGasV2.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #pragma once
  2. #include "UtilBase.hpp"
  3. namespace gsd
  4. {
  5. class DeviceGasV2: public ContorlHttplBase
  6. {
  7. public:
  8. DeviceGasV2():ContorlHttplBase(){
  9. this->DeviceInfo = "合肥新桥机场 西安为开煤气炮驱动板协议";
  10. this->tool = DeviceTools::http;
  11. }
  12. // 电压
  13. float voltage = 0;
  14. // 状态
  15. int state = 0;
  16. // 纬度
  17. float latitude = 0;
  18. // 经度
  19. float longitude = 0;
  20. std::string fuwuid = "551";
  21. std::string key = "cc23a0046c2ba907f6cc779e67c7183b";
  22. /**
  23. * @description: 判定msg是否为status
  24. * @param {int} &msg_id
  25. * @return {*}
  26. */
  27. bool getStatusMsg(int &msg_id);
  28. /**
  29. * @description: 消费数据
  30. * @param {uint8_t} *data
  31. * @param {int} len
  32. * @param {int} &msg_id
  33. * @return {*}
  34. */
  35. bool Consumer(uint8_t *data, int len, int &msg_id);
  36. /**
  37. * @description: 反序列化
  38. * @param {uint8_t} *data
  39. * @param {int} len
  40. * @param {int} &msg_id
  41. * @return {*}
  42. */
  43. virtual bool deserialization(const uint8_t *data, int len, int &msg_id);
  44. // 常规操作
  45. int8_t Open(std::string _deviceId, uint8_t* data, int& length);
  46. int8_t Close(std::string _deviceId, uint8_t* data, int&length);
  47. int8_t Fire(std::string _deviceId, uint8_t* data, int& length);
  48. int8_t Status(std::string _deviceId, uint8_t* data, int& length);
  49. /**
  50. * @description: 构建设备信息
  51. * @param {SendDevice&} sendDevice
  52. * @return {*}
  53. */
  54. virtual void BuildDeviceInfo(SendDevice& sendDevice);
  55. /**
  56. * @description: 序列化
  57. * @param {GasV1Control} gasV1Control
  58. * @param {char} *data
  59. * @return {*}
  60. */
  61. static void serialization(const ControlerMsg gasV1Control,char *data);
  62. /**
  63. * @description: getParms
  64. * @return {*}
  65. */
  66. httplib::Params getParms();
  67. /**
  68. * @description: getHeaders
  69. * @return {*}
  70. */
  71. httplib::Headers getHeaders();
  72. /**
  73. * @description:
  74. * @return {*}
  75. */
  76. std::string getUrl();
  77. ~DeviceGasV2(){}
  78. };
  79. } // namespace gsd