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 
29 namespace 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:
70  DebugObserver();
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
armarx::DebugObserverPropertyDefinitions::DebugObserverPropertyDefinitions
DebugObserverPropertyDefinitions(std::string prefix)
Definition: DebugObserver.h:39
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:110
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:84
armarx::DebugObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DebugObserver.cpp:176
armarx::DebugObserver::DebugObserver
DebugObserver()
Definition: DebugObserver.cpp:35
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:345
armarx::DebugObserver::removeAllChannels_async
void removeAllChannels_async(const AMD_DebugObserverInterface_removeAllChannelsPtr &amd, const ::Ice::Current &) override
Removes all channels.
Definition: DebugObserver.cpp:149
armarx::DebugObserver
The DebugObserver is a component for logging debug data, which is updated frequently.
Definition: DebugObserver.h:67
Observer.h
armarx::DebugObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: DebugObserver.h:74
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:131
IceInternal::Handle<::armarx::VariantBase >
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
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:111
armarx::DebugObserverPropertyDefinitions
Definition: DebugObserver.h:36
armarx::DebugObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: DebugObserver.cpp:49
IceUtil::Handle
Definition: forward_declarations.h:30
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:54
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:92
armarx::ObserverPropertyDefinitions
Definition: Observer.h:49
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27