/***** (C) Copyright, Shenzhen SUNWIN Intelligent Co.,Ltd. ******header file**** * File name : expel.h * Author : Jinliang Yang * Brief : ******************************************************************************** * modify * Version Date Author Described * V2.00 2020/04/8 ShengYin Li Created *******************************************************************************/ #ifndef expel_h #define expel_h #pragma once #include #include #include #include #include #include #include "md5.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "SerialPort.h" #include "Util/util.h" #include "Util/logger.h" #include "Network/Socket.h" #include "Util/TimeTicker.h" #include "Poller/Timer.h" #include "Util/NoticeCenter.h" #include "Network/TcpClient.h" //dataType #include "NettyClientCommandEnum.h" #include "NettyServerCommandEnum.h" #include "NettyClientResultMsg.h" #include "NettyServerResultMsg.h" #include "RecDeviceCommand.h" #include "SendBird.h" #include "SendDevice.h" #include "SendHeartBeat.h" #include "Notices.h" #include "httplib.h" #include "ExpelDevice.h" #include #include "uuid.hpp" using namespace std; using namespace itas109; using namespace toolkit; using namespace utility; class Expel { public: Expel(); ~Expel(); /** * @description: 初始化 * @param {*} * @return {*} */ void Init(); /** * @description: 获取Ptr * @return {*} */ static std::shared_ptr getPtr(); /** * @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); list m_deviceIdList; list m_deviceLists; mutex m_mutex; 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); }; #endif /******** (C) Copyright, Shenzhen SUNWIN Intelligent Co.,Ltd. ******** End *****/