123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #ifndef _DEVICEGASV1_HPP_
- #define _DEVICEGASV1_HPP_
- #include "UtilBase.hpp"
- namespace gsd{
- class DeviceGasV1: public ContorlSerialBase
- {
- private:
- enum RECV_STEP{
- STEP_HEAD = 0,
- STEP_1 = 1,
- STEP_2 = 2,
- STEP_TYPE = 3,
- STEP_ADDR = 4,
- STEP_COM = 5,
- STEP_ACK = 6,
- STEP_STA = 7,
- STEP_DATA = 8,
- STEP_RLC = 9
- };
- typedef struct {
- uint8_t dataCount;
- uint8_t dataLength;
- uint8_t dataCheckSum;
- uint8_t data[40];
- enum RECV_STEP step = STEP_HEAD;
- }ExpelComm;
- ExpelComm _comm;
- public:
- DeviceGasV1():ContorlSerialBase(){
- this->DeviceInfo = "兰州中川机场 煤气炮驱动板协议";
- this->tool = DeviceTools::serial;
- this->baudRate = 38400;
- }
- // 电压
- float voltage = 0;
- // 气压
- float pressure = 0;
- // 状态
- int state = 0;
- // 纬度
- float latitude = 0;
- // 经度
- float longitude = 0;
- /**
- * @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);
- // 常规操作
- 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);
- /**
- * @description: 序列化
- * @param {GasV1Control} gasV1Control
- * @param {char} *data
- * @return {*}
- */
- static void serialization(const ControlerMsg gasV1Control,char *data);
- // LRC校验
- static unsigned char LRC_check(unsigned char *pSendBuf,unsigned char num);
- ~DeviceGasV1(){}
- };
-
- }
- #endif
|