DevicePlayerV4.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef _DEVICEGASV4_HPP_
  2. #define _DEVICEGASV4_HPP_
  3. #include "UtilBase.hpp"
  4. #include "Util/logger.h"
  5. #include "requests.hpp"
  6. namespace gsd
  7. {
  8. class DevicePlayerV4: public ContorlTcplBase
  9. {
  10. private:
  11. enum RECV_STEP{
  12. STEP_HEAD_1 = 0,
  13. STEP_HEAD_2 = 1,
  14. STEP_TYPE = 2,
  15. STEP_DEVID = 3,
  16. STEP_COM = 4,
  17. STEP_ACK = 5
  18. };
  19. typedef struct {
  20. uint8_t dataCount;
  21. uint8_t dataLength;
  22. uint8_t dataCheckSum;
  23. uint8_t data[6];
  24. enum RECV_STEP step = STEP_HEAD_1;
  25. }ExpelComm;
  26. ExpelComm _comm;
  27. public:
  28. DevicePlayerV4(): ContorlTcplBase(){
  29. this->DeviceInfo = "赛为智能驱鸟器协议";
  30. this->tool = DeviceTools::tcp;
  31. }
  32. ~DevicePlayerV4(){}
  33. // 电压
  34. float voltage = 0;
  35. // 气压
  36. float pressure = 0;
  37. // 状态
  38. int state = 0;
  39. // 纬度
  40. float latitude = 0;
  41. // 经度
  42. float longitude = 0;
  43. static unsigned char check(unsigned char *pSendBuf,unsigned char num);
  44. static void serialization(const ControlerMsg gasControl,char *data);
  45. bool deserialization()
  46. {
  47. return true;
  48. }
  49. bool Consumer(uint8_t *data, int len, int &msg_id);
  50. bool deserialization(const uint8_t *data, int len, int &msg_id);
  51. /**
  52. * @description: 打开
  53. * @param {int} deivceId
  54. * @return {*}
  55. */
  56. int8_t Open(std::string DeviceId, uint8_t* data, int& length);
  57. /**
  58. * @description: 关闭
  59. * @param {int} deivceId
  60. * @return {*}
  61. */
  62. int8_t Close(std::string DeviceId, uint8_t* data, int& length);
  63. /**
  64. * @description: 开炮
  65. * @param {int} deivceId
  66. * @return {*}
  67. */
  68. int8_t Fire(std::string DeviceId, uint8_t* data, int& length);
  69. /**
  70. * @description: 状态
  71. * @param {int} deivceId
  72. * @return {*}
  73. */
  74. int8_t Status(std::string DeviceId, uint8_t* data, int& length);
  75. /**
  76. * @description: 判定msg是否为status
  77. * @param {int} &msg_id
  78. * @return {*}
  79. */
  80. bool getStatusMsg(int &msg_id){
  81. return true;
  82. }
  83. /**
  84. * @description: 构建设备信息
  85. * @param {SendDevice&} sendDevice
  86. * @return {*}
  87. */
  88. void BuildDeviceInfo(SendDevice& sendDevice);
  89. };
  90. } // namespace gsd
  91. #endif