From 4a674296868c86d993a0aabfaca1b44b36ece486 Mon Sep 17 00:00:00 2001 From: Rainer Kartmann <rainer.kartmann@kit.edu> Date: Thu, 3 Aug 2023 10:15:57 +0200 Subject: [PATCH] changes likely by FPK. Getting rid of IceUtil::Time --- .../RobotHealth/RobotHealthDummy.cpp | 37 ++++++++++++------- .../components/RobotHealth/RobotHealthDummy.h | 2 +- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/source/RobotAPI/components/RobotHealth/RobotHealthDummy.cpp b/source/RobotAPI/components/RobotHealth/RobotHealthDummy.cpp index e028bc556..34894b6ea 100644 --- a/source/RobotAPI/components/RobotHealth/RobotHealthDummy.cpp +++ b/source/RobotAPI/components/RobotHealth/RobotHealthDummy.cpp @@ -80,7 +80,7 @@ namespace armarx } void - RobotHealthDummy::busydwait(long microseconds) + RobotHealthDummy::busywait(long microseconds) { long start = TimeUtil::GetTime().toMicroSeconds(); auto end = start + microseconds; @@ -95,51 +95,60 @@ namespace armarx { auto args = RobotHealthHeartbeatArgs(); args.identifier = getName(); + armarx::core::time::toIce(args.maximumCycleTimeError, armarx::core::time::Duration::MilliSeconds(1000)); + armarx::core::time::toIce(args.maximumCycleTimeWarning, armarx::core::time::Duration::MilliSeconds(500)); robotHealthTopicPrx->signUp(args); ARMARX_INFO << "starting rinning task"; while (!dummyTask->isStopped()) { - long beforeTopicCall = TimeUtil::GetTime().toMicroSeconds(); + auto beforeTopicCall = armarx::core::time::DateTime::Now(); //ARMARX_INFO << "send heartbeat"; armarx::core::time::dto::DateTime now; armarx::core::time::toIce(now, armarx::core::time::DateTime::Now()); robotHealthTopicPrx->heartbeat(getName(), now); - long afterTopicCall = TimeUtil::GetTime().toMicroSeconds(); + auto afterTopicCall = armarx::core::time::DateTime::Now(); + if (sleepmode == "nanosleep") { - NanoSleep(10 * 1000 * 1000); + NanoSleep(10 * 1000 * 1000); // wait 10 milliseconds } else if (sleepmode == "sleepwait") { - sleepwait(10 * 1000); + sleepwait(10 * 1000); // wait 10 milliseconds } else if (sleepmode == "yieldwait") { - yieldwait(10 * 1000); + yieldwait(10 * 1000); // wait 10 milliseconds } else if (sleepmode == "busywait") { - busydwait(10 * 1000); + busywait(10 * 1000); // wait 10 milliseconds + } + else if (sleepmode == "std::this_thread::sleep_for") + { + std::this_thread::sleep_for(std::chrono::microseconds(10 * 1000)); } else { throw LocalException("Unknown sleepmode."); } - long afterSleep = TimeUtil::GetTime().toMicroSeconds(); - long topicCallDelay = afterTopicCall - beforeTopicCall; - long sleepDelay = afterSleep - afterTopicCall; - if (sleepDelay > 20000) + auto afterSleep = armarx::core::time::DateTime::Now(); + auto topicCallDelay = afterTopicCall - beforeTopicCall; + auto sleepDelay = afterSleep - afterTopicCall; + if (sleepDelay.toMicroSeconds() > 20000) { - ARMARX_IMPORTANT << sleepmode << ": " << sleepDelay << "us"; + ARMARX_IMPORTANT << sleepmode << " took long: " << sleepDelay << "us"; } - if (topicCallDelay > 1000) + if (topicCallDelay.toMicroSeconds() > 1000) { - ARMARX_IMPORTANT << "topic: " << topicCallDelay << "us"; + ARMARX_IMPORTANT << "topic took long: " << topicCallDelay << "us"; } } + + robotHealthTopicPrx->unregister(args.identifier); } void diff --git a/source/RobotAPI/components/RobotHealth/RobotHealthDummy.h b/source/RobotAPI/components/RobotHealth/RobotHealthDummy.h index cfd8d369d..a84172014 100644 --- a/source/RobotAPI/components/RobotHealth/RobotHealthDummy.h +++ b/source/RobotAPI/components/RobotHealth/RobotHealthDummy.h @@ -78,7 +78,7 @@ namespace armarx int NanoSleep(long nanosec); void yieldwait(long microseconds); - void busydwait(long microseconds); + void busywait(long microseconds); void sleepwait(long microseconds); protected: -- GitLab