From 389639b64844acb3b1f1947eb79a24403df60853 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: Wed, 21 Jun 2023 13:11:40 +0200
Subject: [PATCH] replacing topic by proxy call (already available); fixing
 property defs

---
 .../HeartbeatComponentPlugin.cpp              | 28 +++++++++----------
 .../HeartbeatComponentPlugin.h                | 10 ++-----
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp
index f5e65cd47..9c1d995de 100644
--- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp
+++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp
@@ -59,50 +59,50 @@ namespace armarx::plugins
     HeartbeatComponentPlugin::signUp(const RobotHealthHeartbeatArgs& args)
     {
         ARMARX_TRACE;
-        ARMARX_CHECK_NOT_NULL(rhprx);
+        ARMARX_CHECK_NOT_NULL(robotHealthComponentPrx);
 
         if (args.identifier.empty())
         {
             RobotHealthHeartbeatArgs argsCopy = args;
             argsCopy.identifier = parent().getName();
-            rhprx->signUp(argsCopy);
+            robotHealthComponentPrx->signUp(argsCopy);
         }
         else
         {
             // add component name prefix to identifier
             RobotHealthHeartbeatArgs argsCopy = args;
             argsCopy.identifier = parent().getName() + "_" + argsCopy.identifier;
-            rhprx->signUp(argsCopy);
+            robotHealthComponentPrx->signUp(argsCopy);
         }
     }
 
     void
     HeartbeatComponentPlugin::heartbeat()
     {
-        if (robotHealthTopic)
+        if (robotHealthComponentPrx)
         {
             armarx::core::time::dto::DateTime now;
             armarx::core::time::toIce(now, armarx::core::time::DateTime::Now());
-            robotHealthTopic->heartbeat(parent().getName(), now);
+            robotHealthComponentPrx->heartbeat(parent().getName(), now);
         }
         else
         {
-            ARMARX_WARNING << "No robot health topic available!";
+            ARMARX_WARNING << "No robot health proxy available!";
         }
     }
 
     void
     HeartbeatComponentPlugin::heartbeatOnChannel(const std::string& channelName)
     {
-        if (robotHealthTopic)
+        if (robotHealthComponentPrx)
         {
             armarx::core::time::dto::DateTime now;
             armarx::core::time::toIce(now, armarx::core::time::DateTime::Now());
-            robotHealthTopic->heartbeat(parent().getName() + "_" + channelName, now);
+            robotHealthComponentPrx->heartbeat(parent().getName() + "_" + channelName, now);
         }
         else
         {
-            ARMARX_WARNING << "No robot health topic available!";
+            ARMARX_WARNING << "No robot health proxy available!";
         }
     }
 
@@ -131,9 +131,7 @@ namespace armarx::plugins
     void
     HeartbeatComponentPlugin::postOnConnectComponent()
     {
-        ARMARX_CHECK_NOT_NULL(rhprx);
-        topicName = rhprx->getTopicName();
-        robotHealthTopic = parent<Component>().getTopic<RobotHealthInterfacePrx>(topicName);
+        ARMARX_CHECK_NOT_NULL(robotHealthComponentPrx);
     }
 
     void
@@ -142,19 +140,19 @@ namespace armarx::plugins
         if (!properties->hasDefinition(makePropertyName(healthPropertyName)))
         {
             properties->component(
-                rhprx, "RobotHealth", healthPropertyName, "Name of the robot health component.");
+                robotHealthComponentPrx, "RobotHealth", healthPropertyName, "Name of the robot health component.");
         }
 
         if (not properties->hasDefinition(makePropertyName(maximumCycleTimeWarningMSPropertyName)))
         {
-            properties->required(p.maximumCycleTimeWarningMS,
+            properties->optional(p.maximumCycleTimeWarningMS,
                                  maximumCycleTimeWarningMSPropertyName,
                                  "maximum cycle time before warning is emitted");
         }
 
         if (not properties->hasDefinition(makePropertyName(maximumCycleTimeErrorMSPropertyName)))
         {
-            properties->required(p.maximumCycleTimeErrorMS,
+            properties->optional(p.maximumCycleTimeErrorMS,
                                  maximumCycleTimeErrorMSPropertyName,
                                  "maximum cycle time before error is emitted");
         }
diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h
index 7b3654e84..8a7f4a42c 100644
--- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h
+++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h
@@ -88,11 +88,7 @@ namespace armarx::plugins
         void postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties) override;
 
     private:
-        //! heartbeat topic name (outgoing)
-        RobotHealthInterfacePrx robotHealthTopic;
-        std::string topicName{"RobotHealthTopic"};
-
-        RobotHealthComponentInterfacePrx rhprx;
+        RobotHealthComponentInterfacePrx robotHealthComponentPrx;
 
         //
         static constexpr auto healthPropertyName = "heartbeat.ComponentName";
@@ -103,8 +99,8 @@ namespace armarx::plugins
 
         struct Properties
         {
-            long maximumCycleTimeWarningMS = 50;
-            long maximumCycleTimeErrorMS = 100;
+            long maximumCycleTimeWarningMS = 100; // [ms]
+            long maximumCycleTimeErrorMS = 200; // [ms]
         } p;
 
         //! default config used in heartbeat(), set via properties
-- 
GitLab