Browse Source

完善驱鸟器控制

Your Name 2 years ago
parent
commit
4c1936c8a2

+ 5 - 5
framework/request/include/ExpelDevice.h

@@ -4,7 +4,7 @@
  * @Autor: lishengyin
  * @Date: 2022-02-16 15:25:46
  * @LastEditors: lishengyin
- * @LastEditTime: 2022-08-22 14:35:20
+ * @LastEditTime: 2022-08-23 17:44:35
  */
 #ifndef __EXPELDEVICE_H_
 #define __EXPELDEVICE_H_
@@ -25,10 +25,10 @@ using namespace gsd;
 
 enum DeviceType { 
     DevicePlayerV1 = 0,
-    DevicePlayerV2 = 1,
-    DevicePlayerV3 = 2,
-    DevicePlayerV4 = 3,
-    DeviceGasV1 = 4
+    DeviceGasV1 = 1,
+    DevicePlayerV2 = 2,
+    DevicePlayerV3 = 3,
+    DevicePlayerV4 = 4,
 };
 
 class ExpelDevice

BIN
lib/libgsd_modules.so


BIN
lib/libgsd_plugins.so


+ 107 - 0
modules/Expel/include/DeviceGasV1.hpp

@@ -0,0 +1,107 @@
+
+#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

+ 2 - 19
modules/Expel/include/DevicePlayerV1.hpp

