GlobalVariable.cpp 20 KB

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