Manager.h 4.8 KB

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