StateWatcher.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package Mirko Waechter
17* @author (waechter at kit dot edu)
18* @date 2015
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22#pragma once
23#include <mutex>
24
27#include <ArmarXCore/interface/observers/ProfilerObserverInterface.h>
29
32
33namespace armarx
34{
35
36 class StateWatcher : public armarx::ManagedIceObject, public ProfilerListener
37 // public EventListenerInterface
38 {
39 public:
41 {
42 StateIceBasePtr iceState;
43 std::set<statechartmodel::StatePtr> states;
44 std::set<StateItem*> stateItems;
45 std::map<std::string, ::armarx::StateParameterMap> parameters;
46 };
47
48 using StateListenerDataMap = std::map<std::string, StateListenerData>;
49
51 bool subscribeToState(StateIceBasePtr iceState, StateItem* state);
52 bool subscribeToState(StateIceBasePtr iceState, statechartmodel::StatePtr state);
53 bool unsubscribeState(StateItem* state);
55 const std::string paramMapType) const;
56 ::armarx::StateParameterMap getStateParameterMap(statechartmodel::StatePtr state,
57 const std::string paramMapType) const;
58
59 void clear();
60
61 static std::string ExtractStateName(const std::string globalIdString);
62 // ManagedIceObject interface
63 std::string getDefaultName() const override;
64
65 protected:
66 void onInitComponent() override;
67 void onConnectComponent() override;
68 void onDisconnectComponent() override;
69
71
73 mutable std::mutex mapMutex;
74 ConditionHandlerInterfacePrx conditionHandler;
75 ProfilerObserverInterfacePrx profilerObserver;
76 using SubscriptionMap = std::vector<
77 std::pair<StateIceBasePtr, std::pair<statechartmodel::StatePtr, StateItem*>>>;
80
81
82 // ProfilerListener interface
83 public:
84 void reportNetworkTraffic(const std::string&,
85 const std::string&,
86 Ice::Int,
87 Ice::Int,
88 const Ice::Current&) override;
89 void reportEvent(const ProfilerEvent&, const Ice::Current&) override;
90 void reportStatechartTransition(const ProfilerStatechartTransition& event,
91 const Ice::Current&) override;
92 void reportStatechartInputParameters(const ProfilerStatechartParameters& event,
93 const Ice::Current&) override;
94 void reportStatechartLocalParameters(const ProfilerStatechartParameters& event,
95 const Ice::Current&) override;
96 void reportStatechartOutputParameters(const ProfilerStatechartParameters&,
97 const Ice::Current&) override;
98 void reportProcessCpuUsage(const ProfilerProcessCpuUsage&, const Ice::Current&) override;
99 void reportProcessMemoryUsage(const ProfilerProcessMemoryUsage&,
100 const Ice::Current&) override;
101 void reportEventList(const ProfilerEventList&, const Ice::Current&) override;
102 void reportStatechartTransitionList(const ProfilerStatechartTransitionList&,
103 const Ice::Current&) override;
104 void reportStatechartInputParametersList(const ProfilerStatechartParametersList& data,
105 const Ice::Current&) override;
106 void reportStatechartLocalParametersList(const ProfilerStatechartParametersList&,
107 const Ice::Current&) override;
108 void reportStatechartOutputParametersList(const ProfilerStatechartParametersList&,
109 const Ice::Current&) override;
110 void reportProcessCpuUsageList(const ProfilerProcessCpuUsageList&,
111 const Ice::Current&) override;
112 void reportProcessMemoryUsageList(const ProfilerProcessMemoryUsageList&,
113 const Ice::Current&) override;
114
115 void
116 reportStatechartTransitionWithParameters(const ProfilerStatechartTransitionWithParameters&,
117 const Ice::Current&) override
118 {
119 }
120
121 void
123 const ProfilerStatechartTransitionWithParametersList&,
124 const Ice::Current&) override
125 {
126 }
127 };
129} // namespace armarx
The ManagedIceObject is the base class for all ArmarX objects.
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
void onInitComponent() override
Pure virtual hook for the subclass.
void reportStatechartInputParameters(const ProfilerStatechartParameters &event, const Ice::Current &) override
std::vector< std::pair< StateIceBasePtr, std::pair< statechartmodel::StatePtr, StateItem * > > > SubscriptionMap
::armarx::StateParameterMap getStateParameterMap(statechartmodel::StatePtr state, const std::string paramMapType) const
VariantPtr getStateParameter(statechartmodel::StatePtr state, const std::string paramMapType) const
void onDisconnectComponent() override
Hook for subclass.
void reportStatechartOutputParameters(const ProfilerStatechartParameters &, const Ice::Current &) override
void reportStatechartLocalParameters(const ProfilerStatechartParameters &event, const Ice::Current &) override
void reportStatechartLocalParametersList(const ProfilerStatechartParametersList &, const Ice::Current &) override
SubscriptionMap subscriptionQueue
void reportStatechartTransitionList(const ProfilerStatechartTransitionList &, const Ice::Current &) override
void reportProcessCpuUsageList(const ProfilerProcessCpuUsageList &, const Ice::Current &) override
void reportNetworkTraffic(const std::string &, const std::string &, Ice::Int, Ice::Int, const Ice::Current &) override
bool unsubscribeState(StateItem *state)
void reportStatechartTransitionWithParameters(const ProfilerStatechartTransitionWithParameters &, const Ice::Current &) override
void reportStatechartInputParametersList(const ProfilerStatechartParametersList &data, const Ice::Current &) override
void reportProcessCpuUsage(const ProfilerProcessCpuUsage &, const Ice::Current &) override
ConditionHandlerInterfacePrx conditionHandler
void onConnectComponent() override
Pure virtual hook for the subclass.
void reportEvent(const ProfilerEvent &, const Ice::Current &) override
ProfilerObserverInterfacePrx profilerObserver
void reportStatechartTransitionWithParametersList(const ProfilerStatechartTransitionWithParametersList &, const Ice::Current &) override
static std::string ExtractStateName(const std::string globalIdString)
void reportProcessMemoryUsageList(const ProfilerProcessMemoryUsageList &, const Ice::Current &) override
void reportEventList(const ProfilerEventList &, const Ice::Current &) override
bool subscribeToState(StateIceBasePtr iceState, StateItem *state)
PeriodicTask< StateWatcher >::pointer_type subscriptionTask
StateListenerDataMap stateMap
void reportStatechartOutputParametersList(const ProfilerStatechartParametersList &, const Ice::Current &) override
void reportStatechartTransition(const ProfilerStatechartTransition &event, const Ice::Current &) override
std::string getDefaultName() const override
Retrieve default name of component.
std::map< std::string, StateListenerData > StateListenerDataMap
void reportProcessMemoryUsage(const ProfilerProcessMemoryUsage &, const Ice::Current &) override
std::shared_ptr< State > StatePtr
Definition State.h:48
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Variant > VariantPtr
Definition Variant.h:41
IceInternal::Handle< StateWatcher > StateWatcherPtr
std::set< statechartmodel::StatePtr > states
std::map< std::string, ::armarx::StateParameterMap > parameters