Manager.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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-13 15:16:09
  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. private:
  48. /**
  49. * @description: 获取fd的判定结果
  50. * @param {*}
  51. * @return {*}
  52. */
  53. bool decideFdResult();
  54. /**
  55. * @description: 获取内存的判定结果
  56. * @param {*}
  57. * @return {*}
  58. */
  59. bool decideMemoryResult();
  60. /**
  61. * @description: 获取温度判定结果
  62. * @param {*}
  63. * @return {*}
  64. */
  65. bool decideTempResult();
  66. /**
  67. * @description: 判定播放的结果
  68. * @param {*}
  69. * @return {*}
  70. */
  71. bool decidePlayResult();
  72. /**
  73. * @description: 获取重置的判定结果
  74. * @param {*}
  75. * @return {*}
  76. */
  77. bool decideResetResult();
  78. public:
  79. Manager();
  80. ~Manager();
  81. /**
  82. * @description: 创建实例
  83. * @param {*}
  84. * @return {*}
  85. */
  86. static std::shared_ptr<Manager> CreateNew();
  87. /**
  88. * @description: 设置MemoryThreshold
  89. * @param {int} MemoryThreshold
  90. * @return {*}
  91. */
  92. void setMemoryThreshold(int memoryThreshold);
  93. /**
  94. * @description: 设置温度阈值
  95. * @param {int} TempThreshold
  96. * @return {*}
  97. */
  98. void setTempThreshold(int tempThreshold);
  99. /**
  100. * @description: 设置fd阈值
  101. * @param {int} fdThreshold
  102. * @return {*}
  103. */
  104. void setFdThreshold(int fdThreshold);
  105. /**
  106. * @description: 设置重启阈值
  107. * @param {int} resetThreshold
  108. * @return {*}
  109. */
  110. void setResetThreshold(int resetThreshold);
  111. /**
  112. * @description: 设置重启开关
  113. * @param {bool} resetSwich
  114. * @return {*}
  115. */
  116. void setResetSwitch(bool resetSwitch);
  117. /**
  118. * @description: 获取启动资格
  119. * @param {*}
  120. * @return {*}
  121. */
  122. int32_t getStartPower();
  123. /**
  124. * @description: 获取停止的资格
  125. * @param {*}
  126. * @return {*}
  127. */
  128. int32_t getStopPower();
  129. /**
  130. * @description: 获取清理的资格
  131. * @param {*}
  132. * @return {*}
  133. */
  134. int32_t getClearPower();
  135. /**
  136. * @description: 获取同步数据的资格
  137. * @param {*}
  138. * @return {*}
  139. */
  140. int32_t getSyncDataPower();
  141. /**
  142. * @description: 获取上层数据的资格
  143. * @param {*}
  144. * @return {*}
  145. */
  146. int32_t getHostDataPower();
  147. /**
  148. * @description: 获取同步FdThreshold的资格
  149. * @param {*}
  150. * @return {*}
  151. */
  152. int32_t getSyncFdThresholdPower();
  153. /**
  154. * @description: 获取重启的资格
  155. * @param {*}
  156. * @return {*}
  157. */
  158. int32_t getResetPower();
  159. /**
  160. * @description: 重启
  161. * @param {*}
  162. * @return {*}
  163. */
  164. void Reset();
  165. public:
  166. using Ptr = std::shared_ptr<Manager>;
  167. };
  168. }