diff --git a/src-cli/live.cpp b/src-cli/live.cpp index ac925add7..14d156c5a 100644 --- a/src-cli/live.cpp +++ b/src-cli/live.cpp @@ -30,7 +30,8 @@ namespace webserver // HTTP Handler for stats void http_handle(nng_aio *aio) { - std::string jsonstr = live_pipeline->getModulesStats().dump(4); + live_pipeline->updateModuleStats(); + std::string jsonstr = live_pipeline->stats.dump(4); nng_http_res *res; nng_http_res_alloc(&res); @@ -256,6 +257,8 @@ int main_live(int argc, char *argv[]) logger->warn("Timeout is over! ({:d}s >= {:d}s) Stopping.", elapsed_time, timeout); break; } + + live_pipeline->stats["timeout_left"] = timeout - elapsed_time; } if (live_should_exit) diff --git a/src-core/core/live_pipeline.cpp b/src-core/core/live_pipeline.cpp index b4ead20a0..e7c47408e 100644 --- a/src-core/core/live_pipeline.cpp +++ b/src-core/core/live_pipeline.cpp @@ -181,15 +181,11 @@ namespace satdump return modules[num]->getOutputs(); } - nlohmann::json LivePipeline::getModulesStats() + void LivePipeline::updateModuleStats() { - nlohmann::json stats; for (std::shared_ptr mod : modules) - { if (mod->module_stats.size() > 0) stats[mod->getIDM()] = mod->module_stats; - } - return stats; } void LivePipeline::drawUIs() diff --git a/src-core/core/live_pipeline.h b/src-core/core/live_pipeline.h index 8ffd9a5ff..37564d004 100644 --- a/src-core/core/live_pipeline.h +++ b/src-core/core/live_pipeline.h @@ -32,7 +32,8 @@ namespace satdump std::vector getOutputFiles(); - nlohmann::json getModulesStats(); + nlohmann::json stats; + void updateModuleStats(); void drawUIs(); };