|
@@ -4,7 +4,7 @@
|
|
|
* @Autor: lishengyin
|
|
|
* @Date: 2021-10-13 09:35:42
|
|
|
* @LastEditors: lishengyin
|
|
|
- * @LastEditTime: 2022-01-10 10:28:43
|
|
|
+ * @LastEditTime: 2022-01-11 14:54:04
|
|
|
*/
|
|
|
#include "user_app.h"
|
|
|
|
|
@@ -32,6 +32,7 @@ namespace MIVA
|
|
|
UserApp::~UserApp(){
|
|
|
Destroy();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @description: 初始化
|
|
|
* @param {string} appName
|
|
@@ -93,9 +94,11 @@ namespace MIVA
|
|
|
this->m_recorder = recorder::CreateNew();
|
|
|
this->m_Cleaner = Cleaner::CreateNew();
|
|
|
this->m_monitor = monitor::CreateNew();
|
|
|
+ this->m_deviceState = deviceState::CreateNew();
|
|
|
+ this->m_manager = Manager::CreateNew();
|
|
|
|
|
|
// 查询基础配置
|
|
|
- SqlWriter sqlSelectConfig("SELECT account,outType,outPath,outEnable,ClearType,recordMax,validTime FROM MIVA_DB.`MivaConfig`");
|
|
|
+ SqlWriter sqlSelectConfig("SELECT account,outType,outPath,outEnable,ClearType,recordMax,validTime,MemoryThreshold,TempThreshold FROM MIVA_DB.`MivaConfig`");
|
|
|
sqlSelectConfig << sqlRet;
|
|
|
for(auto &line : sqlRet)
|
|
|
{
|
|
@@ -106,6 +109,8 @@ namespace MIVA
|
|
|
this->m_Cleaner->ClearType = std::atoi(line[4].c_str());
|
|
|
this->m_Cleaner->recordMax = std::atoi(line[5].c_str());
|
|
|
this->m_Cleaner->validTime = std::atoi(line[6].c_str());
|
|
|
+ this->m_manager->setMemoryThreshold(std::atoi(line[7].c_str()));
|
|
|
+ this->m_manager->setTempThreshold(std::atoi(line[8].c_str()));
|
|
|
}
|
|
|
|
|
|
// 链接Netty后端
|
|
@@ -132,7 +137,7 @@ namespace MIVA
|
|
|
this->m_InferInfo = InferInfo::CreateNew();
|
|
|
|
|
|
// 初始化Deepstream
|
|
|
- m_Infer = std::make_shared<Inference>();
|
|
|
+ m_Infer = Inference::CreateNew();
|
|
|
|
|
|
if(m_Infer == NULL){
|
|
|
ErrorL << "Inference module creation failed!";
|
|
@@ -160,7 +165,6 @@ namespace MIVA
|
|
|
InfoL << "The stream to be played is not found, please add it in the background.";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 监听推理广播
|
|
|
NoticeCenter::Instance().addListener(0,NOTICE_INFER,
|
|
|
[&](int Source_id, int num){
|
|
@@ -246,7 +250,7 @@ namespace MIVA
|
|
|
this->m_timer3 = std::make_shared<Timer>(3.0f,[&](){
|
|
|
if(this->m_httpClient->alive()){
|
|
|
// 获取数据
|
|
|
- if(this->m_Infer->Play == false) this->GetNettyDatas();
|
|
|
+ if(this->m_manager->getHostDataPower() == OK) this->GetNettyDatas();
|
|
|
}else{ // 未获取到Token
|
|
|
if(this->m_httpClient->LoginNetty() != OK){
|
|
|
ErrorL << "登录Netty失败" << endl;
|
|
@@ -258,7 +262,7 @@ namespace MIVA
|
|
|
// 定时监控数据变化
|
|
|
this->m_timer4 = std::make_shared<Timer>(3.0f,[&](){
|
|
|
// 监听数据
|
|
|
- if(this->m_Infer->Play == false) this->MonitorData();
|
|
|
+ if(this->m_manager->getSyncDataPower() == OK) this->MonitorData();
|
|
|
return true;
|
|
|
},nullptr);
|
|
|
|
|
@@ -295,7 +299,7 @@ namespace MIVA
|
|
|
*/
|
|
|
void UserApp::ListenInferPer()
|
|
|
{
|
|
|
- if(this->m_Infer->Play == true){
|
|
|
+ if(this->m_manager->getStopPower() == OK){
|
|
|
// 推理结束发布InferData事件
|
|
|
this->ListenInferData();
|
|
|
this->m_Infer->Recorder();
|
|
@@ -466,7 +470,6 @@ namespace MIVA
|
|
|
// std::string json;
|
|
|
// memcpy((uint8_t *)(&json), (uint8_t *)(pBuf->data()), pBuf->size());
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -508,8 +511,8 @@ namespace MIVA
|
|
|
if((serverResultMag.DoorFlag & 0x80))
|
|
|
{
|
|
|
// 广播收到关门的信号
|
|
|
- if(this->m_Infer->Play == false) this->ListenClosed();
|
|
|
- else WarnL << "推理未结束" << endl;
|
|
|
+ if(this->m_manager->getStartPower() == OK) this->ListenClosed();
|
|
|
+ else WarnL << "推理未结束或内存所剩不足" << endl;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -555,10 +558,13 @@ namespace MIVA
|
|
|
vector<DataSource>::iterator iter;
|
|
|
char ctime[80];
|
|
|
getDataTime(ctime);
|
|
|
- SqlWriter sqlUpdate_DeviceState("UPDATE MIVA_DB.DeviceState SET CpuUsage='?',GpuUsage='?',MemoryUsage='?',Temp='?',FdUsage='?',updateTime='?'");
|
|
|
- sqlUpdate_DeviceState << this->m_monitor->getCpuUsage() << this->m_monitor->getGpuUsage() << this->m_monitor->getMemoryUsage() << this->m_monitor->getTemp() << this->m_monitor->getFdUsage() << ctime << sqlRet;
|
|
|
+ std::string Ctime = ctime;
|
|
|
|
|
|
- SqlWriter sqlSelectConfig("SELECT account,outType,outPath,outEnable,ClearType,recordMax,validTime FROM MIVA_DB.`MivaConfig`");
|
|
|
+ // 设备数据
|
|
|
+ this->m_deviceState->getDeviceState();
|
|
|
+ this->m_deviceState->SyncDeviceState(Ctime);
|
|
|
+
|
|
|
+ SqlWriter sqlSelectConfig("SELECT account,outType,outPath,outEnable,ClearType,recordMax,validTime,MemoryThreshold,TempThreshold FROM MIVA_DB.`MivaConfig`");
|
|
|
sqlSelectConfig << sqlRet;
|
|
|
for(auto &line : sqlRet)
|
|
|
{
|
|
@@ -569,6 +575,8 @@ namespace MIVA
|
|
|
this->m_Cleaner->ClearType = std::atoi(line[4].c_str());
|
|
|
this->m_Cleaner->recordMax = std::atoi(line[5].c_str());
|
|
|
this->m_Cleaner->validTime = std::atoi(line[6].c_str());
|
|
|
+ this->m_manager->setMemoryThreshold(std::atoi(line[7].c_str()));
|
|
|
+ this->m_manager->setTempThreshold(std::atoi(line[8].c_str()));
|
|
|
}
|
|
|
|
|
|
if(this->m_Infer->enable == false || this->m_InferInfo->DataSources.empty()){
|
|
@@ -658,7 +666,7 @@ namespace MIVA
|
|
|
this->m_InferInfo->DataSources.clear();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @description: 赋值struct sockaddr
|
|
|
* @param {sockaddr} *out
|
|
@@ -850,7 +858,7 @@ namespace MIVA
|
|
|
}else{
|
|
|
ErrorL << "SystemConfig 未查询到数据" << endl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 解析
|
|
|
if(!CrowdednessTimeConfigs.empty()){
|
|
|
char ctime[80];
|
|
@@ -873,4 +881,14 @@ namespace MIVA
|
|
|
}
|
|
|
return grade;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 清理内存
|
|
|
+ * @param {*}
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ int32_t UserApp::ClearMemory(){
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|