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 
27 #include <ArmarXCore/interface/observers/ObserverInterface.h>
28 
29 namespace armarx
30 {
31 
32  /**
33  * \class DebugObserverPropertyDefinitions
34  * \brief
35  */
38  {
39  public:
42  {
43  defineOptionalProperty<std::string>("DebugObserverTopicName", "DebugObserver", "Name of the topic the DebugObserver listens on");
44 
45  }
46  };
47 
48  /**
49  * @defgroup Component-DebugObserver DebugObserver
50  * @ingroup ObserversSub ArmarXCore-Components
51  * Logging of frequently updated values to the console with printf, cout etc.
52  * pollutes the console to an unreadable degree.
53  * Therefore, the DebugObserver exists. The user can log data from anywhere
54  * in the armarx framework by creating temporary observer channels on the DebugObserver.
55  * These channels can be inspected in the armarx::ObserverGuiPlugin or, in the case of floats or ints,
56  * in the armarx::ArmarXPlotter Widget.
57  *
58  * To interact with the DebugObserver, it need to be started since it is a seperate component (\ref DebugObserverApp).
59  * Then the application needs to retrieve a proxy to this object (armarx::IceManager::getProxy(), \ref HowtoGetProxy).
60  * With the proxy and the function setDebugDatafield() a channel and datafield can be created or
61  * updated (if it already exists).
62  * Unneeded channels or datafields can be removed with removeDebugChannel() resp. removeDebugDatafield().
63  *
64  * @class DebugObserver
65  * @ingroup Component-DebugObserver
66  * @brief The DebugObserver is a component for logging debug data, which is updated frequently.
67  */
68  class DebugObserver :
69  public Observer,
70  public DebugObserverInterface
71  {
72  public:
73  DebugObserver();
74 
75  // framework hooks
76  std::string getDefaultName() const override
77  {
78  return "DebugObserver";
79  }
80  void onInitObserver() override;
81  void onConnectObserver() override;
82 
84 
85  /**
86  * @brief Creates or updates (if it already exists) a datafield in a channel.
87  * @param channelName Name of the channel (anything the users likes)
88  * @param datafieldName Name of the datafield (anything the users likes)
89  * @param value A Variant that the user wants to log
90  */
92  const AMD_DebugObserverInterface_setDebugDatafieldPtr& amd,
93  const std::string& channelName,
94  const std::string& datafieldName,
95  const VariantBasePtr& value,
96  const Ice::Current&) override;
98  const AMD_DebugObserverInterface_setDebugChannelPtr& amd,
99  const std::string& channelName,
100  const StringVariantBaseMap& valueMap,
101  const Ice::Current&) override;
102  /**
103  * @brief Removes a datafield from the DebugObserver. Should be called to clean up the DebugObserver.
104  * @param channelName
105  * @param datafieldName
106  */
108  const AMD_DebugObserverInterface_removeDebugDatafieldPtr& amd,
109  const ::std::string& channelName,
110  const ::std::string& datafieldName,
111  const ::Ice::Current&) override;
112  /**
113  * @brief Removes a channel and all its datafield it has.
114  * @param channelName
115  */
117  const AMD_DebugObserverInterface_removeDebugChannelPtr& amd,
118  const ::std::string& channelName,
119  const ::Ice::Current&) override;
120  /**
121  * @brief Removes all channels.
122  */
124  const AMD_DebugObserverInterface_removeAllChannelsPtr& amd,
125  const ::Ice::Current&) override;
126  };
127 }
128 
armarx::DebugObserverPropertyDefinitions::DebugObserverPropertyDefinitions
DebugObserverPropertyDefinitions(std::string prefix)
Definition: DebugObserver.h:40
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:80
armarx::DebugObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DebugObserver.cpp:153
armarx::DebugObserver::DebugObserver
DebugObserver()
Definition: DebugObserver.cpp:36
armarx::DebugObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: DebugObserver.cpp:40
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::DebugObserver::removeAllChannels_async
void removeAllChannels_async(const AMD_DebugObserverInterface_removeAllChannelsPtr &amd, const ::Ice::Current &) override
Removes all channels.
Definition: DebugObserver.cpp:130
armarx::DebugObserver
The DebugObserver is a component for logging debug data, which is updated frequently.
Definition: DebugObserver.h:68
Observer.h
armarx::DebugObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: DebugObserver.h:76
armarx::DebugObserver::removeDebugChannel_async
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.
Definition: DebugObserver.cpp:115
IceInternal::Handle<::armarx::VariantBase >
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::DebugObserver::removeDebugDatafield_async
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.
Definition: DebugObserver.cpp:99
armarx::DebugObserverPropertyDefinitions
Definition: DebugObserver.h:36
armarx::DebugObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: DebugObserver.cpp:48
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::DebugObserver::setDebugDatafield_async
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.
Definition: DebugObserver.cpp:52
armarx::DebugObserver::setDebugChannel_async
void setDebugChannel_async(const AMD_DebugObserverInterface_setDebugChannelPtr &amd, const std::string &channelName, const StringVariantBaseMap &valueMap, const Ice::Current &) override
Definition: DebugObserver.cpp:83
armarx::ObserverPropertyDefinitions
Definition: Observer.h:50
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28