|
@@ -6,8 +6,10 @@ namespace gsd
|
|
|
* @description: CreateNew
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- std::shared_ptr<MonitorPlugin> MonitorPlugin::CreateNew(){
|
|
|
- return std::shared_ptr<MonitorPlugin>(new MonitorPlugin);
|
|
|
+ std::shared_ptr<MonitorPlugin> MonitorPlugin::getPtr(){
|
|
|
+ static std::shared_ptr<MonitorPlugin> plugin_ = nullptr;
|
|
|
+ if(plugin_ == nullptr) plugin_ = std::shared_ptr<MonitorPlugin>(new MonitorPlugin);
|
|
|
+ return plugin_;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -20,7 +22,7 @@ namespace gsd
|
|
|
ErrorL << "Monitor's init failed" << endl;
|
|
|
return false;
|
|
|
}
|
|
|
- this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_HIGHEST, false);
|
|
|
+ if(this->pool == nullptr) this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_HIGHEST, false);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -29,6 +31,7 @@ namespace gsd
|
|
|
* @return {*}
|
|
|
*/
|
|
|
bool MonitorPlugin::StartTask(){
|
|
|
+ if(this->pool == nullptr) return false;
|
|
|
this->pool->async([&](){
|
|
|
while(!this->stop_){
|
|
|
this->MonitorProThrd();
|
|
@@ -113,7 +116,11 @@ namespace gsd
|
|
|
*/
|
|
|
bool MonitorPlugin::ConsumeData(FrameInferData::Ptr& result){
|
|
|
std::shared_ptr<CNStreamInferData> cnstreamInferData = std::make_shared<CNStreamInferData>();
|
|
|
- if(monitor->ConsumeData(cnstreamInferData)){
|
|
|
+ auto result_data = monitor->ConsumeData(cnstreamInferData);
|
|
|
+ if(result_data.first == false && result_data.second == "ERR__TIMED_OUT"){
|
|
|
+ this->PluginAlive = false;
|
|
|
+ }
|
|
|
+ if(result_data.first){
|
|
|
// 纠察器
|
|
|
if(config::getPtr()->InferChecker){
|
|
|
CNStreamInferData data = *cnstreamInferData;
|
|
@@ -212,6 +219,15 @@ namespace gsd
|
|
|
* @return {*}
|
|
|
*/
|
|
|
bool MonitorPlugin::Alive(){
|
|
|
+ return this->PluginAlive;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: RestPlugin
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ bool MonitorPlugin::RestPlugin(){
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
} // namespace gsd
|