From 394ef979d4e10bbbcf82b2cba60edd09cbcc3341 Mon Sep 17 00:00:00 2001
From: Fabian Reister <fabian.reister@kit.edu>
Date: Thu, 25 Mar 2021 14:21:17 +0100
Subject: [PATCH] PlatformUnit: partially reverting changes

---
 .../RobotAPI/components/units/PlatformUnit.cpp  | 14 +++++++++-----
 source/RobotAPI/components/units/PlatformUnit.h | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/source/RobotAPI/components/units/PlatformUnit.cpp b/source/RobotAPI/components/units/PlatformUnit.cpp
index 5f026957d..7b01dda6b 100644
--- a/source/RobotAPI/components/units/PlatformUnit.cpp
+++ b/source/RobotAPI/components/units/PlatformUnit.cpp
@@ -34,26 +34,30 @@ namespace armarx
 {
     PropertyDefinitionsPtr PlatformUnit::createPropertyDefinitions()
     {
-        armarx::PropertyDefinitionsPtr def = new ComponentPropertyDefinitions(getConfigIdentifier());
+        armarx::PropertyDefinitionsPtr def = new PlatformUnitPropertyDefinitions(getConfigIdentifier());
+
         def->topic(odometryPrx);
         def->topic(globalPosePrx);
 
-        // legacy
-        // defineOptionalProperty<std::string>("PlatformName", "Platform", "Name of the platform (will publish values on PlatformName + 'State')");
-        def->topic(listenerPrx, "PlatformState");
-
         return def;
     }
 
 
     void PlatformUnit::onInitComponent()
     {
+        std::string platformName = getProperty<std::string>("PlatformName").getValue();
+
+        listenerChannelName = platformName + "State";
+        offeringTopic(listenerChannelName);
+
         this->onInitPlatformUnit();
     }
 
 
     void PlatformUnit::onConnectComponent()
     {
+        listenerPrx = getTopic<PlatformUnitListenerPrx>(listenerChannelName);
+
         this->onStartPlatformUnit();
     }
 
diff --git a/source/RobotAPI/components/units/PlatformUnit.h b/source/RobotAPI/components/units/PlatformUnit.h
index 23f5f14fc..f8b2335cf 100644
--- a/source/RobotAPI/components/units/PlatformUnit.h
+++ b/source/RobotAPI/components/units/PlatformUnit.h
@@ -36,6 +36,21 @@
 namespace armarx
 {
 
+    /**
+     * \class PlatformUnitPropertyDefinitions
+     * \brief Defines all necessary properties for armarx::PlatformUnit
+     */
+    class PlatformUnitPropertyDefinitions:
+        public ComponentPropertyDefinitions
+    {
+    public:
+        PlatformUnitPropertyDefinitions(std::string prefix):
+            ComponentPropertyDefinitions(prefix)
+        {
+            defineOptionalProperty<std::string>("PlatformName", "Platform", "Name of the platform (will publish values on PlatformName + 'State')");
+        }
+    };
+
 
     /**
      * \defgroup Component-PlatformUnit PlatformUnit
@@ -100,6 +115,8 @@ namespace armarx
         PropertyDefinitionsPtr createPropertyDefinitions() override;
 
     protected:
+
+        std::string listenerChannelName;
         /**
          * PlatformUnitListener proxy for publishing state updates
          */
-- 
GitLab