25#include <boost/hana/for_each.hpp>
27#include <SimoxUtility/meta/boost_hana.h>
28#include <SimoxUtility/meta/enum/adapt_enum.h>
32#include <ArmarXCore/interface/observers/ObserverInterface.h>
60 bool batchmode =
false) :
86 const std::string& datafieldName,
89 const std::string& datafieldName,
92 const std::string& datafieldName,
98 const std::string& datafieldName,
107 const std::string& datafieldName,
108 const IceUtil::Time& time,
109 const T& value)
const
113 using VariantIntMaxT = Ice::Int;
114 [[maybe_unused]]
static constexpr std::uint64_t IceIntTMax =
115 static_cast<std::uint64_t
>(std::numeric_limits<VariantIntMaxT>::max());
116 if constexpr (std::is_same_v<T, IceUtil::Time> ||
123 else if constexpr (std::is_unsigned_v<T> && !std::is_same_v<bool, T>)
126 if (_float_fallback_for_big_too_large_ints)
128 if (value < IceIntTMax)
146 else if constexpr (simox::meta::has_hana_accessor_v<T>)
149 namespace hana = boost::hana;
150 static constexpr auto accessors = hana::accessors<T>();
151 hana::for_each(accessors,
155 const auto varname = hana::to<char const*>(hana::first(e));
156 const auto elemName = datafieldName +
'_' + varname;
158 channelName, elemName, time, hana::second(e)(value));
162 else if constexpr (simox::meta::is_enum_adapted_v<T>)
167 else if constexpr (std::is_same_v<char, T>)
180 template <
class T,
class... Ts>
183 const std::string& datafieldName,
184 const std::chrono::duration<Ts...> duration,
185 const T& value)
const
191 IceUtil::Time::microSeconds(
192 std::chrono::duration_cast<std::chrono::microseconds>(duration).count()),
196 template <
class T,
class... Ts>
199 const std::string& datafieldName,
200 const std::chrono::time_point<Ts...> timepoint,
201 const T& value)
const
205 channelName, datafieldName, timepoint.time_since_epoch(), value);
209 const std::string& datafieldName,
210 const IceUtil::Time& time,
213 template <
class... Ts>
216 const std::string& datafieldName,
217 const std::chrono::duration<Ts...> duration,
224 IceUtil::Time::microSeconds(
225 std::chrono::duration_cast<std::chrono::microseconds>(duration).count()),
229 template <
class... Ts>
232 const std::string& datafieldName,
233 const std::chrono::time_point<Ts...> timepoint,
238 channelName, datafieldName, timepoint.time_since_epoch(), value);
242 const std::string& datafieldName,
243 const IceUtil::Time& time,
246 template <
class... Ts>
249 const std::string& datafieldName,
250 const std::chrono::duration<Ts...> duration,
257 IceUtil::Time::microSeconds(
258 std::chrono::duration_cast<std::chrono::microseconds>(duration).count()),
262 template <
class... Ts>
265 const std::string& datafieldName,
266 const std::chrono::time_point<Ts...> timepoint,
271 channelName, datafieldName, timepoint.time_since_epoch(), value);
288 const std::string& datafieldName)
const;
297 std::string _channelName;
299 bool _batchMode{
false};
300 mutable std::map<std::string, StringVariantBaseMap> _batch;
301 bool _float_fallback_for_big_too_large_ints =
true;
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const T &t)
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const TimedVariantPtr &value) const
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const std::chrono::duration< Ts... > duration, const VariantPtr &value) const
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const std::chrono::duration< Ts... > duration, const T &value) const
void setDebugObserverChannel(const std::string &channelName, StringVariantBaseMap valueMap) const
DebugObserverHelper(const T &name, const DebugObserverInterfacePrx &prx=nullptr, bool batchmode=false)
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const std::chrono::time_point< Ts... > timepoint, const VariantPtr &value) const
void removeAllDebugObserverChannels() const
void removeDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName) const
void setChannelName(const std::string &name)
const DebugObserverInterfacePrx & getDebugObserver() const
void removeDebugObserverChannel(const std::string &channelname) const
DebugObserverHelper(const DebugObserverInterfacePrx &prx=nullptr, bool batchmode=false)
void sendDebugObserverBatch()
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const std::chrono::time_point< Ts... > timepoint, const Variant &value) const
void setDebugObserverDatafield(const std::string &datafieldName, const T &t)
void setDebugObserver(const DebugObserverInterfacePrx &prx)
void setDebugObserverBatchModeEnabled(bool enable)
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const std::chrono::duration< Ts... > duration, const Variant &value) const
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const std::chrono::time_point< Ts... > timepoint, const T &value) const
void setFloatFallbackForBigTooLargeInts(bool useFallback)
const std::string & getChannelName() const
void setDebugObserverDatafield(const std::string &channelName, const std::string &datafieldName, const IceUtil::Time &time, const T &value) const
The ManagedIceObject is the base class for all ArmarX objects.
Implements a Variant type for timestamps.
The Variant class is described here: Variants.
#define ARMARX_CHECK_LESS_EQUAL(lhs, rhs)
This macro evaluates whether lhs is less or equal (<=) rhs and if it turns out to be false it will th...
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceInternal::Handle< TimedVariant > TimedVariantPtr
IceInternal::Handle< Variant > VariantPtr
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr
#define ARMARX_TRACE_LITE