SATDevices.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef __SAT_QUERIER__
  2. #define __SAT_QUERIER__
  3. #pragma once
  4. #include "CritSection.h"
  5. #include "SATProtocol.h"
  6. namespace SATDEV{
  7. // 设备类型;
  8. enum DEVICE_TYPE{
  9. Virtual,
  10. Usb,
  11. Reticle
  12. };
  13. // 设备状态;
  14. enum DEVICE_STATUS{
  15. Online,
  16. Offline,
  17. Dropline
  18. };
  19. // 设备使用状态;
  20. enum DEVICE_USAGE_STATUS{
  21. Idle,
  22. InUse
  23. };
  24. // 设备信息;
  25. typedef struct __DEVICE__ {
  26. int nType; // 0=虚拟, 1=usb, 2=网线;
  27. std::string strName; // 设备名称(IP:端口号);
  28. // 离线时刻:超过指定时长删除该设备,线程实时刷新离线时刻;
  29. ULONGLONG ulOfflineTime;
  30. int nStatus; // 设备状态:0=在线,1=offline, 2=掉线(drop line);
  31. int nUsageState; // 设备使用状态:0=空闲,1=使用;
  32. }STDevice, *pSTDevice;
  33. // 安卓设备adb连接:USB连接、网线连接;
  34. typedef struct __DEVICE_INFO__ {
  35. STDevice dev;
  36. //////////////////////////////////////////////////////////////////////////
  37. // 附加项;
  38. int nStatus; // 设备状态:0表示空闲,1表示繁忙;
  39. std::string strSoftVersion; // 软件版本;
  40. std::string strModel; // 软件模型;
  41. std::string strHardVersion; // 硬件版本;
  42. std::string strManu; // 软件菜单;
  43. }STDeviceInfo, *pSTDeviceInfo;
  44. }
  45. class CSATDevices
  46. {
  47. CSATDevices(void);
  48. public:
  49. // 单例对象模式;
  50. static CSATDevices* GetInstance()
  51. {
  52. static CSATDevices* pInstance = NULL;
  53. if ( pInstance == NULL )
  54. {
  55. pInstance = new CSATDevices;
  56. }
  57. return pInstance;
  58. }
  59. ~CSATDevices(void);
  60. protected:
  61. // 线程控制句柄;
  62. HANDLE m_hEvent;
  63. // 线程句柄;
  64. HANDLE m_hWorkThread;
  65. // 是否启动安卓设备;
  66. static bool s_bEnableAndroid;
  67. // 离线擦除时长,单位毫秒;
  68. static ULONGLONG s_ulEraseDuration;
  69. // 线程锁;
  70. static ThreadSection s_ThreadSection;
  71. // 安卓设备列表;
  72. static std::vector<SATDEV::STDevice> s_vtDevices;
  73. // 其他接口;
  74. public:
  75. // 工作开始函数;
  76. void StartWork();
  77. // 工作结束函数;
  78. void EndofWork();
  79. // 工作线程;
  80. static DWORD WINAPI WorkThread(LPVOID lpVoid);
  81. const std::vector<SATDEV::STDevice>& GetDeviceList() const {return s_vtDevices;};
  82. // 删除设备;
  83. static void DelDevices(std::string name);
  84. // 添加网线连接设备;
  85. static void AddReticleDevices(std::string ip);
  86. static void AddVirtualDevices(std::string name);
  87. // 设备是否存在;
  88. static bool IsDeviceExist(SATDEV::STDevice &stDevice);
  89. // 设备是否下线;
  90. static bool IsDevicesOffline(SATDEV::STDevice &stDevice, std::vector<SATDEV::STDevice> &vtDevices);
  91. // 是否新设备;
  92. static bool IsNewDevices(SATDEV::STDevice &stDevice);
  93. // 获取当前设备列表;
  94. static void GetCurrentDevices(std::vector<SATDEV::STDevice> &vtDevices);
  95. // 重连所有设备;
  96. static void ReConnectAllDevices();
  97. // 设置设备使用状态;
  98. static void SetDeviceUsageStatus(std::string strDevName, SATDEV::DEVICE_USAGE_STATUS status);
  99. // 附加设备名到缓存中;
  100. static int AttachDeviceName2Buffer(SATPROTO::Device (&pbuff)[30]);
  101. };
  102. #endif // __SAT_QUERIER__