@@ -1,27 +1,10 @@
-#ifndef _DEVICEGASV1_HPP_
-#define _DEVICEGASV1_HPP_
+#ifndef _DEVICEPLAYERV1_HPP_
+#define _DEVICEPLAYERV1_HPP_
 
 #include "Crc.h"
 #include "UtilBase.hpp"
 
 namespace gsd{
-    // 声波驱鸟器
-    #define EXPEL_DATA_HEAD          (0xFE) // 数据头
-    #define EXPEL_HEART_BEAT         (0x01) // 心跳
-    #define EXPEL_GENERAL_ACK        (0X02) // 通用应答
-    #define EXPEL_SYS_STATE          (0x14) // 获取设备信息
-    #define EXPEL_SYS_STATE_ACK      (0X15) // 获取设备信息应答
-
-    #define EXPEL_POWER_OUTPUT_CTRL  (0X16) // 电源输出控制   <-: 通用应答
-    #define EXPEL_POWER_OUTPUT_ON    (0x01) // 电源开启
-    #define EXPEL_POWER_OUTPUT_OFF   (0x00) // 电源关闭
-
-    #define EXPEL_BOMB_CTRL          (0X17) // 煤气炮控制     <-: 通用应答
-    #define EXPEL_BOMB_ON            (0X01) // 煤气炮开炮
-
-    #define EXPEL_GET_BOMB_STATE     (0X18) // 获取开炮结果   
-    #define EXPEL_GET_BOMB_STATE_ACK (0X19) // 煤气炮开炮应答 <-:通用应答(因为状态为阶段状态,过时会丢失状态。需确认应答收到,未收到应带会重传3次
-
     /**
      * @brief DevicePlayerV1
      * 

+ 100 - 0
modules/Expel/include/DevicePlayerV2.hpp

@@ -0,0 +1,100 @@
+#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

+ 12 - 0
modules/Expel/include/DevicePlayerV4.hpp

@@ -0,0 +1,12 @@
+#ifndef _DEVICEGASV4_HPP_
+#define _DEVICEGASV4_HPP_
+
+#include "UtilBase.hpp"
+
+
+
+
+
+
+
+#endif

+ 1 - 0
modules/Expel/include/Expel.hpp

@@ -18,6 +18,7 @@
 #include "DevicePlayerV3.hpp"
 #include "DevicePlayerV4.hpp"
 #include "DeviceGasV1.hpp"
+
 #include "config.hpp"
 #include <iostream>
 #include "PlayerStatus.h"

+ 260 - 0
modules/Expel/src/DeviceGasV1.cpp

@@ -0,0 +1,260 @@
+#include <DeviceGasV1.hpp>
+
+namespace gsd
+{
+    #define DATA_HEAD          (0x40) // 数据头
+    //控制设备类型
+    // device_TYPE
+    #define DEVICE_TYPE_ID        (0x05) // 煤气炮
+
+    // 命令类型
+    // msgId
+    #define MSG_ID_COMMAND  (0x08) //命令
+    #define MSG_ID_INQUIRE  (0x04) //查询
+    #define MSG_ID_DEPLOY   (0x03) //配置
+    #define MSG_ID_COMMAND_ACK      (0X09) //命令应答
+    #define MSG_ID_INQUIRE_ACK   (0X0A) //查询应答
+    #define MSG_ID_DEPLOY_ACK    (0x0b) //配置应答
+
+    //data
+    #define DATA_FIRE               (0x55)//开启
+    #define DATA_STOP               (0xAA)//停止
+    #define DATA_INQUIRE            (0xAB)//查询监控数据
+
+    /**
+     * @description: 序列化
+     * @param {ControlerMsg} gasV1Control
+     * @param {char} *data
+     * @return {*}
+     */    
+    void DeviceGasV1::serialization(const ControlerMsg gasControl,char *data){
+        data[0] =  DATA_HEAD;
+        data[1] =  0x23;
+        data[2] =  0x24;
+        data[3] = DEVICE_TYPE_ID;
+        data[4] = gasControl.deviceId;
+        data[5] = gasControl.msgId;
+        data[6] = gasControl.data;
+        if(gasControl.msgId == MSG_ID_COMMAND){
+            data[7] = 0xb3;
+            data[8] = 0xff;
+        }else if(gasControl.msgId == MSG_ID_INQUIRE){
+            data[7] = 0xAA;
+            data[8] = 0xAA;
+        }
+        data[9] = LRC_check((unsigned char *)data, 9);
+    }
+
+    /**
+     * @description: 反序列化
+     * @param {uint8_t} *data
+     * @param {int} len
+     * @param {int} &msg_id
+     * @return {*}
+     */    
+    bool DeviceGasV1::deserialization(const uint8_t *data, int len, int &msg_id){
+        if(data[0] != DATA_HEAD && data[1] != 0x23 && data[2] != 0x24 && data[3] != DEVICE_TYPE_ID) return false;
+        if(DeviceGasV1::LRC_check((unsigned char *)data, len - 1) != data[len - 1]) return false;
+        setDeviceId(std::to_string(data[4]));
+        if(data[5] == 0x00){
+            msg_id = data[6];
+            switch (msg_id)
+            {
+            // 命令应答
+            case MSG_ID_COMMAND_ACK:
+                break;
+            // 查询应答
+            case MSG_ID_INQUIRE_ACK:
+                this->voltage = (float)data[8] + (float)(data[9]/100);
+                this->pressure = (float)data[10] + (float)(data[11]/100);
+                this->state = data[12];
+                break;
+            // 配置应答
+            case MSG_ID_DEPLOY_ACK:
+                break;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * @description: 消费数据
+     * @param {uint8_t} *data
+     * @param {int} len
+     * @param {int} &msg_id
+     * @return {*}
+     */    
+    bool DeviceGasV1::Consumer(uint8_t *data, int len, int &msg_id)
+    {
+        bool ReceiveSuccessful = false;
+        for (int i = 0; i < len; i++)
+        {
+            switch(_comm.step){
+                case STEP_HEAD:
+                    if(data[i] == DATA_HEAD){
+                        _comm.data[0] = DATA_HEAD;
+                        _comm.step = STEP_1;
+                    }
+                    break;
+                case STEP_1:
+                    if(data[i] == 0x23){
+                        _comm.data[1] = data[i];
+                        _comm.step = STEP_2;
+                    }
+                    break;
+                case STEP_2:
+                    if(data[i] == 0x24){
+                        _comm.data[2] = data[i];
+                        _comm.step = STEP_TYPE;
+                    }
+                    break; 
+                case STEP_TYPE:
+                    _comm.data[3] = data[i];
+                    _comm.step = STEP_ADDR;
+                    break;
+                case STEP_ADDR:
+                    _comm.data[4] = data[i];
+                    _comm.step = STEP_COM;
+                    break;
+                case STEP_COM:
+                    _comm.data[5] = data[i];
+                    _comm.step = STEP_ACK;
+                    break;
+                case STEP_ACK:
+                    _comm.data[6] = data[i];
+                    _comm.step = STEP_STA;
+                    break;
+                case STEP_STA:
+                    _comm.data[7] = data[i];
+                    _comm.step = STEP_DATA;
+                    _comm.dataCount = 8;
+                    break;
+                case STEP_DATA:
+                    _comm.data[_comm.dataCount++] = data[i];
+                    if(_comm.dataCount == 40){
+                        ReceiveSuccessful = true;
+                        _comm.step = STEP_HEAD;
+                    }
+                    break;
+                default:
+                    _comm.step = STEP_HEAD;
+                    break;   
+            }
+        }
+        if(!ReceiveSuccessful) return false;
+        return deserialization(_comm.data, _comm.dataCount, msg_id);
+    }
+
+
+
+    /**
+     * @description: 打开
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DeviceGasV1::Open(std::string DeviceId, uint8_t* data, int& length){
+        ControlerMsg gasControl;
+        gasControl.deviceId = atoi(DeviceId.c_str());
+        gasControl.msgId = 0x00;
+        gasControl.data = 0x00;
+        length = 11;
+        serialization(gasControl, (char *)data);
+        return 0;
+    }
+
+    /**
+     * @description: 关闭
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DeviceGasV1::Close(std::string DeviceId, uint8_t* data, int& length){
+        ControlerMsg gasControl;
+        gasControl.deviceId = atoi(DeviceId.c_str());
+        gasControl.msgId = MSG_ID_COMMAND;
+        gasControl.data = DATA_STOP;
+        length = 11;
+        serialization(gasControl, (char *)data);
+        return 0;
+    }
+
+    /**
+     * @description: 开炮
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DeviceGasV1::Fire(std::string DeviceId, uint8_t* data, int& length){
+        ControlerMsg gasControl;
+        gasControl.deviceId = atoi(DeviceId.c_str());
+        gasControl.msgId = MSG_ID_COMMAND;
+        gasControl.data = DATA_FIRE;
+        length = 11;
+        serialization(gasControl, (char *)data);
+        return 0;
+    }
+
+    /**
+     * @description: 状态
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DeviceGasV1::Status(std::string DeviceId, uint8_t* data, int& length){
+        ControlerMsg gasControl;
+        gasControl.deviceId = atoi(DeviceId.c_str());
+        gasControl.msgId = MSG_ID_INQUIRE;
+        gasControl.data = DATA_INQUIRE;
+        length = 11;
+        serialization(gasControl, (char *)data);
+        return 0;
+    }
+
+    /**
+     * @description: 判定msg是否为status
+     * @param {int} &msg_id
+     * @return {*}
+     */    
+    bool DeviceGasV1::getStatusMsg(int &msg_id){
+        if(msg_id != MSG_ID_INQUIRE_ACK) return false;
+        return true;
+    }
+
+    /**
+     * @description: 构建设备信息
+     * @param {SendDevice&} sendDevice
+     * @return {*}
+     */    
+    void DeviceGasV1::BuildDeviceInfo(SendDevice& sendDevice){
+        sendDevice.deviceId = atoi(this->getDeviceId().c_str());
+        sendDevice.commandCode = "1";
+        sendDevice.status = 1;
+        sendDevice.workStatus = 1;
+        sendDevice.powerStatus = 1;
+        sendDevice.batteryStatus = 1;
+        sendDevice.num  = 0;
+        sendDevice.oxyPressure  = 0;
+        sendDevice.gasPressure  = 0;
+        sendDevice.remark = "";
+        sendDevice.attr1 = std::to_string(this->voltage);     // 电压
+        sendDevice.attr2 = std::to_string(this->pressure);     // 声压
+    }
+
+    /**
+     * @description: LRC_check
+     * @param {unsigned char} *pSendBuf
+     * @param {unsigned char} num
+     * @return {*}
+     */    
+    unsigned char DeviceGasV1::LRC_check(unsigned char *pSendBuf,unsigned char num)
+    {
+        char bylrc = 0,i = 0;
+        
+        for(i = 0; i < num; i++)
+        {
+            bylrc += pSendBuf[i];
+        }
+        bylrc = ~bylrc;
+        bylrc++;
+
+        return bylrc;
+    }
+} // namespace gsd

+ 17 - 1
modules/Expel/src/DevicePlayerV1.cpp

@@ -1,8 +1,24 @@
 #include "DevicePlayerV1.hpp"
 
-
 namespace gsd
 {
+    // 声波驱鸟器
+    #define EXPEL_DATA_HEAD          (0xFE) // 数据头
+    #define EXPEL_HEART_BEAT         (0x01) // 心跳
+    #define EXPEL_GENERAL_ACK        (0X02) // 通用应答
+    #define EXPEL_SYS_STATE          (0x14) // 获取设备信息
+    #define EXPEL_SYS_STATE_ACK      (0X15) // 获取设备信息应答
+
+    #define EXPEL_POWER_OUTPUT_CTRL  (0X16) // 电源输出控制   <-: 通用应答
+    #define EXPEL_POWER_OUTPUT_ON    (0x01) // 电源开启
+    #define EXPEL_POWER_OUTPUT_OFF   (0x00) // 电源关闭
+
+    #define EXPEL_BOMB_CTRL          (0X17) // 煤气炮控制     <-: 通用应答
+    #define EXPEL_BOMB_ON            (0X01) // 煤气炮开炮
+
+    #define EXPEL_GET_BOMB_STATE     (0X18) // 获取开炮结果   
+    #define EXPEL_GET_BOMB_STATE_ACK (0X19) // 煤气炮开炮应答 <-:通用应答(因为状态为阶段状态,过时会丢失状态。需确认应答收到,未收到应带会重传3次
+    
     unsigned short DevicePlayerV1::getVoltage(){
         return voltage;
     }

+ 232 - 0
modules/Expel/src/DevicePlayerV2.cpp

@@ -0,0 +1,232 @@
+#include "DevicePlayerV2.hpp"
+
+namespace gsd
+{
+    // 超声波驱鸟炮
+    #define EXPEL_WRITE             (0x15)
+    #define EXPEL_READ              (0x05)
+
+    #define EXPEL_POWER_OFF         (0)
+    #define EXPEL_POWER_ON          (1<<7)
+    #define EXPEL_PLAY_DISPEL       (1<<6)
+    #define EXPEL_TURN_OFF_DISPEL   (0)
+    #define EXPEL_NOT_FIRE          (0)
+    #define EXPEL_SINGLE_FIRE       (1<<4)
+    #define EXPEL_BURST_FIRE        (2<<4)
+    #define EXPEL_TURN_LEFT_CANCEL  (0)
+    #define EXPEL_TURN_LEFT_ENABLE  (1<<3)
+    #define EXPEL_TURN_RIGHT_CANCEL (0)
+    #define EXPEL_TURN_RIGHT_ENABLE (1<<2)
+    #define EXPEL_TURN_UP_CANCEL    (0)
+    #define EXPEL_TURN_UP_ENABLE    (1<<1)
+    #define EXPEL_TURN_DOWN_CANCEL  (0)
+    #define EXPEL_TURN_DOWM_ENABLE  (1)
+
+    #define EXPEL_STAUS_ACK  0x05
+    
+
+     uint8_t DevicePlayerV2::getPressure(){
+       return pressure;
+    }
+    uint8_t DevicePlayerV2::getCommamd(){
+       return commamd;
+    }
+    int16_t DevicePlayerV2::getCurrent(){
+        return current;
+    }
+    uint16_t DevicePlayerV2::getVoltage(){
+        return voltage;
+    }
+
+    /**
+     * @description: 序列化
+     * @param {ControlerMsg} gasControl
+     * @param {char*} data
+     * @param {bool} status
+     * @return {*}
+     */    
+    void DevicePlayerV2::serialization(const ControlerMsg gasControl, char* data, bool status){
+        data[0] = 0xaa;
+        data[1] = (uint8_t)gasControl.deviceId;
+        data[2] = 0x06;
+        if(status) data[3] = 0x05;
+        else data[3] = 0x15;
+        data[4] = gasControl.data;
+        data[5] = 0;
+
+        for (int i = 0; i < 5; i++) {
+            data[5] += data[i];
+        }
+    }
+
+    /**
+     * @description: 反序列化
+     * @param {uint8_t} *data
+     * @param {int} len
+     * @param {int} &msg_id
+     * @return {*}
+     */    
+    bool DevicePlayerV2::deserialization(const uint8_t *data, int len, int &msg_id){
+        if(data[0] != 0xbb){
+            return false;
+        }
+        uint8_t dataCheckSum = 0;
+        for(int i = 0; i < len - 1; i++){
+            dataCheckSum += data[i];
+        }
+        if(dataCheckSum != data[len - 1]){
+            return false;
+        }
+        msg_id = data[3];
+        if(msg_id == EXPEL_STAUS_ACK){
+            this->setDeviceId(to_string(data[1]));
+            this->pressure = (data[9]&0x80) >> 7;
+            this->commamd = (data[4]);
+            this->current = (int16_t)(data[8]<<8 || data[7]);
+            this->voltage = uint16_t(data[6]<<8 || data[5]);
+        }
+        return true;
+    }
+
+    /**
+     * @description: 消费数据
+     * @param {uint8_t} *data
+     * @param {int} len
+     * @param {int} &msg_id
+     * @return {*}
+     */    
+    bool DevicePlayerV2::Consumer(uint8_t *data, int len, int &msg_id){
+        bool ReceiveSuccessful = false;
+        for(int i = 0; i < len; i++){
+            switch(_comm.step){
+                case STEP_HEAD:
+                    if(data[i] == 0xbb){
+                        _comm.data[0] = 0xbb;
+                        _comm.step = STEP_ADDR;
+                    }
+                    break;
+                case STEP_ADDR:
+                    _comm.data[1] = data[i];
+                    _comm.step = STEP_LEN;
+                    break;
+                case STEP_LEN:
+                    if (data[i] == 0x0B) {
+                        _comm.data[2] = 0x0B;
+                        _comm.dataLength = 0x0B;
+                        _comm.step = STEP_DIR;
+                    } else {
+                        _comm.step = STEP_HEAD;
+                    }
+                    break; 
+                case STEP_DIR:
+                    if (data[i] == 0x05) {
+                        _comm.data[3] = 0x05;
+                        _comm.step = STEP_DATA;
+                        _comm.dataCount = 4;
+                    } else {
+                        _comm.step = STEP_HEAD;
+                    }
+                    break;
+                case STEP_DATA:
+                    _comm.data[_comm.dataCount++] = data[i];
+                    if(_comm.dataCount == _comm.dataLength){
+                        ReceiveSuccessful = true;
+                        _comm.step = STEP_HEAD;
+                    }
+                    break;
+                default:
+                    _comm.step = STEP_HEAD;
+                    break;   
+            }
+        }
+        if(!ReceiveSuccessful) {
+            return false;
+        }
+        return deserialization(_comm.data, _comm.dataLength, msg_id);
+    }
+
+     /**
+     * @description: 打开
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DevicePlayerV2::Open(std::string DeviceId, uint8_t* data, int& length){
+        ControlerMsg gasControl;
+        gasControl.deviceId = std::atoi(DeviceId.c_str());
+        gasControl.data = EXPEL_POWER_ON | EXPEL_PLAY_DISPEL | EXPEL_BURST_FIRE;
+        length = 6;
+        serialization(gasControl, (char*)data);
+        return 0;
+    }
+
+    /**
+     * @description: 关闭
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DevicePlayerV2::Close(std::string DeviceId, uint8_t* data, int& length){
+        ControlerMsg gasControl;
+        gasControl.deviceId = std::atoi(DeviceId.c_str());
+        gasControl.data = EXPEL_POWER_OFF | EXPEL_TURN_OFF_DISPEL | EXPEL_NOT_FIRE;
+        length = 6;
+        serialization(gasControl, (char*)data);
+        return 0;
+    }
+
+    /**
+     * @description: 开炮
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DevicePlayerV2::Fire(std::string DeviceId, uint8_t* data, int& length){
+        return Open(DeviceId, data, length);
+    }
+
+    /**
+     * @description: 状态
+     * @param {int} deivceId
+     * @return {*}
+     */    
+    int8_t DevicePlayerV2::Status(std::string DeviceId, uint8_t* data, int& length){
+        ControlerMsg gasControl;
+        gasControl.deviceId = std::atoi(DeviceId.c_str());
+        gasControl.data = 0;
+        length = 6;
+        bool staus = true;
+        serialization(gasControl, (char*)data, staus);
+        return 0;
+    }
+
+    /**
+     * @description: 判定msg是否为status
+     * @param {int} &msg_id
+     * @return {*}
+     */    
+    bool DevicePlayerV2::getStatusMsg(int &msg_id){
+        if(msg_id != EXPEL_STAUS_ACK) return false;
+        return true;
+    }
+
+    /**
+     * @description: 构建设备信息
+     * @param {SendDevice&} sendDevice
+     * @return {*}
+     */    
+    void DevicePlayerV2::BuildDeviceInfo(SendDevice& sendDevice){
+        sendDevice.deviceId = atoi(this->getDeviceId().c_str());
+        sendDevice.commandCode = "1";
+        sendDevice.status = 1;
+        sendDevice.workStatus = 1;
+        sendDevice.powerStatus = 1;
+        sendDevice.batteryStatus = 1;
+        sendDevice.num  = 0;
+        sendDevice.oxyPressure  = 0;
+        sendDevice.gasPressure  = 0;
+        sendDevice.remark = "";
+        // sendDevice.attr1 = std::to_string(this->getVoltage());     // 电压
+        // sendDevice.attr2 = std::to_string(this->getCurrent());     // 电流
+        // sendDevice.attr3 = std::to_string(this->getPressure());    // 声压
+    }
+
+} // namespace gsd
+

+ 7 - 6
modules/Expel/src/Expel.cpp

@@ -76,13 +76,14 @@ namespace gsd
         case DeviceType::DevicePlayerV1:
             deviceControl = std::make_shared<DevicePlayerV1>();
             break;
-        // case DeviceGasV2:
-        //     deviceControl = std::make_shared<deviceGasV2>();
-        //     break;
 
-        // case DeviceUlt:
-        //     deviceControl = std::make_shared<deviceUlt>();
-        //     break;
+        case DeviceType::DevicePlayerV2:
+            deviceControl = std::make_shared<DevicePlayerV2>();
+            break;
+
+        case DeviceType::DeviceGasV1:
+            deviceControl = std::make_shared<DeviceGasV1>();
+            break;
         
         case DeviceType::DevicePlayerV3:
             deviceControl = std::make_shared<DevicePlayerV3>();