DevicePlayerV2.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _DEVICEGASV2_HPP_
  2. #define _DEVICEGASV2_HPP_
  3. #include "UtilBase.hpp"
  4. namespace gsd
  5. {
  6. class DevicePlayerV2 : public ContorlSerialBase
  7. {
  8. private:
  9. uint8_t pressure;
  10. uint8_t commamd;
  11. int16_t current;
  12. uint16_t voltage;
  13. enum RECV_STEP{
  14. STEP_HEAD = 0,
  15. STEP_ADDR = 1,
  16. STEP_LEN = 2,
  17. STEP_DIR = 3,
  18. STEP_DATA = 4
  19. };
  20. typedef struct {
  21. uint8_t dataCount;
  22. uint8_t dataLength;
  23. uint8_t dataCheckSum;
  24. uint8_t data[11];
  25. enum RECV_STEP step = STEP_HEAD;
  26. }ExpelComm;
  27. ExpelComm _comm;
  28. public:
  29. DevicePlayerV2(): ContorlSerialBase()
  30. {
  31. this->DeviceInfo = "民航大板协议";
  32. this->tool = DeviceTools::serial;
  33. this->baudRate = 115200;
  34. }
  35. ~DevicePlayerV2() {}
  36. uint8_t getPressure();
  37. uint8_t getCommamd();
  38. int16_t getCurrent();
  39. uint16_t getVoltage();
  40. /**
  41. *
  42. * @description: 判定msg是否为status
  43. * @param {int} &msg_id
  44. * @return {*}
  45. */
  46. bool getStatusMsg(int &msg_id);
  47. /**
  48. * @description: 消费数据
  49. * @param {uint8_t} *data
  50. * @param {int} len
  51. * @param {int} &msg_id
  52. * @return {*}
  53. */
  54. bool Consumer(uint8_t *data, int len, int &msg_id);
  55. /**
  56. * @description: 反序列化
  57. * @param {uint8_t} *data
  58. * @param {int} len
  59. * @param {int} &msg_id
  60. * @return {*}
  61. */
  62. virtual bool deserialization(const uint8_t *data, int len, int &msg_id);
  63. /**
  64. * @description: 序列化
  65. * @param {ControlerMsg} gasControl
  66. * @param {char*} data
  67. * @return {*}
  68. */
  69. void serialization(const ControlerMsg gasControl, char* data, bool status = false);
  70. // 常规操作
  71. int8_t Open(std::string _deviceId, uint8_t* data, int& length);
  72. int8_t Close(std::string _deviceId, uint8_t* data, int&length);
  73. int8_t Fire(std::string _deviceId, uint8_t* data, int& length);
  74. int8_t Status(std::string _deviceId, uint8_t* data, int& length);
  75. /**
  76. * @description: 构建设备信息
  77. * @param {SendDevice&} sendDevice
  78. * @return {*}
  79. */
  80. virtual void BuildDeviceInfo(SendDevice& sendDevice);
  81. };
  82. } // namespace gsd
  83. #endif