DebugObserver.cpp
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 #include "DebugObserver.h"
25 
26 #include <chrono>
27 
31 
32 namespace armarx
33 {
34 
36  {
37  }
38 
39  void
41  {
42  usingTopic(getProperty<std::string>("DebugObserverTopicName"));
43 
46  }
47 
48  void
50  {
51  }
52 
53  void
55  const AMD_DebugObserverInterface_setDebugDatafieldPtr& amd,
56  const std::string& channelName,
57  const std::string& datafieldName,
58  const VariantBasePtr& value,
59  const Ice::Current& c)
60  {
62  "DebugObserver::setDebugDatafield",
63  [this, amd, channelName, datafieldName, value]
64  {
66  amd,
67  [&]
68  {
69  if (!existsChannel(channelName))
70  {
71  offerChannel(channelName, "");
72  }
73 
74  if (!existsDataField(channelName, datafieldName))
75  {
77  channelName, datafieldName, *VariantPtr::dynamicCast(value), "");
78  }
79  else
80  {
82  channelName, datafieldName, VariantPtr::dynamicCast(value));
83  }
84 
85  updateChannel(channelName);
86  amd->ice_response();
87  });
88  });
89  }
90 
91  void
92  DebugObserver::setDebugChannel_async(const AMD_DebugObserverInterface_setDebugChannelPtr& amd,
93  const std::string& channelName,
94  const StringVariantBaseMap& valueMap,
95  const Ice::Current& c)
96  {
97  addWorkerJob("DebugObserver::setDebugChannel",
98  [this, amd, channelName, valueMap]
99  {
101  [&]
102  {
104  valueMap);
105  amd->ice_response();
106  });
107  });
108  }
109 
110  void
112  const AMD_DebugObserverInterface_removeDebugDatafieldPtr& amd,
113  const std::string& channelName,
114  const std::string& datafieldName,
115  const Ice::Current&)
116  {
117  addWorkerJob("DebugObserver::removeDebugDatafield",
118  [this, amd, channelName, datafieldName]
119  {
121  [&]
122  {
124  getName(), channelName, datafieldName));
125  amd->ice_response();
126  });
127  });
128  }
129 
130  void
132  const AMD_DebugObserverInterface_removeDebugChannelPtr& amd,
133  const std::string& channelName,
134  const Ice::Current&)
135  {
136  addWorkerJob("DebugObserver::removeDebugChannel",
137  [this, amd, channelName]
138  {
140  [&]
141  {
142  removeChannel(channelName);
143  amd->ice_response();
144  });
145  });
146  }
147 
148  void
150  const AMD_DebugObserverInterface_removeAllChannelsPtr& amd,
151  const Ice::Current&)
152  {
153  addWorkerJob("DebugObserver::removeAllChannels",
154  [this, amd]
155  {
157  [&]
158  {
159  ChannelRegistry channels =
160  getAvailableChannels(false);
161  ChannelRegistry::iterator it =
162  channels.end();
163 
164  for (; it != channels.end(); it++)
165  {
166  ChannelRegistryEntry& entry = it->second;
167  removeChannel(entry.name);
168  }
169  amd->ice_response();
170  });
171  });
172  }
173 } // namespace armarx
174 
177 {
179 }
armarx::Observer::updateChannel
void updateChannel(const std::string &channelName, const std::set< std::string > &updatedDatafields=std::set< std::string >())
Update all conditions for a channel.
Definition: Observer.cpp:788
DebugObserver.h
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:110
armarx::DebugObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DebugObserver.cpp:176
armarx::DebugObserver::DebugObserver
DebugObserver()
Definition: DebugObserver.cpp:35
ConditionCheckEquals.h
armarx::DebugObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: DebugObserver.cpp:40
armarx::Observer::removeChannel
void removeChannel(std::string channelName)
Remove a channel.
Definition: Observer.cpp:318
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::DebugObserver::removeAllChannels_async
void removeAllChannels_async(const AMD_DebugObserverInterface_removeAllChannelsPtr &amd, const ::Ice::Current &) override
Removes all channels.
Definition: DebugObserver.cpp:149
armarx::Observer::existsChannel
bool existsChannel(const std::string &channelName) const
Definition: Observer.cpp:1552
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::ConditionCheckUpdated
Definition: ConditionCheckUpdated.h:41
armarx::Observer::setDataFieldFlatCopy
void setDataFieldFlatCopy(const std::string &channelName, const std::string &datafieldName, const VariantPtr &value, bool triggerFilterUpdate=true)
Definition: Observer.cpp:548
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
InvalidDatafieldException.h
armarx::Observer::offerOrUpdateDataFieldsFlatCopy
void offerOrUpdateDataFieldsFlatCopy(const std::string &channelName, const StringVariantBaseMap &valueMap)
Definition: Observer.cpp:260
armarx::DebugObserverPropertyDefinitions
Definition: DebugObserver.h:36
armarx::Observer::removeDatafield
void removeDatafield(DataFieldIdentifierBasePtr id)
Definition: Observer.cpp:344
armarx::DebugObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: DebugObserver.cpp:49
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:254
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
armarx::Observer::getAvailableChannels
ChannelRegistry getAvailableChannels(bool includeMetaChannels)
Retrieve information on all sensory data channels available from the observer.
Definition: Observer.cpp:1510
armarx::Observer::existsDataField
bool existsDataField(const std::string &channelName, const std::string &datafieldName) const
Definition: Observer.cpp:1569
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::ConditionCheckEquals
Definition: ConditionCheckEquals.h:46
armarx::Observer::offerConditionCheck
void offerConditionCheck(std::string checkName, ConditionCheck *conditionCheck)
Offer a condition check.
Definition: Observer.cpp:301
armarx::ManagedIceObject::getName
std::string getName() const
Retrieve name of object.
Definition: ManagedIceObject.cpp:108
armarx::Observer::offerDataFieldWithDefault
void offerDataFieldWithDefault(std::string channelName, std::string datafieldName, const Variant &defaultValue, std::string description)
Offer a datafield with default value.
Definition: Observer.cpp:160
armarx::Observer::addWorkerJob
void addWorkerJob(const std::string &name, std::function< void(void)> &&f) const
Definition: Observer.cpp:1195
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48
armarx::Observer::callAndPassExceptionToAMD
void callAndPassExceptionToAMD(auto &amd, auto f) const
Definition: Observer.h:514
ConditionCheckUpdated.h
armarx::Observer::offerChannel
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition: Observer.cpp:131