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
31
32namespace 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,
58 const std::string& protocol,
59 Ice::Int inBytes,
60 Ice::Int outBytes,
61 const Ice::Current& = Ice::emptyCurrent) override;
62 void reportEvent(const ProfilerEvent& event,
63 const Ice::Current& = Ice::emptyCurrent) override;
64
65 void reportStatechartTransition(const ProfilerStatechartTransition& transition,
66 const Ice::Current& = Ice::emptyCurrent) override;
67 void reportStatechartInputParameters(const ProfilerStatechartParameters& inputParametes,
68 const Ice::Current& = Ice::emptyCurrent) override;
69 void reportStatechartLocalParameters(const ProfilerStatechartParameters& localParameters,
70 const Ice::Current& = Ice::emptyCurrent) override;
71 void reportStatechartOutputParameters(const ProfilerStatechartParameters& outputParameters,
72 const Ice::Current& = Ice::emptyCurrent) override;
74 const ProfilerStatechartTransitionWithParameters& outputParameters,
75 const Ice::Current& = Ice::emptyCurrent) override;
76
77 void reportProcessCpuUsage(const ProfilerProcessCpuUsage& process,
78 const Ice::Current& = Ice::emptyCurrent) override;
79 void reportProcessMemoryUsage(const ProfilerProcessMemoryUsage& memoryUsage,
80 const Ice::Current& = Ice::emptyCurrent) override;
81
82
83 void reportEventList(const ProfilerEventList& events,
84 const Ice::Current& = Ice::emptyCurrent) override;
85
86 void reportStatechartTransitionList(const ProfilerStatechartTransitionList& transitions,
87 const Ice::Current& = Ice::emptyCurrent) override;
89 const ProfilerStatechartParametersList& inputParametersList,
90 const ::Ice::Current& = Ice::emptyCurrent) override;
92 const ProfilerStatechartParametersList& localParametersList,
93 const Ice::Current& = Ice::emptyCurrent) override;
95 const ProfilerStatechartParametersList& outputParametersList,
96 const Ice::Current& = Ice::emptyCurrent) override;
98 const ProfilerStatechartTransitionWithParametersList& outputParameters,
99 const Ice::Current& = Ice::emptyCurrent) override;
100
101 void reportProcessCpuUsageList(const ProfilerProcessCpuUsageList& processes,
102 const Ice::Current& = Ice::emptyCurrent) override;
103 void reportProcessMemoryUsageList(const ProfilerProcessMemoryUsageList& memoryUsages,
104 const Ice::Current& = Ice::emptyCurrent) override;
105
106 private:
107 /**
108 * @brief createStateChannelIfRequired if channel with @p channelName does not exist, create it and all required datafields
109 * @param channelName
110 */
111 void createStateChannelIfRequired(const std::string& channelName);
112 /**
113 * @brief createResourceChannelIfRequired if channel with @p channelName does not exist, create it and all required datafields
114 * @param channelName
115 */
116 void createResourceChannelIfRequired(const std::string& channelName);
117
118 static void StateParameterToVariantMap(const armarx::StateParameterMap& parameterMap,
119 armarx::StringValueMap& variantMap);
120 std::mutex channelCheckMutex;
121 };
122} // namespace armarx
void reportStatechartInputParametersList(const ProfilerStatechartParametersList &inputParametersList, const ::Ice::Current &=Ice::emptyCurrent) override
void onConnectObserver() override
Framework hook.
void reportNetworkTraffic(const std::string &id, const std::string &protocol, Ice::Int inBytes, Ice::Int outBytes, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartTransition(const ProfilerStatechartTransition &transition, const Ice::Current &=Ice::emptyCurrent) override
void reportEventList(const ProfilerEventList &events, const Ice::Current &=Ice::emptyCurrent) override
void reportProcessMemoryUsage(const ProfilerProcessMemoryUsage &memoryUsage, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartTransitionList(const ProfilerStatechartTransitionList &transitions, const Ice::Current &=Ice::emptyCurrent) override
void reportProcessCpuUsageList(const ProfilerProcessCpuUsageList &processes, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartTransitionWithParametersList(const ProfilerStatechartTransitionWithParametersList &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
void reportProcessCpuUsage(const ProfilerProcessCpuUsage &process, const Ice::Current &=Ice::emptyCurrent) override
void reportEvent(const ProfilerEvent &event, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartLocalParametersList(const ProfilerStatechartParametersList &localParametersList, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartOutputParametersList(const ProfilerStatechartParametersList &outputParametersList, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartInputParameters(const ProfilerStatechartParameters &inputParametes, const Ice::Current &=Ice::emptyCurrent) override
void onInitObserver() override
Framework hook.
void reportStatechartTransitionWithParameters(const ProfilerStatechartTransitionWithParameters &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
void reportProcessMemoryUsageList(const ProfilerProcessMemoryUsageList &memoryUsages, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartLocalParameters(const ProfilerStatechartParameters &localParameters, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartOutputParameters(const ProfilerStatechartParameters &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
std::string getDefaultName() const override
Retrieve default name of component.
The StringValueMap class is a subclass of VariantContainer and is comparable to a std::map<std::strin...
This file offers overloads of toIce() and fromIce() functions for STL container types.