#ifndef _EXPEL_HPP_ #define _EXPEL_HPP_ #include "UtilBase.hpp" #include #include #include #include "Util/logger.h" #include "Util/NoticeCenter.h" #include "Network/TcpClient.h" #include "requests.hpp" #include "ExpelDevice.h" #include "httplib.h" #include "CSerialPort/SerialPort.h" // dev #include "DevicePlayerV1.hpp" #include "DevicePlayerV2.hpp" #include "DevicePlayerV3.hpp" #include "DevicePlayerV3.hpp" #include "DevicePlayerV4.hpp" #include "DevicePlayerV5.hpp" #include "DeviceGasV1.hpp" #include "DeviceGasV2.hpp" #include "config.hpp" #include #include "PlayerStatus.h" #include "uuid.hpp" #include "Notices.h" using namespace utility; using namespace toolkit; using namespace itas109; namespace gsd{ class Expel: public std::enable_shared_from_this, public ModuleBase { private: Expel(): ModuleBase(){ this->pool = std::make_shared(1,ThreadPool::PRIORITY_HIGHEST, false); InfoL; } public: using Ptr = std::shared_ptr; ~Expel(){ this->Destroy(); } /** * @description: 获取Ptr * @return {*} */ static std::shared_ptr getPtr(); /** * @description: 初始化 * @return {*} */ bool Init(); /** * @description: 释放 * @return {*} */ void Destroy(); /** * @description: HttpControler的控制接口 * @param {int} commandCode * @param {ExpelDevice} expelDevice * @return {*} */ void HttpControler(int commandCode, ExpelDevice expelDevice); /** * @description: 设备命令的回调函数 * @param {NettyServerResultMsg} &nettyServerResultMsg * @return {*} */ void sendDeviceMsgCallback(NettyServerResultMsg &nettyServerResultMsg, ExpelDevice expelDevice); /** * @description: 全部打开 * @param {*} * @return {*} */ int32_t AllOpen(); /** * @description: * @param {*} * @return {*} */ int32_t AllClose(); /** * @description: 全部开炮 * @param {*} * @return {*} */ int32_t AllFire(); /** * @description: 获取设备列表 * @param {*} * @return {*} */ int32_t UpdateDeviceList(vector>& datas); /** * @description: 数组转为json * @param {uint8_t*} bytes * @param {int} length * @return {*} */ static std::string bytesToHexString(const uint8_t* bytes,const int length); /** * @description: 获取驱鸟设备数量 * @return {*} */ int32_t getExpelSize(); /** * @description: 全部驱鸟设备的控制器 * @return {*} */ int32_t Controler(std::string commandCode); /** * @description: getExpelInfo * @return {*} */ std::string getExpelInfo(); list m_deviceIdList; list m_deviceLists; private: /** * @description: 获取控制器 * @param {*} * @return {*} */ std::shared_ptr getControl(ExpelDevice& expelDevice); /** * @description: 启动 * @param {int} deivceId * @return {*} */ int32_t Open(ExpelDevice& expelDevice); /** * @description: 关闭 * @param {int} deivceId * @return {*} */ int32_t Close(ExpelDevice& expelDevice); /** * @description: 开火 * @param {int} deivceId * @return {*} */ int32_t Fire(ExpelDevice& expelDevice); /** * @description: 状态 * @param {int} deivceId * @param {string&} json * @return {*} */ int32_t Status(ExpelDevice& expelDevice); /** * @description: 串口数据接收 * @param {*} * @return {*} */ bool SerialReceive(CSerialPort& ser, std::shared_ptr& deviceControl); /** * @description: Control * @param {*} * @return {*} */ int32_t Control(std::shared_ptr& deviceControl, ExpelDevice& expelDevice, uint8_t* data, int& length, int type); protected: mutex m_mutex; std::shared_ptr pool = nullptr; }; }; #endif