From 06fc4f52fa3012e63ab6d4aae221df46fd71fef2 Mon Sep 17 00:00:00 2001 From: Simon Ottenhaus <simon.ottenhaus@kit.edu> Date: Mon, 17 Dec 2018 17:45:03 +0100 Subject: [PATCH] minimum report interval --- source/RobotAPI/components/RobotHealth/RobotHealth.cpp | 4 +++- source/RobotAPI/components/RobotHealth/RobotHealth.h | 4 ++++ .../GuiHealthClient/GuiHealthClientWidgetController.cpp | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/RobotAPI/components/RobotHealth/RobotHealth.cpp b/source/RobotAPI/components/RobotHealth/RobotHealth.cpp index 6f10dc4ab..24bc96c94 100644 --- a/source/RobotAPI/components/RobotHealth/RobotHealth.cpp +++ b/source/RobotAPI/components/RobotHealth/RobotHealth.cpp @@ -33,6 +33,7 @@ void RobotHealth::onInitComponent() defaultMaximumCycleTimeErr = getProperty<int>("MaximumCycleTimeErrMS").getValue(); usingTopic(getProperty<std::string>("RobotHealthTopicName").getValue()); reportErrorsWithSpeech = getProperty<bool>("ReportErrorsWithSpeech").getValue(); + speechMinimumReportInterval = getProperty<int>("SpeechMinimumReportInterval").getValue(); //robotUnitRequired = getProperty<bool>("RobotUnitRequired").getValue(); /*if(robotUnitRequired) @@ -88,8 +89,9 @@ void RobotHealth::monitorHealthTaskClb() if (e.isRunning) { ARMARX_ERROR << deactivateSpam(0.1, e.name) << "Component " << e.name << " has died."; - if (reportErrorsWithSpeech) + if (reportErrorsWithSpeech && (TimeUtil::GetTime() - lastSpeechOutput).toSecondsDouble() > speechMinimumReportInterval) { + lastSpeechOutput = TimeUtil::GetTime(); textToSpeechTopic->reportText("Oh no! Component " + e.name + " is no longer running."); } hasNewErr = true; diff --git a/source/RobotAPI/components/RobotHealth/RobotHealth.h b/source/RobotAPI/components/RobotHealth/RobotHealth.h index 65c086a35..cc50f09de 100644 --- a/source/RobotAPI/components/RobotHealth/RobotHealth.h +++ b/source/RobotAPI/components/RobotHealth/RobotHealth.h @@ -54,6 +54,8 @@ namespace armarx defineOptionalProperty<std::string>("AggregatedRobotHealthTopicName", "AggregatedRobotHealthTopic", "Name of the AggregatedRobotHealthTopic"); defineOptionalProperty<std::string>("RequiredComponents", "", "Comma separated list of required components"); + defineOptionalProperty<int>("SpeechMinimumReportInterval", 60, "Time that has to pass between reported messages in seconds."); + //defineOptionalProperty<std::string>("RemoteGuiName", "RemoteGuiProvider", "Name of the remote GUI provider"); //defineOptionalProperty<std::string>("RobotUnitName", "Armar6Unit", "Name of the RobotUnit"); //defineOptionalProperty<bool>("RobotUnitRequired", true, "Wait for RobotUnit"); @@ -150,6 +152,8 @@ namespace armarx AggregatedRobotHealthInterfacePrx aggregatedRobotHealthTopicPrx; TextListenerInterfacePrx textToSpeechTopic; bool reportErrorsWithSpeech; + int speechMinimumReportInterval; + IceUtil::Time lastSpeechOutput; // RobotHealthInterface interface public: diff --git a/source/RobotAPI/gui-plugins/GuiHealthClient/GuiHealthClientWidgetController.cpp b/source/RobotAPI/gui-plugins/GuiHealthClient/GuiHealthClientWidgetController.cpp index ccad68123..4b588f433 100644 --- a/source/RobotAPI/gui-plugins/GuiHealthClient/GuiHealthClientWidgetController.cpp +++ b/source/RobotAPI/gui-plugins/GuiHealthClient/GuiHealthClientWidgetController.cpp @@ -68,6 +68,9 @@ void GuiHealthClientWidgetController::onInitComponent() void GuiHealthClientWidgetController::healthTimerClb() { + RobotHealthHeartbeatArgs rhha; + rhha.maximumCycleTimeWarningMS = 250; + rhha.maximumCycleTimeErrorMS = 500; robotHealthTopicPrx->heartbeat(getName(), RobotHealthHeartbeatArgs()); } void GuiHealthClientWidgetController::updateSummaryTimerClb() -- GitLab