123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #ifndef _DEVICEPLAYERV1_HPP_
- #define _DEVICEPLAYERV1_HPP_
- #include "Crc.h"
- #include "UtilBase.hpp"
- namespace gsd{
- /**
- * @brief DevicePlayerV1
- *
- */
- class DevicePlayerV1: public ContorlSerialBase
- {
- private:
- unsigned short voltage;
- short current;
- short pressure;
- uint8_t power_out_state;
- enum RECV_STEP{
- STEP_HEAD = 0,
- STEP_LEN = 1,
- STEP_SEQ = 2,
- STEP_SAddr = 3,
- STEP_DAddr = 4,
- STEP_MSGId = 5,
- STEP_DATA = 6
- };
- typedef struct {
- uint8_t dataCount;
- uint8_t dataLength;
- uint8_t dataCheckSum;
- uint8_t data[15];
- enum RECV_STEP step = STEP_HEAD;
- }ExpelComm;
- ExpelComm _comm;
- public:
- DevicePlayerV1(): ContorlSerialBase()
- {
- this->DeviceInfo = "民航小板协议";
- this->tool = DeviceTools::serial;
- this->baudRate = 115200;
- }
- ~DevicePlayerV1(){}
- unsigned short getVoltage();
- short getCurent();
- short getPressure();
- uint8_t getPowerOutState();
- /**
- * @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);
- // 常规操作
- 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);
- };
- };
- #endif
|