123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- /*
- * @Description:
- * @Version: 1.0
- * @Autor: lishengyin
- * @Date: 2022-01-11 11:47:46
- * @LastEditors: lishengyin
- * @LastEditTime: 2022-01-11 14:51:57
- */
- #include "Manager.h"
- namespace MIVA{
- std::shared_ptr<Manager> m_manager = nullptr;
- Manager::Manager(){
- }
- Manager::~Manager(){
- }
- /**
- * @description: 创建实例
- * @param {*}
- * @return {*}
- */
- std::shared_ptr<Manager> Manager::CreateNew(){
- if(m_manager == nullptr) m_manager = std::make_shared<Manager>();
- return m_manager;
- }
-
- /**
- * @description: 设置MemoryThreshold
- * @param {int} MemoryThreshold
- * @return {*}
- */
- void Manager::setMemoryThreshold(int memoryThreshold){
- this->MemoryThreshold = memoryThreshold;
- }
- /**
- * @description: 设置温度阈值
- * @param {int} TempThreshold
- * @return {*}
- */
- void Manager::setTempThreshold(int tempThreshold){
- this->TempThreshold = tempThreshold;
- }
- /**
- * @description: 获得启动资格
- * @param {*}
- * @return {*}
- */
- int32_t Manager::getStartPower(){
- std::shared_ptr<Inference> Infer = Inference::CreateNew();
- std::shared_ptr<deviceState> m_deviceState = deviceState::CreateNew();
- int result = ERR;
- if(Infer == nullptr) return result;
- if(m_deviceState->getDeviceState() != OK) return result;
- result = !Infer->Play ? OK : ERR;
- // 内存余量较少,避免内存在未清理完全的时候启动,避免死机
- if(m_deviceState->MemoryUsage < this-> MemoryThreshold) result = ERR;
- return result;
- }
- /**
- * @description: 获取停止资格
- * @param {*}
- * @return {*}
- */
- int32_t Manager::getStopPower(){
- std::shared_ptr<Inference> Infer = Inference::CreateNew();
- if(Infer == nullptr) return ERR;
- return Infer->Play ? OK : ERR;
- return OK;
- }
- /**
- * @description: 获取清理数据的资格
- * @param {*}
- * @return {*}
- */
- int32_t Manager::getClearPower(){
-
- return OK;
- }
- /**
- * @description: 获取同步数据的权力
- * @param {*}
- * @return {*}
- */
- int32_t Manager::getSyncDataPower(){
- std::shared_ptr<Inference> Infer = Inference::CreateNew();
- if(Infer == nullptr) return ERR;
- return !Infer->Play ? OK : ERR;
- }
- /**
- * @description: 获取上层数据的资格
- * @param {*}
- * @return {*}
- */
- int32_t Manager::getHostDataPower(){
- std::shared_ptr<Inference> Infer = Inference::CreateNew();
- if(Infer == nullptr) return ERR;
- return !Infer->Play ? OK : ERR;
- }
-
- }
|