GlobalVariable.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. #include "GlobalVariable.h"
  2. #include "spdlog/spdlog.h"
  3. // #include "FuncBase.h"
  4. /* ====================================================================================
  5. * ******************************* 全局变量定义 **********************************
  6. * ====================================================================================*/
  7. int g_eventTimeVaild = 600; /* 事件时间有效性,单位秒,超过这个时间就认为是无效数据 */
  8. /* ====================================================================================
  9. * *************************** DeviceInfo成员函数 *******************************
  10. * ====================================================================================*/
  11. DeviceInfo::DeviceInfo(const DeviceInfo& other)
  12. : PKID(other.PKID),
  13. DeviceID(other.DeviceID),
  14. DevicePort(other.DevicePort),
  15. DeviceName(other.DeviceName),
  16. DeviceSerial(other.DeviceSerial),
  17. DeviceType(other.DeviceType),
  18. DeviceIP(other.DeviceIP),
  19. UserAccount(other.UserAccount),
  20. UserPassword(other.UserPassword),
  21. vecAlgorithmInfo(other.vecAlgorithmInfo)
  22. {}
  23. DeviceInfo& DeviceInfo::operator=(const DeviceInfo& other)
  24. {
  25. if (this != &other) {
  26. DeviceID = other.DeviceID;
  27. DevicePort = other.DevicePort;
  28. DeviceName = other.DeviceName;
  29. DeviceSerial = other.DeviceSerial;
  30. DeviceType = other.DeviceType;
  31. DeviceIP = other.DeviceIP;
  32. UserAccount = other.UserAccount;
  33. UserPassword = other.UserPassword;
  34. vecAlgorithmInfo = other.vecAlgorithmInfo;
  35. }
  36. return *this;
  37. }
  38. /* 对比是否相等 */
  39. bool DeviceInfo::operator==(const DeviceInfo& other)
  40. {
  41. if(DeviceID != other.DeviceID) {
  42. return false;
  43. }
  44. else if(DeviceName != other.DeviceName || DeviceIP != other.DeviceIP) {
  45. return false;
  46. }
  47. else if(DeviceSerial != other.DeviceSerial || DeviceType != other.DeviceType) {
  48. return false;
  49. }
  50. else if(DevicePort != other.DevicePort || UserAccount != other.UserAccount || UserPassword != other.UserPassword) {
  51. return false;
  52. }
  53. return true;
  54. }
  55. /* 对比设备关联的算法信息是否相等 */
  56. bool DeviceInfo::isEqualAlgorithmInfo(const std::vector<AlgorithmInfo>& other)
  57. {
  58. /* 算法数目不相等,直接返回false */
  59. if(vecAlgorithmInfo.size() != other.size()) {
  60. return false;
  61. }else {
  62. /* 算法数目相等,进一步对比算法信息 */
  63. bool isEquality = true;
  64. /* 逐步对比算法信息 */
  65. for(const auto& it0 : vecAlgorithmInfo) {
  66. bool isEq2 = true;
  67. for(const auto& it1 : other) {
  68. if(it0 == it1) {
  69. continue;
  70. }else {
  71. isEq2 = false;
  72. break;
  73. }
  74. }
  75. if(!isEq2) {
  76. isEquality = false;
  77. break;
  78. }
  79. }
  80. if(!isEquality) {
  81. return false;
  82. }
  83. }
  84. return true;
  85. }
  86. DetectPeriodInfo::DetectPeriodInfo()
  87. {
  88. ChannelID = 0;
  89. appFunction = AppFunction::APP_NONE;
  90. PeriodName = "";
  91. PeriodType = Enum_PeriodType::PERIOD_ALL;
  92. listWeekTime.clear();
  93. lastTime = QDateTime::fromString("1970-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  94. }
  95. DetectPeriodInfo::DetectPeriodInfo(const DetectPeriodInfo& other)
  96. {
  97. ChannelID = other.ChannelID;
  98. appFunction = other.appFunction;
  99. PeriodName = other.PeriodName;
  100. PeriodType = other.PeriodType;
  101. listWeekTime = other.listWeekTime;
  102. lastTime = other.lastTime;
  103. }
  104. DetectPeriodInfo& DetectPeriodInfo::operator=(const DetectPeriodInfo& other)
  105. {
  106. if (this != &other) {
  107. ChannelID = other.ChannelID;
  108. appFunction = other.appFunction;
  109. PeriodName = other.PeriodName;
  110. PeriodType = other.PeriodType;
  111. listWeekTime = other.listWeekTime;
  112. lastTime = other.lastTime;
  113. }
  114. return *this;
  115. }
  116. /* ====================================================================================
  117. * ******************************* 各种报警信息 **********************************
  118. * ====================================================================================*/
  119. AlarmInfo::AlarmInfo()
  120. {
  121. Is_Alarm = false;
  122. Is_InsertEQM = false;
  123. Is_OnWork = false;
  124. PKID = 0;
  125. AlarmID = 0;
  126. DeviceID = 0;
  127. RoomID = 0;
  128. ChannelID = 0;
  129. State = 0;
  130. OnWork = 0;
  131. StartTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  132. EndTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  133. EventTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  134. // PicUrl = "";
  135. ImageInfo = "";
  136. // AppID = "";
  137. ActionID = "";
  138. ActionDes = "";
  139. FaceIDList = "";
  140. FaceNameList = "";
  141. listBbox.clear();
  142. listPersonInfo.clear();
  143. appFunction = AppFunction::APP_NONE;
  144. }
  145. AlarmInfo::AlarmInfo(const AlarmInfo& other)
  146. {
  147. Is_Alarm = other.Is_Alarm;
  148. Is_InsertEQM = other.Is_InsertEQM;
  149. Is_OnWork = other.Is_OnWork;
  150. PKID = other.PKID;
  151. AlarmID = other.AlarmID;
  152. DeviceID = other.DeviceID;
  153. RoomID = other.RoomID;
  154. ChannelID = other.ChannelID;
  155. State = other.State;
  156. OnWork = other.OnWork;
  157. StartTime = other.StartTime;
  158. EndTime = other.EndTime;
  159. EventTime = other.EventTime;
  160. // PicUrl = other.PicUrl;
  161. ImageInfo = other.ImageInfo;
  162. // AppID = other.AppID;
  163. ActionID = other.ActionID;
  164. ActionDes = other.ActionDes;
  165. FaceIDList = other.FaceIDList;
  166. FaceNameList = other.FaceNameList;
  167. listBbox = other.listBbox;
  168. listPersonInfo = other.listPersonInfo;
  169. appFunction = other.appFunction;
  170. }
  171. AlarmInfo& AlarmInfo::operator=(AlarmInfo& other)
  172. {
  173. if(this != &other)
  174. {
  175. Is_Alarm = other.Is_Alarm;
  176. Is_InsertEQM = other.Is_InsertEQM;
  177. Is_OnWork = other.Is_OnWork;
  178. PKID = other.PKID;
  179. AlarmID = other.AlarmID;
  180. DeviceID = other.DeviceID;
  181. RoomID = other.RoomID;
  182. ChannelID = other.ChannelID;
  183. State = other.State;
  184. OnWork = other.OnWork;
  185. StartTime = other.StartTime;
  186. EndTime = other.EndTime;
  187. EventTime = other.EventTime;
  188. // PicUrl = other.PicUrl;
  189. ImageInfo = other.ImageInfo;
  190. // AppID = other.AppID;
  191. ActionID = other.ActionID;
  192. ActionDes = other.ActionDes;
  193. FaceIDList = other.FaceIDList;
  194. FaceNameList = other.FaceNameList;
  195. listBbox = other.listBbox;
  196. listPersonInfo = other.listPersonInfo;
  197. appFunction = other.appFunction;
  198. }
  199. return *this;
  200. }
  201. /* 清空内容 */
  202. void AlarmInfo::reInit()
  203. {
  204. Is_Alarm = false;
  205. Is_InsertEQM = false;
  206. Is_OnWork = false;
  207. PKID = 0;
  208. AlarmID = 0;
  209. DeviceID = 0;
  210. RoomID = 0;
  211. ChannelID = 0;
  212. State = 0;
  213. OnWork = 0;
  214. StartTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  215. EndTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  216. EventTime = QDateTime::fromString("2000-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  217. // PicUrl = "";
  218. ImageInfo = "";
  219. // AppID = "";
  220. ActionID = "";
  221. ActionDes = "";
  222. FaceIDList = "";
  223. FaceNameList = "";
  224. listBbox.clear();
  225. listPersonInfo.clear();
  226. appFunction = AppFunction::APP_NONE;
  227. }
  228. /* 获取人脸列表 */
  229. std::string AlarmInfo::getFaceIDListString()
  230. {
  231. std::string strFaceList = "";
  232. for(auto& it : listPersonInfo)
  233. {
  234. if(it.PersonID.size() < 0)
  235. {
  236. continue;
  237. }
  238. strFaceList += it.PersonID + ";" ;
  239. }
  240. /* 去掉最后的“;” */
  241. if(strFaceList.size() > 0)
  242. {
  243. strFaceList = strFaceList.substr(0, strFaceList.size() - 1);
  244. }
  245. return strFaceList;
  246. }
  247. /* 获取人脸名称列表 */
  248. std::string AlarmInfo::getFaceNameListString()
  249. {
  250. std::string strFaceName;
  251. for(auto& it : listPersonInfo)
  252. {
  253. if(it.PersonName.size() < 0)
  254. {
  255. continue;
  256. }
  257. strFaceName += it.PersonName + ";";
  258. }
  259. /* 去掉最后的“;” */
  260. if(strFaceName.size() > 0)
  261. {
  262. strFaceName = strFaceName.substr(0, strFaceName.size() - 1);
  263. }
  264. return strFaceName;
  265. }
  266. /**
  267. * @brief 添加报警信息
  268. *
  269. * @param info
  270. * @return true
  271. * @return false
  272. */
  273. bool ListAlarmInfo::addAlarmInfo(AlarmInfo& info)
  274. {
  275. /* 先查找有没有重复的 */
  276. auto p = findAlarmInfo(info);
  277. if(p != nullptr)
  278. {
  279. return false;
  280. }
  281. AlarmInfo* pNew = new AlarmInfo(info);
  282. listAlarmInfo.push_back(pNew);
  283. return true;
  284. }
  285. /**
  286. * @brief 检查列表中是是否有这个报警信息,这里只检查ChannelID、RoomID、CameraID、ActionID是否相等
  287. *
  288. * @param info
  289. * @return AlarmInfo*
  290. */
  291. AlarmInfo* ListAlarmInfo::findAlarmInfo(AlarmInfo& info)
  292. {
  293. for(auto& it0 : listAlarmInfo)
  294. {
  295. if(it0->ChannelID == info.ChannelID && it0->RoomID == info.RoomID && it0->DeviceID == info.DeviceID && it0->ActionID == info.ActionID)
  296. {
  297. return it0;
  298. }
  299. }
  300. return nullptr;
  301. }
  302. /* 删除报警记录 */
  303. void ListAlarmInfo::deleteAlarmInfo(AlarmInfo& info)
  304. {
  305. for(auto it = listAlarmInfo.begin(); it != listAlarmInfo.end();)
  306. {
  307. if((*it)->ChannelID == info.ChannelID && (*it)->RoomID == info.RoomID && (*it)->DeviceID == info.DeviceID && (*it)->ActionID == info.ActionID)
  308. {
  309. delete *it;
  310. it = listAlarmInfo.erase(it);
  311. }else {
  312. ++it;
  313. }
  314. }
  315. }
  316. /* 清空报警记录 */
  317. void ListAlarmInfo::clearAlarmInfo()
  318. {
  319. for(auto& it : listAlarmInfo)
  320. {
  321. delete it;
  322. }
  323. listAlarmInfo.clear();
  324. }
  325. /* 查找是否有相同的人脸信息 */
  326. bool RoomFaceInfo::findPersonInfo(const PersonInfo& info)
  327. {
  328. for(auto& it0 : listPersonInfo)
  329. {
  330. if(it0.PersonID == info.PersonID && it0.PersonName == info.PersonName)
  331. {
  332. return true;
  333. }
  334. }
  335. return false;
  336. }
  337. /* 添加房间人脸信息 */
  338. void ListRoomFaceInfo::addRoomFaceInfo(RoomFaceInfo& info)
  339. {
  340. /* 先查找有没有重复的 */
  341. auto p = findRoomFaceInfo(info);
  342. if(p != nullptr)
  343. {
  344. return;
  345. }
  346. listRoomFaceInfo.push_back(info);
  347. }
  348. /**
  349. * @brief 通过报警信息添加人脸信息
  350. *
  351. * @param info
  352. */
  353. void ListRoomFaceInfo::addRoomFaceInfo(AlarmInfo& info)
  354. {
  355. auto p = findRoomFaceInfo(info.ChannelID, info.RoomID, info.DeviceID);
  356. if(p == nullptr)
  357. {
  358. RoomFaceInfo rfi;
  359. rfi.ChannelID = info.ChannelID;
  360. rfi.RoomID = info.RoomID;
  361. rfi.CameraID = info.DeviceID;
  362. rfi.MaxNum = 0;
  363. rfi.MinNum = 0;
  364. rfi.StartTime = QDateTime::currentDateTime();
  365. listRoomFaceInfo.push_back(rfi);
  366. }
  367. /* 将人员信息加入到列表中,添加时会先查找有没有相同的信息 */
  368. for(auto& it0 : info.listPersonInfo)
  369. {
  370. if(!p->findPersonInfo(it0))
  371. {
  372. p->listPersonInfo.push_back(it0);
  373. }
  374. }
  375. }
  376. RoomFaceInfo* ListRoomFaceInfo::findRoomFaceInfo(RoomFaceInfo& info)
  377. {
  378. for(auto& it0 : listRoomFaceInfo)
  379. {
  380. if(it0.ChannelID == info.ChannelID && it0.RoomID == info.RoomID && it0.CameraID == info.CameraID)
  381. {
  382. return &it0;
  383. }
  384. }
  385. return nullptr;
  386. }
  387. /* 查找有没有相同的结构 */
  388. RoomFaceInfo* ListRoomFaceInfo::findRoomFaceInfo(int ChannelID, int RoomID, int CameraID)
  389. {
  390. for(auto& it0 : listRoomFaceInfo)
  391. {
  392. if(it0.ChannelID == ChannelID && it0.RoomID == RoomID && it0.CameraID == CameraID)
  393. {
  394. return &it0;
  395. }
  396. }
  397. return nullptr;
  398. }
  399. /* ====================================================================================
  400. * ************************** ListActionInfo成员函数 ****************************
  401. * ====================================================================================*/
  402. ActionInfo::ActionInfo()
  403. {
  404. RunState = RunTimeState::RUN_STATE_INIT;
  405. ChannelID = -1;
  406. RoomID = -1;
  407. CameraID = -1;
  408. RoomType = Enum_RoomType::ROOM_NONE;
  409. ActionID = "";
  410. strRoomName = "";
  411. strActionName = "";
  412. }
  413. ActionInfo& ActionInfo::operator=(const ActionInfo& other)
  414. {
  415. if (this != &other)
  416. {
  417. ChannelID = other.ChannelID;
  418. RoomID = other.RoomID;
  419. CameraID = other.CameraID;
  420. ActionID = other.ActionID;
  421. strRoomName = other.strRoomName;
  422. RoomType = other.RoomType;
  423. }
  424. return *this;
  425. }
  426. bool ActionInfo::operator==(const ActionInfo& other)
  427. {
  428. if(ChannelID != other.ChannelID) {
  429. return false;
  430. }
  431. if(RoomID != other.RoomID) {
  432. return false;
  433. }
  434. if(CameraID != other.CameraID) {
  435. return false;
  436. }
  437. if(ActionID != other.ActionID) {
  438. return false;
  439. }
  440. if(RoomType != other.RoomType) {
  441. return false;
  442. }
  443. return true;
  444. }
  445. /* 对比除摄像机外的基础信息是否相等 */
  446. bool ActionInfo::isEqualBaseInfo(const ActionInfo& other)
  447. {
  448. if(ChannelID != other.ChannelID) {
  449. return false;
  450. }
  451. if(RoomID != other.RoomID) {
  452. return false;
  453. }
  454. if(ActionID != other.ActionID) {
  455. return false;
  456. }
  457. if(RoomType != other.RoomType) {
  458. return false;
  459. }
  460. return true;
  461. }
  462. /* 添加关联信息,会自动进行重复判断,如果已有相同的信息,则跳过 */
  463. bool ListActionInfo::insertActionInfo(ActionInfo* info)
  464. {
  465. /* 先判断是否已经在列表中了 */
  466. if(findActionInList(info) == nullptr)
  467. {
  468. ActionInfo* pActionInfo = new ActionInfo;
  469. *pActionInfo = *info;
  470. listActionInfo.push_back(pActionInfo);
  471. }
  472. return true;
  473. }
  474. /* 删除信息 */
  475. bool ListActionInfo::deleteActionInfo(ActionInfo* info)
  476. {
  477. if(info == nullptr)
  478. {
  479. return false;
  480. }
  481. if(findActionInList(info) != nullptr)
  482. {
  483. listActionInfo.remove(info);
  484. delete info;
  485. info = nullptr;
  486. }
  487. return true;
  488. }
  489. /* 给算法添加摄像机,原有的会被替换掉 */
  490. bool ListActionInfo::addActionCamera(ActionInfo* pInfo)
  491. {
  492. auto pActionInfo = findActionIDInListNoCamera(pInfo);
  493. if(pActionInfo != nullptr)
  494. {
  495. pActionInfo->CameraID = pInfo->CameraID;
  496. }
  497. return true;
  498. }
  499. /* 清空算法中的摄像机信息 */
  500. void ListActionInfo::clearCameraList()
  501. {
  502. for(auto& it0 : listActionInfo)
  503. {
  504. it0->CameraID = -1;
  505. }
  506. }
  507. /* 清空设置成STOP或ERROR的Action */
  508. void ListActionInfo::clearStopAction()
  509. {
  510. for(auto it0 = listActionInfo.begin(); it0 != listActionInfo.end();)
  511. {
  512. if(( (*it0)->RunState == RunTimeState::RUN_STATE_STOP) || ((*it0)->RunState == RunTimeState::RUN_STATE_ERROR))
  513. {
  514. delete *it0;
  515. it0 = listActionInfo.erase(it0);
  516. }else {
  517. ++it0;
  518. }
  519. }
  520. }
  521. /* 查找算法ID是否已在列表中 */
  522. ActionInfo* ListActionInfo::findActionInList(ActionInfo* pInfo)
  523. {
  524. for(const auto& it0 : listActionInfo)
  525. {
  526. if(*it0 == *pInfo)
  527. {
  528. return it0;
  529. }
  530. }
  531. return nullptr;
  532. }
  533. /* 查找算法ID是否在列表中,这里查找不会对比摄像机ID */
  534. ActionInfo* ListActionInfo::findActionIDInListNoCamera(ActionInfo* pInfo)
  535. {
  536. for(const auto& it0 : listActionInfo)
  537. {
  538. if(it0->isEqualBaseInfo(*pInfo))
  539. {
  540. return it0;
  541. }
  542. }
  543. return nullptr;
  544. }
  545. /* 清空容器 */
  546. void ListActionInfo::clear()
  547. {
  548. for(auto& it0 : listActionInfo)
  549. {
  550. delete it0;
  551. it0 = nullptr;
  552. }
  553. listActionInfo.clear();
  554. }
  555. /* ====================================================================================
  556. * *********************** ListRoomActionInfo成员函数 ***************************
  557. * ====================================================================================*/
  558. /* 对比频道信息、房间信息、算法ID是否相等 */
  559. bool RoomActionInfo::isEqualBaseInfo(const RoomActionInfo& other)
  560. {
  561. if(ChannelID != other.ChannelID) {
  562. return false;
  563. }
  564. if(RoomID != other.RoomID) {
  565. return false;
  566. }
  567. if(ActionID != other.ActionID) {
  568. return false;
  569. }
  570. if(RoomType != other.RoomType) {
  571. return false;
  572. }
  573. return true;
  574. }
  575. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  576. bool ListRoomActionInfo::insertRoomActionInfo(const RoomActionInfo& info)
  577. {
  578. /* 先判断是否已经在列表中了 */
  579. if(findActionIDInList(info.ChannelID, info.RoomID, info.ActionID) == nullptr)
  580. {
  581. RoomActionInfo* pRoomActionInfo = new RoomActionInfo;
  582. *pRoomActionInfo = info;
  583. listRoomActionInfo.push_back(pRoomActionInfo);
  584. }
  585. return true;
  586. }
  587. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  588. bool ListRoomActionInfo::insertRoomActionInfo(const int ChannelID, const int RoomID, const std::string& strActionID)
  589. {
  590. /* 先判断是否已经在列表中了 */
  591. if(findActionIDInList(ChannelID, RoomID, strActionID) == nullptr)
  592. {
  593. RoomActionInfo* pRoomActionInfo = new RoomActionInfo;
  594. pRoomActionInfo->RoomID = RoomID;
  595. pRoomActionInfo->ActionID = strActionID;
  596. listRoomActionInfo.push_back(pRoomActionInfo);
  597. }
  598. return true;
  599. }
  600. /* 删除一个容器,注意,这个不能在别的for循环中删除,只能单独删除 */
  601. bool ListRoomActionInfo::deleteRoomActionInfo(RoomActionInfo* pInfo)
  602. {
  603. if(pInfo == nullptr)
  604. {
  605. return false;
  606. }
  607. for(auto it0 = listRoomActionInfo.begin(); it0 != listRoomActionInfo.end(); ++it0)
  608. {
  609. if(*it0 == pInfo)
  610. {
  611. listRoomActionInfo.erase(it0);
  612. delete pInfo;
  613. pInfo = nullptr;
  614. return true;
  615. }
  616. }
  617. return false;
  618. }
  619. /* 清空容器 */
  620. void ListRoomActionInfo::clear()
  621. {
  622. for(auto& it0 : listRoomActionInfo)
  623. {
  624. delete it0;
  625. it0 = nullptr;
  626. }
  627. listRoomActionInfo.clear();
  628. }
  629. /* 添加算法信息,根据传入的算法信息,自动将其加入到对应的容器中 */
  630. void ListRoomActionInfo::addActionInfo(const ActionInfo& info)
  631. {
  632. auto pRAInfo = findActionIDInList(info.ChannelID, info.RoomID, info.ActionID);
  633. if(pRAInfo != nullptr)
  634. {
  635. pRAInfo->listCameraID.push_back(info.CameraID);
  636. }else {
  637. RoomActionInfo* pRoomActionInfo = new RoomActionInfo;
  638. pRoomActionInfo->ChannelID = info.ChannelID;
  639. pRoomActionInfo->RoomID = info.RoomID;
  640. pRoomActionInfo->ActionID = info.ActionID;
  641. pRoomActionInfo->RoomType = info.RoomType;
  642. pRoomActionInfo->strRoomName = info.strRoomName;
  643. pRoomActionInfo->listCameraID.push_back(info.CameraID);
  644. listRoomActionInfo.push_back(pRoomActionInfo);
  645. }
  646. }
  647. /* 清空算法对应的摄像机列表 */
  648. void ListRoomActionInfo::clearCameraList()
  649. {
  650. for(auto& it0 : listRoomActionInfo)
  651. {
  652. it0->listCameraID.clear();
  653. }
  654. }
  655. /* 清理设置为STOP或者ERROR的RoomAction */
  656. // void ListRoomActionInfo::clearStopRoomAction()
  657. // {
  658. // for(auto it0 = listRoomActionInfo.begin(); it0 != listRoomActionInfo.end();)
  659. // {
  660. // if(( (*it0)->RunState == RunTimeState::RUN_STATE_STOP) || ((*it0)->RunState == RunTimeState::RUN_STATE_ERROR))
  661. // {
  662. // delete *it0;
  663. // it0 = listRoomActionInfo.erase(it0);
  664. // }else {
  665. // ++it0;
  666. // }
  667. // }
  668. // }
  669. /* 查找算法ID是否已在列表中 */
  670. RoomActionInfo* ListRoomActionInfo::findActionIDInList(const int chnID, const int RoomID, const std::string& strActionID)
  671. {
  672. for(const auto& it0 : listRoomActionInfo)
  673. {
  674. if((it0->RoomID == RoomID) && (it0->ActionID == strActionID) && (it0->ChannelID == chnID))
  675. {
  676. return it0;
  677. }
  678. }
  679. return nullptr;
  680. }
  681. RoomCamActInfo::RoomCamActInfo()
  682. {
  683. RoomID = -1;
  684. RoomType = Enum_RoomType::ROOM_NONE;
  685. strRoomName = "";
  686. mapCameraAction.clear();
  687. }
  688. RoomCamActInfo::RoomCamActInfo(const RoomCamActInfo& other) \
  689. {
  690. if (this != &other) {
  691. RoomID = other.RoomID;
  692. RoomType = other.RoomType;
  693. strRoomName = other.strRoomName;
  694. mapCameraAction = other.mapCameraAction;
  695. }
  696. }
  697. RoomCamActInfo& RoomCamActInfo::operator=(const RoomCamActInfo& other)
  698. {
  699. if (this != &other) {
  700. RoomID = other.RoomID;
  701. RoomType = other.RoomType;
  702. strRoomName = other.strRoomName;
  703. mapCameraAction = other.mapCameraAction;
  704. }
  705. return *this;
  706. }
  707. /* 添加摄像机算法 */
  708. void RoomCamActInfo::addCameraAction(int CameraID, const std::string& ActionID)
  709. {
  710. auto it = mapCameraAction.find(CameraID);
  711. if(it == mapCameraAction.end()) {
  712. std::list<std::string> list;
  713. list.push_back(ActionID);
  714. mapCameraAction.insert(std::make_pair(CameraID, list));
  715. }else {
  716. it->second.push_back(ActionID);
  717. }
  718. }