GlobalVariable.cpp 20 KB

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