123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- /***** (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 <iostream>
- #include <stdlib.h>
- #include <time.h>
- #include <stdio.h>
- #include <sys/types.h>
- #include <stdint.h>
- #include "md5.h"
- #include <sys/socket.h>
- #include <sys/mman.h>
- #include <sys/shm.h>
- #include <sys/stat.h>
- #include <sys/un.h>
- #include <sys/wait.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <iostream>
- #include <memory>
- #include <string>
- #include <vector>
- #include <stdio.h>
- #include <stdlib.h>
- #include <list>
- #include <thread>
- #include <rapidjson/document.h>
- #include <rapidjson/rapidjson.h>
- #include <rapidjson/stringbuffer.h>
- #include <rapidjson/writer.h>
- #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 <mutex>
- #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<Expel> getPtr();
- /**
- * @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);
- list<int> m_deviceIdList;
- list<ExpelDevice> m_deviceLists;
- mutex m_mutex;
- private:
- /**
- * @description: 获取控制器
- * @param {*}
- * @return {*}
- */
- std::shared_ptr<deviceBase> 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<deviceBase>& deviceControl);
- /**
- * @description: Control
- * @param {*}
- * @return {*}
- */
- int32_t Control(std::shared_ptr<deviceBase>& deviceControl, ExpelDevice& expelDevice, uint8_t* data, int& length, int type);
- };
- #endif
- /******** (C) Copyright, Shenzhen SUNWIN Intelligent Co.,Ltd. ******** End *****/
|