SPAServer.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef SPASERVER_H
  2. #define SPASERVER_H
  3. #include "FromSuperBrain.h"
  4. #include "FromRedis.h"
  5. #include "ToEQMDataBase.h"
  6. /**
  7. * 安播辅助提示系统服务类
  8. *
  9. */
  10. class SPAServer
  11. {
  12. public:
  13. SPAServer();
  14. ~SPAServer();
  15. /* 启动服务 */
  16. void startServer();
  17. private:
  18. /* 从基础平台获取算法信息和设备信息的线程函数 */
  19. void threadFromSuperBrain();
  20. /* 处理算法信息,返回值为true,说明有改变,需要重新读取 */
  21. bool processAlgorithmInfo(std::vector<AlgorithmInfo> vecNewAlgInfo);
  22. /* 处理设备信息,传入新获取到的值,返回true需要更新本地数据缓存 */
  23. bool processDeviceInfo(std::vector<DeviceInfo> vecNewDevInfo);
  24. /* 对比算法信息现有的数据和新获取到的数据,取出要删除和添加的数据 */
  25. void compareAlgorithmInfo(const std::vector<AlgorithmInfo>& vecNewInfo, std::vector<AlgorithmInfo>& vecAlgUpdate, std::vector<AlgorithmInfo>& vecAlgDelete);
  26. /* 对比设备和算法关联表是否需要更新 */
  27. void compareDeviceAlgorithmInfo(const std::vector<DeviceInfo>& vecNewInfo, std::vector<DeviceInfo>& vecDevUpdate);
  28. /* 从Redis获取数据线程函数,这个是摄像机线程 */
  29. void threadFromRedis(const CameraThreadInfo& info);
  30. /* 解析Redis基础数据 */
  31. void parseRedisData(const std::string& strData, AlarmInfo& alarmInfo);
  32. /* 判断时间是否长时间没有更新 */
  33. bool isEventTimeVaild(const std::string& strTime);
  34. /* 刷新房间和摄像机关联的线程 */
  35. void threadRoomCamera();
  36. /* 查找算法ID是否已在列表中 */
  37. RoomActionInfo* findActionIDInList(const int RoomID, const std::string& strActionID);
  38. /* 判断相机是否有这个算法 */
  39. bool isCameraHasAction(const int CameraID, const std::string& strActionID);
  40. private:
  41. std::shared_ptr<spdlog::logger> m_logger = nullptr;
  42. bool m_threadRunning = true; /* 线程正在运行 */
  43. FromSuperBrain m_fromSuperBrain;
  44. ToEQMDataBase m_toEQMDataBase;
  45. std::string m_keyContraband; /* 违禁品检测的Key,这个Key后面可能随时会变动 */
  46. std::string m_KeyFace; /* 人脸检测的Key */
  47. std::string ActPersonWork; /* 人员在岗识别 */
  48. std::string ActContraband; /* 违禁品检测 */
  49. std::string ActIllegalInvasion; /* 非法入侵检测 */
  50. std::string ActFatigueDetection; /* 疲劳检测 */
  51. std::string ActPersonNumber; /* 区域人员检测 */
  52. /* 算法信息,这个就是tAction在内存中的数据,方便后续对比,程序启动的时候会先获取一份 */
  53. std::vector<AlgorithmInfo> m_vecEqmAlgInfo;
  54. /* 设备信息,这个是tActionCamer的信息 */
  55. std::vector<DeviceInfo> m_vecEqmDevInfo;
  56. /* 摄像机ID和算法ID对应表 */
  57. std::mutex m_mutexCameraActionID;
  58. std::multimap<int, std::string> m_mapCameraActionID;
  59. /* 设备和算法关联信息,这里存储着已经删除的设备对应的算法信息,将在这一轮循环中删除 */
  60. std::list<int> m_listDevIDDelete;
  61. /* 房间和算法关联的信息,包含所需要的摄像机ID */
  62. std::mutex m_mutexRoomCameraInfo;
  63. std::list<RoomActionInfo*> m_listRoomCameraInfo;
  64. };
  65. #endif /* SPASERVER_H */