diff --git a/source/RobotAPI/components/armem/client/TransformClient/MemoryConnector.cpp b/source/RobotAPI/components/armem/client/TransformClient/MemoryConnector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d9b017e2efed8d46cffd7a2f3b00d589428aec1a --- /dev/null +++ b/source/RobotAPI/components/armem/client/TransformClient/MemoryConnector.cpp @@ -0,0 +1,40 @@ +#include "MemoryConnector.h" + +#include <ArmarXCore/core/ManagedIceObject.h> +#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> +#include <ArmarXCore/core/exceptions/local/ExpressionException.h> + +namespace armarx { + +MemoryConnector::MemoryConnector(ManagedIceObject &component) : component(component) {} + +void MemoryConnector::registerPropertyDefinitions(PropertyDefinitionsPtr &def) +{ + ARMARX_INFO << "Memory connector: registerPropertyDefinitions"; + + const std::string prefix = getPropertyPrefix(); + + def->component(memoryNameSystem, "ArMemMemoryNameSystem", prefix + "ArMemMemoryNameSystem"); +} + +armem::data::WaitForMemoryResult MemoryConnector::useMemory(const std::string &memoryName) +{ + armem::data::WaitForMemoryInput input; + input.name = memoryName; + + ARMARX_CHECK_NOT_NULL(memoryNameSystem); + + ARMARX_INFO << "Waiting for memory ..."; + armem::data::WaitForMemoryResult result = memoryNameSystem->waitForMemory(input); + + if (result.success) { + // Add dependency. + component.usingProxy(result.proxy->ice_getIdentity().name); + } + else { + ARMARX_WARNING << "Use memory: Failure"; + } + return result; +} + +} // namespace armarx diff --git a/source/RobotAPI/components/armem/client/TransformClient/MemoryConnector.h b/source/RobotAPI/components/armem/client/TransformClient/MemoryConnector.h new file mode 100644 index 0000000000000000000000000000000000000000..473435954443fbf34b4589e17bf996eba0bb5369 --- /dev/null +++ b/source/RobotAPI/components/armem/client/TransformClient/MemoryConnector.h @@ -0,0 +1,58 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects:: + * @author Fabian Reister ( fabian dot reister at kit dot edu ) + * @date 2021 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h> + +// TODO(fabian.reister): remove +#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> + +namespace armarx { + +class ManagedIceObject; + +// TODO(fabian.reister): add +// class PropertyDefinitionsPtr; + +class MemoryConnector { + + public: + MemoryConnector(ManagedIceObject &component); + + protected: + armem::data::WaitForMemoryResult useMemory(const std::string &memoryName); + void registerPropertyDefinitions(PropertyDefinitionsPtr &def); + + void waitForMemory(); + + virtual std::string getPropertyPrefix(){ + return "mem."; + } + + private: + ManagedIceObject &component; + + armem::mns::MemoryNameSystemInterfacePrx memoryNameSystem; +}; + +} // namespace armarx \ No newline at end of file diff --git a/source/RobotAPI/components/armem/client/TransformClient/TransformReaderClient.cpp b/source/RobotAPI/components/armem/client/TransformClient/TransformReader.cpp similarity index 100% rename from source/RobotAPI/components/armem/client/TransformClient/TransformReaderClient.cpp rename to source/RobotAPI/components/armem/client/TransformClient/TransformReader.cpp diff --git a/source/RobotAPI/components/armem/client/TransformClient/TransformReaderClient.h b/source/RobotAPI/components/armem/client/TransformClient/TransformReader.h similarity index 100% rename from source/RobotAPI/components/armem/client/TransformClient/TransformReaderClient.h rename to source/RobotAPI/components/armem/client/TransformClient/TransformReader.h