123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef __SAT_QUERIER__
- #define __SAT_QUERIER__
- #pragma once
- #include "CritSection.h"
- #include "SATProtocol.h"
- namespace SATDEV{
- // 设备类型;
- enum DEVICE_TYPE{
- Virtual,
- Usb,
- Reticle
- };
- // 设备状态;
- enum DEVICE_STATUS{
- Online,
- Offline,
- Dropline
- };
- // 设备使用状态;
- enum DEVICE_USAGE_STATUS{
- Idle,
- InUse
- };
- // 设备信息;
- typedef struct __DEVICE__ {
- int nType; // 0=虚拟, 1=usb, 2=网线;
- std::string strName; // 设备名称(IP:端口号);
- // 离线时刻:超过指定时长删除该设备,线程实时刷新离线时刻;
- ULONGLONG ulOfflineTime;
- int nStatus; // 设备状态:0=在线,1=offline, 2=掉线(drop line);
- int nUsageState; // 设备使用状态:0=空闲,1=使用;
- }STDevice, *pSTDevice;
- // 安卓设备adb连接:USB连接、网线连接;
- typedef struct __DEVICE_INFO__ {
- STDevice dev;
- //////////////////////////////////////////////////////////////////////////
- // 附加项;
- int nStatus; // 设备状态:0表示空闲,1表示繁忙;
- std::string strSoftVersion; // 软件版本;
- std::string strModel; // 软件模型;
- std::string strHardVersion; // 硬件版本;
- std::string strManu; // 软件菜单;
- }STDeviceInfo, *pSTDeviceInfo;
- }
- class CSATDevices
- {
- CSATDevices(void);
- public:
- // 单例对象模式;
- static CSATDevices* GetInstance()
- {
- static CSATDevices* pInstance = NULL;
- if ( pInstance == NULL )
- {
- pInstance = new CSATDevices;
- }
- return pInstance;
- }
- ~CSATDevices(void);
- protected:
- // 线程控制句柄;
- HANDLE m_hEvent;
- // 线程句柄;
- HANDLE m_hWorkThread;
- // 是否启动安卓设备;
- static bool s_bEnableAndroid;
- // 离线擦除时长,单位毫秒;
- static ULONGLONG s_ulEraseDuration;
- // 线程锁;
- static ThreadSection s_ThreadSection;
- // 安卓设备列表;
- static std::vector<SATDEV::STDevice> s_vtDevices;
- // 其他接口;
- public:
- // 工作开始函数;
- void StartWork();
- // 工作结束函数;
- void EndofWork();
- // 工作线程;
- static DWORD WINAPI WorkThread(LPVOID lpVoid);
- const std::vector<SATDEV::STDevice>& GetDeviceList() const {return s_vtDevices;};
- // 删除设备;
- static void DelDevices(std::string name);
- // 添加网线连接设备;
- static void AddReticleDevices(std::string ip);
- static void AddVirtualDevices(std::string name);
- // 设备是否存在;
- static bool IsDeviceExist(SATDEV::STDevice &stDevice);
- // 设备是否下线;
- static bool IsDevicesOffline(SATDEV::STDevice &stDevice, std::vector<SATDEV::STDevice> &vtDevices);
- // 是否新设备;
- static bool IsNewDevices(SATDEV::STDevice &stDevice);
- // 获取当前设备列表;
- static void GetCurrentDevices(std::vector<SATDEV::STDevice> &vtDevices);
- // 重连所有设备;
- static void ReConnectAllDevices();
- // 设置设备使用状态;
- static void SetDeviceUsageStatus(std::string strDevName, SATDEV::DEVICE_USAGE_STATUS status);
- // 附加设备名到缓存中;
- static int AttachDeviceName2Buffer(SATPROTO::Device (&pbuff)[30]);
- };
- #endif // __SAT_QUERIER__
|