#ifndef _DEVICEGASV2_HPP_ #define _DEVICEGASV2_HPP_ #include "UtilBase.hpp" namespace gsd { class DevicePlayerV2 : public ContorlSerialBase { private: uint8_t pressure; uint8_t commamd; int16_t current; uint16_t voltage; enum RECV_STEP{ STEP_HEAD = 0, STEP_ADDR = 1, STEP_LEN = 2, STEP_DIR = 3, STEP_DATA = 4 }; typedef struct { uint8_t dataCount; uint8_t dataLength; uint8_t dataCheckSum; uint8_t data[11]; enum RECV_STEP step = STEP_HEAD; }ExpelComm; ExpelComm _comm; public: DevicePlayerV2(): ContorlSerialBase() { this->DeviceInfo = "民航大板协议"; this->tool = DeviceTools::serial; this->baudRate = 115200; } ~DevicePlayerV2() {} uint8_t getPressure(); uint8_t getCommamd(); int16_t getCurrent(); uint16_t getVoltage(); /** * * @description: 判定msg是否为status * @param {int} &msg_id * @return {*} */ bool getStatusMsg(int &msg_id); /** * @description: 消费数据 * @param {uint8_t} *data * @param {int} len * @param {int} &msg_id * @return {*} */ bool Consumer(uint8_t *data, int len, int &msg_id); /** * @description: 反序列化 * @param {uint8_t} *data * @param {int} len * @param {int} &msg_id * @return {*} */ virtual bool deserialization(const uint8_t *data, int len, int &msg_id); /** * @description: 序列化 * @param {ControlerMsg} gasControl * @param {char*} data * @return {*} */ void serialization(const ControlerMsg gasControl, char* data, bool status = false); // 常规操作 int8_t Open(std::string _deviceId, uint8_t* data, int& length); int8_t Close(std::string _deviceId, uint8_t* data, int&length); int8_t Fire(std::string _deviceId, uint8_t* data, int& length); int8_t Status(std::string _deviceId, uint8_t* data, int& length); /** * @description: 构建设备信息 * @param {SendDevice&} sendDevice * @return {*} */ virtual void BuildDeviceInfo(SendDevice& sendDevice); }; } // namespace gsd #endif