/* * @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 m_manager = nullptr; Manager::Manager(){ } Manager::~Manager(){ } /** * @description: 创建实例 * @param {*} * @return {*} */ std::shared_ptr Manager::CreateNew(){ if(m_manager == nullptr) m_manager = std::make_shared(); 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 Infer = Inference::CreateNew(); std::shared_ptr 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 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 Infer = Inference::CreateNew(); if(Infer == nullptr) return ERR; return !Infer->Play ? OK : ERR; } /** * @description: 获取上层数据的资格 * @param {*} * @return {*} */ int32_t Manager::getHostDataPower(){ std::shared_ptr Infer = Inference::CreateNew(); if(Infer == nullptr) return ERR; return !Infer->Play ? OK : ERR; } }