diff --git a/base/include/Module.h b/base/include/Module.h index ec89b30cc..842dd2df7 100644 --- a/base/include/Module.h +++ b/base/include/Module.h @@ -46,6 +46,7 @@ class ModuleProps fIndexStrategyType = FIndexStrategy::FIndexStrategyType::AUTO_INCREMENT; frameFetchStrategy = FrameFetchStrategy::PUSH; enableHealthCallBack = false; + healthUpdateIntervalInSec = 5; } ModuleProps(float _fps) @@ -59,6 +60,7 @@ class ModuleProps fIndexStrategyType = FIndexStrategy::FIndexStrategyType::AUTO_INCREMENT; frameFetchStrategy = FrameFetchStrategy::PUSH; enableHealthCallBack = false; + healthUpdateIntervalInSec = 5; } ModuleProps(float _fps, size_t _qlen, bool _logHealth) @@ -72,6 +74,7 @@ class ModuleProps fIndexStrategyType = FIndexStrategy::FIndexStrategyType::AUTO_INCREMENT; frameFetchStrategy = FrameFetchStrategy::PUSH; enableHealthCallBack = false; + healthUpdateIntervalInSec = 5; } ModuleProps(FrameFetchStrategy _frameFetchStrategy) @@ -85,6 +88,7 @@ class ModuleProps fIndexStrategyType = FIndexStrategy::FIndexStrategyType::AUTO_INCREMENT; frameFetchStrategy = _frameFetchStrategy; enableHealthCallBack = false; + healthUpdateIntervalInSec = 5; } size_t getQLen() @@ -125,8 +129,9 @@ class ModuleProps FrameFetchStrategy frameFetchStrategy; QuePushStrategy::QuePushStrategyType quePushStrategyType; FIndexStrategy::FIndexStrategyType fIndexStrategyType; - bool enableHealthCallBack; - + bool enableHealthCallBack; // ToEnable HealthCallback we need to set ModuleProps as true, Will get Callbacks only if ControlModule is there + int healthUpdateIntervalInSec; // Health Callback Interval Defined in Sec, if Value is + // set to 5, then it means after every 5 sec Control Module will receive health callback private: friend class Module; diff --git a/base/src/Module.cpp b/base/src/Module.cpp index 8053cd998..661b7ee15 100644 --- a/base/src/Module.cpp +++ b/base/src/Module.cpp @@ -34,7 +34,7 @@ class Module::Profiler using sys_clock = std::chrono::system_clock; public: - Profiler(string &id, bool _shouldLog, int _printFrequency, + Profiler(string &id, bool _shouldLog, int _printFrequency, int _healthUpdateIntervalInSec, std::function _getPoolHealthRecord, APHealthCallback _healthCallback) : moduleId(id), shouldLog(_shouldLog), mPipelineFps(0), @@ -42,6 +42,7 @@ class Module::Profiler { getPoolHealthRecord = _getPoolHealthRecord; lastHealthCallbackTime = sys_clock::now(); + mHealthUpdateIntervalInSec = _healthUpdateIntervalInSec; } void setShouldLog(bool _shouldLog) { shouldLog = _shouldLog; } @@ -100,7 +101,7 @@ class Module::Profiler auto elapsed = std::chrono::duration_cast( now - lastHealthCallbackTime) .count(); - if (elapsed >= 1) + if (elapsed >= mHealthUpdateIntervalInSec) { if (healthCallback) { @@ -137,6 +138,7 @@ class Module::Profiler double mPipelineFps; APHealthCallback healthCallback; + int mHealthUpdateIntervalInSec; }; Module::Module(Kind nature, string name, ModuleProps _props) @@ -156,7 +158,7 @@ Module::Module(Kind nature, string name, ModuleProps _props) pacer = boost::shared_ptr(new PaceMaker(_props.fps)); auto tempId = getId(); mProfiler.reset(new Profiler( - tempId, _props.logHealth, _props.logHealthFrequency, + tempId, _props.logHealth, _props.logHealthFrequency, _props.healthUpdateIntervalInSec, [&]() -> std::string { if (!mpFrameFactory.get()) diff --git a/base/test/ImageEncodeCV_tests.cpp b/base/test/ImageEncodeCV_tests.cpp index 5651dc3f4..f8cec1b93 100755 --- a/base/test/ImageEncodeCV_tests.cpp +++ b/base/test/ImageEncodeCV_tests.cpp @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(MONO_profile, *boost::unit_test::disabled()) BOOST_AUTO_TEST_CASE(RGB_profile, *boost::unit_test::disabled()) { LoggerProps logprops; - logprops.logLevel = boost::log::trivial::severity_level::info; + logprops.logLevel = boost::log::trivial::severity_level::error; Logger::initLogger(logprops); @@ -162,6 +162,7 @@ BOOST_AUTO_TEST_CASE(RGB_profile, *boost::unit_test::disabled()) ImageEncoderCVProps encoderProps; encoderProps.enableHealthCallBack = true; + encoderProps.healthUpdateIntervalInSec = 10; auto m2 = boost::shared_ptr(new ImageEncoderCV(encoderProps)); fileReader->setNext(m2); @@ -172,8 +173,8 @@ BOOST_AUTO_TEST_CASE(RGB_profile, *boost::unit_test::disabled()) boost::shared_ptr mControl = boost::shared_ptr(new SimpleControlModule(controlProps)); StatSinkProps statSinkProps; - statSinkProps.logHealth = true; - statSinkProps.logHealthFrequency = 10; + // statSinkProps.logHealth = true; + // statSinkProps.logHealthFrequency = 10; auto statSink = boost::shared_ptr(new StatSink(statSinkProps)); m2->setNext(statSink);