Skip to content
Snippets Groups Projects
Commit e2f30738 authored by Joana Plewnia's avatar Joana Plewnia
Browse files

Make sure statistics for recording are saved if recording is interupted due to...

Make sure statistics for recording are saved if recording is interupted due to stopping the component
parent 1723e76f
No related branches found
No related tags found
1 merge request!422Draft: Memory Viewer LTM Recording Progress bar
Pipeline #17287 passed
......@@ -49,6 +49,11 @@ namespace armarx::armem::server::ltm
void createPropertyDefinitions(PropertyDefinitionsPtr& defs, const std::string& prefix) override;
/**
* @brief getAndSaveStatistics generates and saves statistics for a LTM recording
*/
void getAndSaveStatistics();
protected:
void _loadAllReferences(armem::wm::Memory&) final;
void _resolve(armem::wm::Memory&) final;
......@@ -56,11 +61,6 @@ namespace armarx::armem::server::ltm
void _directlyStore(const armem::wm::Memory&) final;
private:
/**
* @brief getAndSaveStatistics generates and saves statistics for a LTM recording
*/
void getAndSaveStatistics();
std::time_t current_date;
};
} // namespace armarx::armem::server::ltm
......@@ -303,8 +303,8 @@ namespace armarx::armem::server::ltm::detail
{
bool enabled_on_startup = false;
std::string configuration_on_startup =
"{ \"SnapshotFrequencyFilter\": {\"WaitingTimeInMsForFilter\" : 500}, "
"\"PngConverter\": {}, \"ExrConverter\": {}}";
"{ \"SnapshotFrequencyFilter\": {\"WaitingTimeInMsForFilter\" : 50}, "
"\"PngConverter\": {}, \"ExrConverter\": {}}"; //record with 20 fps as standard
std::string export_name = "MemoryExport";
std::string export_path = "/tmp/ltm";
} p;
......
......@@ -133,6 +133,16 @@ namespace armarx::armem::server::plugins
statistics_saved = true;
*/
try{
if(longtermMemory.isRecording()){
ARMARX_INFO << "Recording still in progress, stopping component anyways. "
"Saving statistics...";
longtermMemory.getAndSaveStatistics();
}
} catch(...){
ARMARX_WARNING << "Statistics could not be saved for recording that was interrupted by "
"disconnecting the component";
}
if (clientPlugin->isMemoryNameSystemEnabled() and clientPlugin->getMemoryNameSystemClient())
{
......
......@@ -84,6 +84,7 @@ void save_statistics(
//get current date:
auto now = std::chrono::high_resolution_clock::now();
auto now_ax_datetime = DateTime::Now();
auto now_time = std::chrono::high_resolution_clock::to_time_t(now);
auto time = localtime(&now_time);
......@@ -97,6 +98,12 @@ void save_statistics(
bool ended_without_recording = false;
if(firstStoppedRecording.toMilliSecondsSinceEpoch() < firstStartedRecording.toMilliSecondsSinceEpoch()){
//this can happen if the recording is not propperly stopped but interrupted by stopping
//the component
firstStoppedRecording = now_ax_datetime;
}
for(const auto& filter: stats){
filter_statistics(filter.second, memoryName,firstStartedRecording, firstStoppedRecording, &jsonData);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment