Manager.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-01-11 11:47:37
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-01-18 09:58:52
  8. */
  9. #pragma once
  10. #include <iostream>
  11. #include <iostream>
  12. #include <map>
  13. #include <time.h>
  14. #include <dirent.h>
  15. #include <time.h>
  16. #include <cstdlib>
  17. #include <dirent.h>
  18. #include <sys/types.h>
  19. #include <sys/stat.h>
  20. #include <unistd.h>
  21. #include "Util/logger.h"
  22. #include "Util/NoticeCenter.h"
  23. #include "Poller/EventPoller.h"
  24. #include "Player/PlayerProxy.h"
  25. #include "Rtmp/RtmpPusher.h"
  26. #include "Common/config.h"
  27. #include "Pusher/MediaPusher.h"
  28. #include "Extension/Frame.h"
  29. #include "Util/SqlPool.h"
  30. #include "Network/TcpClient.h"
  31. #include "Poller/Timer.h"
  32. #include "monitor.h"
  33. #include "Notices.h"
  34. #include "inference.h"
  35. #include "deviceState.h"
  36. using namespace toolkit;
  37. using namespace std;
  38. namespace MIVA{
  39. class Manager
  40. {
  41. private:
  42. int MemoryThreshold;
  43. int TempThreshold;
  44. int FdThreshold;
  45. int ResetThreshold = 100;
  46. bool ResetSwitch = false;
  47. int TimeoutThreshold = 3;
  48. private:
  49. /**
  50. * @description: 获取fd的判定结果
  51. * @param {*}
  52. * @return {*}
  53. */
  54. bool decideFdResult();
  55. /**
  56. * @description: 获取内存的判定结果
  57. * @param {*}
  58. * @return {*}
  59. */
  60. bool decideMemoryResult();
  61. /**
  62. * @description: 获取温度判定结果
  63. * @param {*}
  64. * @return {*}
  65. */
  66. bool decideTempResult();
  67. /**
  68. * @description: 判定播放的结果
  69. * @param {*}
  70. * @return {*}
  71. */
  72. bool decidePlayResult();
  73. /**
  74. * @description: 获取重置的判定结果
  75. * @param {*}
  76. * @return {*}
  77. */
  78. bool decideResetResult();
  79. /**
  80. * @description: 获取超时的判定结果
  81. * @param {*}
  82. * @return {*}
  83. */
  84. bool decideTimeoutResult();
  85. public:
  86. Manager();
  87. ~Manager();
  88. /**
  89. * @description: 创建实例
  90. * @param {*}
  91. * @return {*}
  92. */
  93. static std::shared_ptr<Manager> CreateNew();
  94. /**
  95. * @description: 设置MemoryThreshold
  96. * @param {int} MemoryThreshold
  97. * @return {*}
  98. */
  99. void setMemoryThreshold(int memoryThreshold);
  100. /**
  101. * @description: 设置温度阈值
  102. * @param {int} TempThreshold
  103. * @return {*}
  104. */
  105. void setTempThreshold(int tempThreshold);
  106. /**
  107. * @description: 设置fd阈值
  108. * @param {int} fdThreshold
  109. * @return {*}
  110. */
  111. void setFdThreshold(int fdThreshold);
  112. /**
  113. * @description: 设置重启阈值
  114. * @param {int} resetThreshold
  115. * @return {*}
  116. */
  117. void setResetThreshold(int resetThreshold);
  118. /**
  119. * @description: 设置重启开关
  120. * @param {bool} resetSwich
  121. * @return {*}
  122. */
  123. void setResetSwitch(bool resetSwitch);
  124. /**
  125. * @description: 设置超时阈值
  126. * @param {int} timeoutThreshold
  127. * @return {*}
  128. */
  129. void setTimeoutThreshold(int timeoutThreshold);
  130. /**
  131. * @description: 纪律超时
  132. * @param {*}
  133. * @return {*}
  134. */
  135. void recordTimeOut();
  136. /**
  137. * @description: 清除超时
  138. * @param {*}
  139. * @return {*}
  140. */
  141. void clearRecordTimeOut();
  142. /**
  143. * @description: 获取启动资格
  144. * @param {*}
  145. * @return {*}
  146. */
  147. int32_t getStartPower();
  148. /**
  149. * @description: 获取停止的资格
  150. * @param {*}
  151. * @return {*}
  152. */
  153. int32_t getStopPower();
  154. /**
  155. * @description: 获取清理的资格
  156. * @param {*}
  157. * @return {*}
  158. */
  159. int32_t getClearPower();
  160. /**
  161. * @description: 获取同步数据的资格
  162. * @param {*}
  163. * @return {*}
  164. */
  165. int32_t getSyncDataPower();
  166. /**
  167. * @description: 获取上层数据的资格
  168. * @param {*}
  169. * @return {*}
  170. */
  171. int32_t getHostDataPower();
  172. /**
  173. * @description: 获取同步FdThreshold的资格
  174. * @param {*}
  175. * @return {*}
  176. */
  177. int32_t getSyncFdThresholdPower();
  178. /**
  179. * @description: 获取重启的资格
  180. * @param {*}
  181. * @return {*}
  182. */
  183. int32_t getResetPower();
  184. /**
  185. * @description: 重启
  186. * @param {*}
  187. * @return {*}
  188. */
  189. void Reset();
  190. public:
  191. using Ptr = std::shared_ptr<Manager>;
  192. };
  193. }