123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #ifndef _DEVICEGASV5_HPP_
- #define _DEVICEGASV5_HPP_
- #include "UtilBase.hpp"
- namespace gsd
- {
- class DevicePlayerV5 : public ContorlSerialBase
- {
- private:
- uint8_t pressure;
- uint8_t commamd;
- int16_t current;
- uint16_t voltage;
- enum RECV_STEP{
- STEP_HEAD = 0,
- STEP_CMD= 1,
- STEP_LEN = 2,
- STEP_DATA = 3
- };
- 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:
- DevicePlayerV5(): ContorlSerialBase()
- {
- this->DeviceInfo = "三亚继电器协议";
- this->tool = DeviceTools::serial;
- this->baudRate = 9600;
- }
- ~DevicePlayerV5() {}
- 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
|