DevicePlayerV1.hpp 2.6 KB

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