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 <chrono>
25 
26 #include "DebugObserver.h"
27 
29 
32 
33 namespace armarx
34 {
35 
37  {
38  }
39 
41  {
42  usingTopic(getProperty<std::string>("DebugObserverTopicName"));
43 
46  }
47 
49  {
50  }
51 
53  const AMD_DebugObserverInterface_setDebugDatafieldPtr& amd,
54  const std::string& channelName,
55  const std::string& datafieldName,
56  const VariantBasePtr& value,
57  const Ice::Current& c)
58  {
59  addWorkerJob("DebugObserver::setDebugDatafield", [this, amd, channelName, datafieldName, value]
60  {
62  {
63  if (!existsChannel(channelName))
64  {
65  offerChannel(channelName, "");
66  }
67 
68  if (!existsDataField(channelName, datafieldName))
69  {
70  offerDataFieldWithDefault(channelName, datafieldName, *VariantPtr::dynamicCast(value), "");
71  }
72  else
73  {
74  setDataFieldFlatCopy(channelName, datafieldName, VariantPtr::dynamicCast(value));
75  }
76 
77  updateChannel(channelName);
78  amd->ice_response();
79  });
80  });
81  }
82 
84  const AMD_DebugObserverInterface_setDebugChannelPtr& amd,
85  const std::string& channelName,
86  const StringVariantBaseMap& valueMap,
87  const Ice::Current& c)
88  {
89  addWorkerJob("DebugObserver::setDebugChannel", [this, amd, channelName, valueMap]
90  {
92  {
93  offerOrUpdateDataFieldsFlatCopy(channelName, valueMap);
94  amd->ice_response();
95  });
96  });
97  }
98 
100  const AMD_DebugObserverInterface_removeDebugDatafieldPtr& amd,
101  const std::string& channelName,
102  const std::string& datafieldName,
103  const Ice::Current&)
104  {
105  addWorkerJob("DebugObserver::removeDebugDatafield", [this, amd, channelName, datafieldName]
106  {
108  {
109  removeDatafield(new DataFieldIdentifier(getName(), channelName, datafieldName));
110  amd->ice_response();
111  });
112  });
113  }
114 
116  const AMD_DebugObserverInterface_removeDebugChannelPtr& amd,
117  const std::string& channelName,
118  const Ice::Current&)
119  {
120  addWorkerJob("DebugObserver::removeDebugChannel", [this, amd, channelName]
121  {
123  {
124  removeChannel(channelName);
125  amd->ice_response();
126  });
127  });
128  }
129 
131  const AMD_DebugObserverInterface_removeAllChannelsPtr& amd,
132  const Ice::Current&)
133  {
134  addWorkerJob("DebugObserver::removeAllChannels", [this, amd]
135  {
137  {
138  ChannelRegistry channels = getAvailableChannels(false);
139  ChannelRegistry::iterator it = channels.end();
140 
141  for (; it != channels.end(); it++)
142  {
143  ChannelRegistryEntry& entry = it->second;
144  removeChannel(entry.name);
145  }
146  amd->ice_response();
147  });
148  });
149  }
150 }
151 
152 
154 {
157 }
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:715
DebugObserver.h
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::DebugObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DebugObserver.cpp:153
armarx::DebugObserver::DebugObserver
DebugObserver()
Definition: DebugObserver.cpp:36
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:289
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::DebugObserver::removeAllChannels_async
void removeAllChannels_async(const AMD_DebugObserverInterface_removeAllChannelsPtr &amd, const ::Ice::Current &) override
Removes all channels.
Definition: DebugObserver.cpp:130
armarx::Observer::existsChannel
bool existsChannel(const std::string &channelName) const
Definition: Observer.cpp:1433
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:115
IceInternal::Handle<::armarx::VariantBase >
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
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:501
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:99
InvalidDatafieldException.h
armarx::Observer::offerOrUpdateDataFieldsFlatCopy
void offerOrUpdateDataFieldsFlatCopy(const std::string &channelName, const StringVariantBaseMap &valueMap)
Definition: Observer.cpp:236
armarx::DebugObserverPropertyDefinitions
Definition: DebugObserver.h:36
armarx::Observer::removeDatafield
void removeDatafield(DataFieldIdentifierBasePtr id)
Definition: Observer.cpp:314
armarx::DebugObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: DebugObserver.cpp:48
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:248
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
armarx::Observer::getAvailableChannels
ChannelRegistry getAvailableChannels(bool includeMetaChannels)
Retrieve information on all sensory data channels available from the observer.
Definition: Observer.cpp:1396
armarx::Observer::existsDataField
bool existsDataField(const std::string &channelName, const std::string &datafieldName) const
Definition: Observer.cpp:1450
IceUtil::Handle< class PropertyDefinitionContainer >
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:52
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:83
armarx::ConditionCheckEquals
Definition: ConditionCheckEquals.h:46
armarx::Observer::offerConditionCheck
void offerConditionCheck(std::string checkName, ConditionCheck *conditionCheck)
Offer a condition check.
Definition: Observer.cpp:273
armarx::ManagedIceObject::getName
std::string getName() const
Retrieve name of object.
Definition: ManagedIceObject.cpp:107
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:152
armarx::Observer::addWorkerJob
void addWorkerJob(const std::string &name, std::function< void(void)> &&f) const
Definition: Observer.cpp:1099
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
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:506
ConditionCheckUpdated.h
armarx::Observer::offerChannel
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition: Observer.cpp:126