123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #ifndef SPASERVER_H
- #define SPASERVER_H
- #include "FromSuperBrain.h"
- #include "FromRedis.h"
- #include "ToEQMDataBase.h"
- /**
- * 安播辅助提示系统服务类
- *
- */
- class SPAServer
- {
- public:
- SPAServer();
- ~SPAServer();
- /* 启动服务 */
- void startServer();
- private:
- /* 从基础平台获取算法信息和设备信息的线程函数 */
- void threadFromSuperBrain();
- /* 处理算法信息,返回值为true,说明有改变,需要重新读取 */
- bool processAlgorithmInfo(std::vector<AlgorithmInfo> vecNewAlgInfo);
- /* 处理设备信息,传入新获取到的值,返回true需要更新本地数据缓存 */
- bool processDeviceInfo(std::vector<DeviceInfo> vecNewDevInfo);
- /* 对比算法信息现有的数据和新获取到的数据,取出要删除和添加的数据 */
- void compareAlgorithmInfo(const std::vector<AlgorithmInfo>& vecNewInfo, std::vector<AlgorithmInfo>& vecAlgUpdate, std::vector<AlgorithmInfo>& vecAlgDelete);
- /* 对比设备和算法关联表是否需要更新 */
- void compareDeviceAlgorithmInfo(const std::vector<DeviceInfo>& vecNewInfo, std::vector<DeviceInfo>& vecDevUpdate);
- /* 从Redis获取数据线程函数,这个是摄像机线程 */
- void threadFromRedis(const CameraThreadInfo& info);
- /* 解析Redis基础数据 */
- void parseRedisData(const std::string& strData, AlarmInfo& alarmInfo);
- /* 判断时间是否长时间没有更新 */
- bool isEventTimeVaild(const std::string& strTime);
- /* 分派任务的线程 */
- void threadRoomCamera();
- /* 将该算法对应的摄像机放入摄像机列表 */
- bool insertCameraToAction(RoomActionInfo* pRAInfo, std::list<RoomCameraInfo>& listRC, std::multimap<int, std::string>& mapCameraActionID);
- /* 更新房间、算法需要的摄像机个数 */
- bool updateRoomActionCameraCount(std::shared_ptr<RoomActionInfo> pRAInfo);
- /* 更新算法的摄像机ID */
- bool updateActionCameraID(std::shared_ptr<ActionInfo> pInfo);
- /* 设置线程状态 */
- void setThreadState(std::shared_ptr<ActionInfo> pInfo, RunTimeState state);
-
- /* 人员在岗识别线程,应该是人脸识别线程,这个需要房间内多个摄像机共同识别 */
- void threadActPersonWork(RoomActionInfo* RAInfo);
- /* 区域人员检测,检测这个区域内的人数,不能少于多少人,不能多余多少人 */
- void threadActPersonNumber(RoomActionInfo* RAInfo);
- /* 违禁物品识别 */
- void threadActContraband(ActionInfo* info);
- /* 非法入侵检测 */
- void threadActIllegalInvasion(ActionInfo* info);
- private:
- std::shared_ptr<spdlog::logger> m_logger = nullptr;
- bool m_threadRunning = true; /* 线程正在运行 */
- FromSuperBrain m_fromSuperBrain;
- ToEQMDataBase m_toEQMDataBase;
- std::string m_keyContraband; /* 违禁品检测的Key,这个Key后面可能随时会变动 */
- std::string m_KeyFace; /* 人脸检测的Key */
- std::mutex m_mutexActionID; /* 算法ID的互斥锁 */
- std::string ActPersonWork; /* 人员在岗识别 */
- std::string ActPersonNumber; /* 区域人员检测 */
- std::string ActContraband; /* 违禁品检测 */
- std::string ActIllegalInvasion; /* 非法入侵检测 */
- std::string ActFatigueDetection; /* 疲劳检测 */
- /* 算法信息,这个就是tAction在内存中的数据,方便后续对比,程序启动的时候会先获取一份 */
- std::vector<AlgorithmInfo> m_vecEqmAlgInfo;
- /* 设备信息,这个是tActionCamer的信息 */
- std::vector<DeviceInfo> m_vecEqmDevInfo;
- /* 算法信息列表,每个算法所在的频率、房间、摄像机 */
- std::mutex m_mutexActionInfo;
- ListActionInfo m_listActionInfo;
- /* 设备和算法关联信息,这里存储着已经删除的设备对应的算法信息,将在这一轮循环中删除 */
- std::list<int> m_listDevIDDelete;
- /* 房间和算法关联的信息,包含所需要的摄像机ID */
- std::mutex m_mutexRunRAI;
- ListRoomActionInfo m_runListRoomActionInfo;
- /* 运行时的算法信息列表,这个容器存储的是不需要摄像机融合的算法 */
- std::mutex m_mutexRunActionInfo;
- ListActionInfo m_runListActionInfo;
- };
- #endif /* SPASERVER_H */
|