123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- #ifndef _EXPEL_HPP_
- #define _EXPEL_HPP_
- #include "UtilBase.hpp"
- #include <mutex>
- #include <condition_variable>
- #include <future>
- #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 <iostream>
- #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<Expel>, public ModuleBase
- {
- private:
- Expel(): ModuleBase(){
- this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_HIGHEST, false);
- InfoL;
- }
- public:
- using Ptr = std::shared_ptr<Expel>;
- ~Expel(){
- this->Destroy();
- }
- /**
- * @description: 获取Ptr
- * @return {*}
- */
- static std::shared_ptr<Expel> 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<RecDeviceCommand>} &nettyServerResultMsg
- * @return {*}
- */
- void sendDeviceMsgCallback(NettyServerResultMsg<RecDeviceCommand> &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<vector<std::string>>& 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<int> m_deviceIdList;
- list<ExpelDevice> m_deviceLists;
- private:
- /**
- * @description: 获取控制器
- * @param {*}
- * @return {*}
- */
- std::shared_ptr<ContorlGear> 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<ContorlGear>& deviceControl);
- /**
- * @description: Control
- * @param {*}
- * @return {*}
- */
- int32_t Control(std::shared_ptr<ContorlGear>& deviceControl, ExpelDevice& expelDevice, uint8_t* data, int& length, int type);
- protected:
- mutex m_mutex;
- std::shared_ptr<ThreadPool> pool = nullptr;
- };
- };
- #endif
|