DebugObserver.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#pragma once
25
26#include <ArmarXCore/interface/observers/ObserverInterface.h>
28
29namespace armarx
30{
31
32 /**
33 * \class DebugObserverPropertyDefinitions
34 * \brief
35 */
37 {
38 public:
40 {
41 defineOptionalProperty<std::string>("DebugObserverTopicName",
42 "DebugObserver",
43 "Name of the topic the DebugObserver listens on");
44 }
45 };
46
47 /**
48 * @defgroup Component-DebugObserver DebugObserver
49 * @ingroup ObserversSub ArmarXCore-Components
50 * Logging of frequently updated values to the console with printf, cout etc.
51 * pollutes the console to an unreadable degree.
52 * Therefore, the DebugObserver exists. The user can log data from anywhere
53 * in the armarx framework by creating temporary observer channels on the DebugObserver.
54 * These channels can be inspected in the armarx::ObserverGuiPlugin or, in the case of floats or ints,
55 * in the armarx::ArmarXPlotter Widget.
56 *
57 * To interact with the DebugObserver, it need to be started since it is a seperate component (\ref DebugObserverApp).
58 * Then the application needs to retrieve a proxy to this object (armarx::IceManager::getProxy(), \ref HowtoGetProxy).
59 * With the proxy and the function setDebugDatafield() a channel and datafield can be created or
60 * updated (if it already exists).
61 * Unneeded channels or datafields can be removed with removeDebugChannel() resp. removeDebugDatafield().
62 *
63 * @class DebugObserver
64 * @ingroup Component-DebugObserver
65 * @brief The DebugObserver is a component for logging debug data, which is updated frequently.
66 */
67 class DebugObserver : public Observer, public DebugObserverInterface
68 {
69 public:
71
72 // framework hooks
73 std::string
74 getDefaultName() const override
75 {
76 return "DebugObserver";
77 }
78
79 void onInitObserver() override;
80 void onConnectObserver() override;
81
83
84 /**
85 * @brief Creates or updates (if it already exists) a datafield in a channel.
86 * @param channelName Name of the channel (anything the users likes)
87 * @param datafieldName Name of the datafield (anything the users likes)
88 * @param value A Variant that the user wants to log
89 */
90 void setDebugDatafield_async(const AMD_DebugObserverInterface_setDebugDatafieldPtr& amd,
91 const std::string& channelName,
92 const std::string& datafieldName,
93 const VariantBasePtr& value,
94 const Ice::Current&) override;
95 void setDebugChannel_async(const AMD_DebugObserverInterface_setDebugChannelPtr& amd,
96 const std::string& channelName,
97 const StringVariantBaseMap& valueMap,
98 const Ice::Current&) override;
99 /**
100 * @brief Removes a datafield from the DebugObserver. Should be called to clean up the DebugObserver.
101 * @param channelName
102 * @param datafieldName
103 */
104 void
105 removeDebugDatafield_async(const AMD_DebugObserverInterface_removeDebugDatafieldPtr& amd,
106 const ::std::string& channelName,
107 const ::std::string& datafieldName,
108 const ::Ice::Current&) override;
109 /**
110 * @brief Removes a channel and all its datafield it has.
111 * @param channelName
112 */
113 void removeDebugChannel_async(const AMD_DebugObserverInterface_removeDebugChannelPtr& amd,
114 const ::std::string& channelName,
115 const ::Ice::Current&) override;
116 /**
117 * @brief Removes all channels.
118 */
119 void removeAllChannels_async(const AMD_DebugObserverInterface_removeAllChannelsPtr& amd,
120 const ::Ice::Current&) override;
121 };
122} // namespace armarx
DebugObserverPropertyDefinitions(std::string prefix)
void onConnectObserver() override
Framework hook.
void setDebugDatafield_async(const AMD_DebugObserverInterface_setDebugDatafieldPtr &amd, const std::string &channelName, const std::string &datafieldName, const VariantBasePtr &value, const Ice::Current &) override
Creates or updates (if it already exists) a datafield in a channel.
void removeDebugDatafield_async(const AMD_DebugObserverInterface_removeDebugDatafieldPtr &amd, const ::std::string &channelName, const ::std::string &datafieldName, const ::Ice::Current &) override
Removes a datafield from the DebugObserver.
void removeAllChannels_async(const AMD_DebugObserverInterface_removeAllChannelsPtr &amd, const ::Ice::Current &) override
Removes all channels.
PropertyDefinitionsPtr createPropertyDefinitions() override
void removeDebugChannel_async(const AMD_DebugObserverInterface_removeDebugChannelPtr &amd, const ::std::string &channelName, const ::Ice::Current &) override
Removes a channel and all its datafield it has.
void onInitObserver() override
Framework hook.
void setDebugChannel_async(const AMD_DebugObserverInterface_setDebugChannelPtr &amd, const std::string &channelName, const StringVariantBaseMap &valueMap, const Ice::Current &) override
std::string getDefaultName() const override
Retrieve default name of component.
ObserverPropertyDefinitions(std::string prefix)
Definition Observer.h:52
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr