DevicePlayerV5.hpp 2.5 KB

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