Manager.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-01-11 11:47:46
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-01-11 14:51:57
  8. */
  9. #include "Manager.h"
  10. namespace MIVA{
  11. std::shared_ptr<Manager> m_manager = nullptr;
  12. Manager::Manager(){
  13. }
  14. Manager::~Manager(){
  15. }
  16. /**
  17. * @description: 创建实例
  18. * @param {*}
  19. * @return {*}
  20. */
  21. std::shared_ptr<Manager> Manager::CreateNew(){
  22. if(m_manager == nullptr) m_manager = std::make_shared<Manager>();
  23. return m_manager;
  24. }
  25. /**
  26. * @description: 设置MemoryThreshold
  27. * @param {int} MemoryThreshold
  28. * @return {*}
  29. */
  30. void Manager::setMemoryThreshold(int memoryThreshold){
  31. this->MemoryThreshold = memoryThreshold;
  32. }
  33. /**
  34. * @description: 设置温度阈值
  35. * @param {int} TempThreshold
  36. * @return {*}
  37. */
  38. void Manager::setTempThreshold(int tempThreshold){
  39. this->TempThreshold = tempThreshold;
  40. }
  41. /**
  42. * @description: 获得启动资格
  43. * @param {*}
  44. * @return {*}
  45. */
  46. int32_t Manager::getStartPower(){
  47. std::shared_ptr<Inference> Infer = Inference::CreateNew();
  48. std::shared_ptr<deviceState> m_deviceState = deviceState::CreateNew();
  49. int result = ERR;
  50. if(Infer == nullptr) return result;
  51. if(m_deviceState->getDeviceState() != OK) return result;
  52. result = !Infer->Play ? OK : ERR;
  53. // 内存余量较少,避免内存在未清理完全的时候启动,避免死机
  54. if(m_deviceState->MemoryUsage < this-> MemoryThreshold) result = ERR;
  55. return result;
  56. }
  57. /**
  58. * @description: 获取停止资格
  59. * @param {*}
  60. * @return {*}
  61. */
  62. int32_t Manager::getStopPower(){
  63. std::shared_ptr<Inference> Infer = Inference::CreateNew();
  64. if(Infer == nullptr) return ERR;
  65. return Infer->Play ? OK : ERR;
  66. return OK;
  67. }
  68. /**
  69. * @description: 获取清理数据的资格
  70. * @param {*}
  71. * @return {*}
  72. */
  73. int32_t Manager::getClearPower(){
  74. return OK;
  75. }
  76. /**
  77. * @description: 获取同步数据的权力
  78. * @param {*}
  79. * @return {*}
  80. */
  81. int32_t Manager::getSyncDataPower(){
  82. std::shared_ptr<Inference> Infer = Inference::CreateNew();
  83. if(Infer == nullptr) return ERR;
  84. return !Infer->Play ? OK : ERR;
  85. }
  86. /**
  87. * @description: 获取上层数据的资格
  88. * @param {*}
  89. * @return {*}
  90. */
  91. int32_t Manager::getHostDataPower(){
  92. std::shared_ptr<Inference> Infer = Inference::CreateNew();
  93. if(Infer == nullptr) return ERR;
  94. return !Infer->Play ? OK : ERR;
  95. }
  96. }