ProfilerObserver.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 Core::observers::ProfilerObserver
19  * @author Manfred Kroehnert (manfred dot kroehnert at kit dot edu)
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 #include <ArmarXCore/interface/observers/ProfilerObserverInterface.h>
28 
29 #include "../observers/Observer.h"
30 #include "../observers/variant/StringValueMap.h"
31 
32 namespace armarx
33 {
34  /**
35  * @defgroup Component-ProfilerObserver ProfilerObserver
36  * @ingroup ObserversSub ArmarXCore-Components
37  * The ProfilerObserver class listens on the topic armarx::Profiler::PROFILER_TOPIC_NAME (defined in Core/interface/core/Profiler.ice) and provides the data via Channels.
38  *
39  * Network profiling can be enabled for any armarx::Application by setting the property armarx::NetworkStats to "1".
40  * This property can either be set in ~/.armarx/default.cfg or on the commandline.
41  *
42  * The gathered data can for example be viewed with the Logger plugin of ArmarXGui.
43  *
44  * @class ProfilerObserver
45  * @ingroup Component-ProfilerObserver
46  */
48  virtual public Observer,
49  virtual public armarx::ProfilerObserverInterface
50  {
51  public:
52  ~ProfilerObserver() override;
53  std::string getDefaultName() const override;
54  void onInitObserver() override;
55  void onConnectObserver() override;
56 
57  void reportNetworkTraffic(const std::string& id, const std::string& protocol, Ice::Int inBytes, Ice::Int outBytes, const Ice::Current& = Ice::emptyCurrent) override;
58  void reportEvent(const ProfilerEvent& event, const Ice::Current& = Ice::emptyCurrent) override;
59 
60  void reportStatechartTransition(const ProfilerStatechartTransition& transition, const Ice::Current& = Ice::emptyCurrent) override;
61  void reportStatechartInputParameters(const ProfilerStatechartParameters& inputParametes, const Ice::Current& = Ice::emptyCurrent) override;
62  void reportStatechartLocalParameters(const ProfilerStatechartParameters& localParameters, const Ice::Current& = Ice::emptyCurrent) override;
63  void reportStatechartOutputParameters(const ProfilerStatechartParameters& outputParameters, const Ice::Current& = Ice::emptyCurrent) override;
64  void reportStatechartTransitionWithParameters(const ProfilerStatechartTransitionWithParameters& outputParameters, const Ice::Current& = Ice::emptyCurrent) override;
65 
66  void reportProcessCpuUsage(const ProfilerProcessCpuUsage& process, const Ice::Current& = Ice::emptyCurrent) override;
67  void reportProcessMemoryUsage(const ProfilerProcessMemoryUsage& memoryUsage, const Ice::Current& = Ice::emptyCurrent) override;
68 
69 
70  void reportEventList(const ProfilerEventList& events, const Ice::Current& = Ice::emptyCurrent) override;
71 
72  void reportStatechartTransitionList(const ProfilerStatechartTransitionList& transitions, const Ice::Current& = Ice::emptyCurrent) override;
73  void reportStatechartInputParametersList(const ProfilerStatechartParametersList& inputParametersList, const ::Ice::Current& = Ice::emptyCurrent) override;
74  void reportStatechartLocalParametersList(const ProfilerStatechartParametersList& localParametersList, const Ice::Current& = Ice::emptyCurrent) override;
75  void reportStatechartOutputParametersList(const ProfilerStatechartParametersList& outputParametersList, const Ice::Current& = Ice::emptyCurrent) override;
76  void reportStatechartTransitionWithParametersList(const ProfilerStatechartTransitionWithParametersList& outputParameters, const Ice::Current& = Ice::emptyCurrent) override;
77 
78  void reportProcessCpuUsageList(const ProfilerProcessCpuUsageList& processes, const Ice::Current& = Ice::emptyCurrent) override;
79  void reportProcessMemoryUsageList(const ProfilerProcessMemoryUsageList& memoryUsages, const Ice::Current& = Ice::emptyCurrent) override;
80  private:
81  /**
82  * @brief createStateChannelIfRequired if channel with @p channelName does not exist, create it and all required datafields
83  * @param channelName
84  */
85  void createStateChannelIfRequired(const std::string& channelName);
86  /**
87  * @brief createResourceChannelIfRequired if channel with @p channelName does not exist, create it and all required datafields
88  * @param channelName
89  */
90  void createResourceChannelIfRequired(const std::string& channelName);
91 
92  static void StateParameterToVariantMap(const armarx::StateParameterMap& parameterMap, armarx::StringValueMap& variantMap);
93  std::mutex channelCheckMutex;
94  };
95 }
96 
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:80
armarx::ProfilerObserver::reportEventList
void reportEventList(const ProfilerEventList &events, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:300
armarx::ProfilerObserver::reportStatechartTransitionWithParametersList
void reportStatechartTransitionWithParametersList(const ProfilerStatechartTransitionWithParametersList &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:357
armarx::ProfilerObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: ProfilerObserver.cpp:44
armarx::ProfilerObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: ProfilerObserver.cpp:50
armarx::ProfilerObserver
Definition: ProfilerObserver.h:47
armarx::ProfilerObserver::reportStatechartInputParameters
void reportStatechartInputParameters(const ProfilerStatechartParameters &inputParametes, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:199
armarx::ProfilerObserver::reportProcessMemoryUsageList
void reportProcessMemoryUsageList(const ProfilerProcessMemoryUsageList &memoryUsages, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:378
armarx::ProfilerObserver::reportStatechartLocalParametersList
void reportStatechartLocalParametersList(const ProfilerStatechartParametersList &localParametersList, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:327
armarx::ProfilerObserver::reportStatechartInputParametersList
void reportStatechartInputParametersList(const ProfilerStatechartParametersList &inputParametersList, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:312
armarx::statechartmodel::StateParameterMap
QMap< QString, StateParameterPtr > StateParameterMap
Definition: StateParameter.h:46
armarx::ProfilerObserver::~ProfilerObserver
~ProfilerObserver() override
Definition: ProfilerObserver.cpp:40
armarx::ProfilerObserver::reportStatechartLocalParameters
void reportStatechartLocalParameters(const ProfilerStatechartParameters &localParameters, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:218
armarx::ProfilerObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: ProfilerObserver.cpp:56
armarx::ProfilerObserver::reportStatechartTransition
void reportStatechartTransition(const ProfilerStatechartTransition &transition, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:166
armarx::ProfilerObserver::reportProcessCpuUsageList
void reportProcessCpuUsageList(const ProfilerProcessCpuUsageList &processes, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:363
armarx::ProfilerObserver::reportProcessCpuUsage
void reportProcessCpuUsage(const ProfilerProcessCpuUsage &process, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:130
armarx::ProfilerObserver::reportNetworkTraffic
void reportNetworkTraffic(const std::string &id, const std::string &protocol, Ice::Int inBytes, Ice::Int outBytes, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:69
armarx::ProfilerObserver::reportStatechartTransitionList
void reportStatechartTransitionList(const ProfilerStatechartTransitionList &transitions, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:305
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
armarx::ProfilerObserver::reportStatechartOutputParameters
void reportStatechartOutputParameters(const ProfilerStatechartParameters &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:236
armarx::ProfilerObserver::reportProcessMemoryUsage
void reportProcessMemoryUsage(const ProfilerProcessMemoryUsage &memoryUsage, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:147
armarx::ProfilerObserver::reportStatechartOutputParametersList
void reportStatechartOutputParametersList(const ProfilerStatechartParametersList &outputParametersList, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:342
armarx::StringValueMap
The StringValueMap class is a subclass of VariantContainer and is comparable to a std::map<std::strin...
Definition: StringValueMap.h:49
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::ProfilerObserver::reportEvent
void reportEvent(const ProfilerEvent &event, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:88
armarx::ProfilerObserver::reportStatechartTransitionWithParameters
void reportStatechartTransitionWithParameters(const ProfilerStatechartTransitionWithParameters &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerObserver.cpp:253