CVB++ 14.1
float_node.hpp
1#pragma once
2
3#include "../global.hpp"
4
5#include "float_base_node.hpp"
6
8#include "_detail/ihas_value_config.hpp"
9#include "_detail/iconfigurable_register_node.hpp"
10#include "_detail/iconfigurable_command_node.hpp"
12
13namespace Cvb
14{
15 CVB_BEGIN_INLINE_NS
16 namespace GevServer
17 {
19
22 : public FloatBaseNode
24 , public Private::IHasValueConfig<FloatBaseNodePtr>
26 {
27 public:
28 explicit FloatNode(HandleGuard<Node>&& guard) : FloatBaseNode(std::move(guard)) {}
29
40 static FloatNodePtr Create(const String& name, const GevServer::Namespace& nameSpace)
41 {
42 return std::make_shared<FloatNode>(HandleGuard<Node>(
43 CExports::CreateGSFloatNodeTyped(name.data(), static_cast<CExports::TGSNamespace>(nameSpace))));
44 }
45
59 static FloatNodePtr Create(const String& name) { return Create(ParseName(name), ParseNamespace(name)); }
60
74 template <class T> T IncrementConfig() const
75 {
76 throw std::runtime_error("requested increment config type must be derived from FloatNode or "
77 "be "
78 "of type double");
79 }
80
82
90 template <class T> void SetIncrementConfig(const T& /*value*/)
91 {
92 throw std::runtime_error("requested value config type must be derived from "
93 "FloatNode or be of type double");
94 }
95
101 {
102 auto value = GetTerminalRegisterNode<FloatNode, FloatBaseNodePtr>(
103 this, [](Node* node) {
104 return dynamic_cast<Private::IConfigurableRegisterNode*>(node) ? true : false;
105 });
106 if (value == nullptr)
108 else
109 return value->AccessMode();
110 }
111
117 {
118 auto value = GetTerminalRegisterNode<FloatNode, FloatBaseNodePtr>(
119 this, [](Node* node) { return dynamic_cast<Private::IConfigurableRegisterNode*>(node) ? true : false; });
120 if (value == nullptr)
122 else
123 return value->CacheMode();
124 }
125
130 template <class Rep, class Period> std::chrono::duration<Rep, Period> PollingTime() const
131 {
132 auto value = GetTerminalRegisterNode<FloatNode, FloatBaseNodePtr>(this, [](Node* node) {
133 auto isRegisterNode = dynamic_cast<Private::IConfigurableRegisterNode*>(node);
134 auto isCommandNode = dynamic_cast<Private::IConfigurableCommandNode*>(node);
135 return (isRegisterNode || isCommandNode) ? true : false;
136 });
137 if (value == nullptr)
139 else
140 return value->template PollingTime<Rep, Period>();
141 }
142
151 template <class T> T MaxConfig() const
152 {
153 throw std::runtime_error("requested max config type must be derived from FloatNode or be "
154 "of type double");
155 }
156
169 template <class T> void SetMaxConfig(const T& /*value*/)
170 {
171 throw std::runtime_error("requested value config type must be derived from "
172 "FloatNode or be of type double");
173 }
174
183 template <class T> T MinConfig() const
184 {
185 throw std::runtime_error("requested min config type must be derived from FloatNode or be "
186 "of type double");
187 }
188
201 template <class T> void SetMinConfig(const T& /*value*/)
202 {
203 throw std::runtime_error("requested min config type must be derived from "
204 "FloatNode or be of type double");
205 }
206
208
212 String Unit() const
213 {
214 auto bufferSize = NativeCall<size_t>([&](size_t& size) {
215 return CExports::GSNGetInfoAsStringTyped(
216 Handle(), CExports::TGSNodeInfo::GSNI_Unit, reinterpret_cast<Char*>(0), size);
217 });
218
219 bufferSize += sizeof(Char);
220 std::vector<Char> buffer(bufferSize);
221 NativeCall([&]() {
222 return CExports::GSNGetInfoAsStringTyped(
223 Handle(), CExports::TGSNodeInfo::GSNI_Unit, buffer.data(), bufferSize);
224 });
225
226 return buffer.data() ? String(buffer.data()) : String();
227 }
228
230
234 void SetUnit(const String& unit)
235 {
236 SetInfo(NodeInfo::Unit, unit);
237 }
238
240 // TODO: This is currently not implemented in the RegMap. As I did not find it in a camera xml either (not important?!),
241 // I'd like to keep this TODO rather then a "not implemented" which makes customers want this.
244 // * \return Display notation of this node as text.
245 // * \throws Any exception derived from std::exception including CvbException.
246 // */
247 //String DisplayNotation() const
248 //{
249
250 //}
251
252 //void SetDisplayNotation(const String& displayNotation)
253 //{
254
255 //}
257
259
263 double DisplayPrecision() const
264 {
265 return GetInfoAsFloat(NodeInfo::DisplayPrecision);
266 }
267
269
274 void SetDisplayPrecision(const double displayPrecision)
275 {
276 SetInfoAsFloat(NodeInfo::DisplayPrecision, displayPrecision);
277 }
278
279 FloatBaseNodePtr ValueConfigAsNode() const override;
280
290 template <class T> T ValueConfig() const
291 {
292 throw std::runtime_error("requested value config type must be derived from FloatNode or be "
293 "of type double");
294 }
295
309 template <class T> void SetValueConfig(const T& /*value*/)
310 {
311 throw std::runtime_error("requested value config type must be derived from "
312 "FloatNode or be of type double");
313 }
314 };
315
316 template <> inline double FloatNode::MaxConfig<double>() const
317 {
318 return GetInfoAsFloat(NodeInfo::Max);
319 }
320
321 template <> inline void FloatNode::SetMaxConfig<double>(const double& value)
322 {
323 SetInfoAsFloat(NodeInfo::Max, value);
324 }
325
326 template <> inline double FloatNode::MinConfig<double>() const
327 {
328 return GetInfoAsFloat(NodeInfo::Min);
329 }
330
331 template <> inline void FloatNode::SetMinConfig<double>(const double& value)
332 {
333 SetInfoAsFloat(NodeInfo::Min, value);
334 }
335
336 template <> inline double FloatNode::ValueConfig<double>() const
337 {
338 return GetInfoAsFloat(NodeInfo::Value);
339 }
340
341 template <> inline double FloatNode::IncrementConfig<double>() const
342 {
343 return GetInfoAsFloat(NodeInfo::Increment);
344 }
345
346 template <> inline void FloatNode::SetIncrementConfig<double>(const double& value)
347 {
348 SetInfoAsFloat(NodeInfo::Increment, value);
349 }
350
351 template <> inline void FloatNode::SetValueConfig<double>(const double& value)
352 {
353 SetInfoAsFloat(NodeInfo::Value, value);
354 }
355
356 }
357 CVB_END_INLINE_NS
358}
Represents a floating point number.
Definition: float_base_node.hpp:19
Represents a floating point number.
Definition: float_node.hpp:26
void SetDisplayPrecision(const double displayPrecision)
Sets the display precision of this node's value.
Definition: float_node.hpp:274
void SetMinConfig(const T &)
Sets the minimum configuration of this float node.
Definition: float_node.hpp:201
void SetMaxConfig(const T &)
Sets the maximum configuration of this float node.
Definition: float_node.hpp:169
T MaxConfig() const
Gets the maximum configuration of this float node.
Definition: float_node.hpp:151
void SetUnit(const String &unit)
Sets the unit of this node's value.
Definition: float_node.hpp:234
void SetIncrementConfig(const T &)
Sets the increment of this value.
Definition: float_node.hpp:90
String Unit() const
Gets the unit of this node's value.
Definition: float_node.hpp:212
void SetValueConfig(const T &)
Sets the value configuration of this float node.
Definition: float_node.hpp:309
T MinConfig() const
Gets the minimum configuration of this float node.
Definition: float_node.hpp:183
static FloatNodePtr Create(const String &name)
Creates a new FloatNode with the given name .
Definition: float_node.hpp:59
GenApi::CacheMode CacheMode() const override
Gets the cache mode by querying all ValueConfigs for it.
Definition: float_node.hpp:116
T ValueConfig() const
Gets the value configuration of this float node.
Definition: float_node.hpp:290
GenApi::AccessMode AccessMode() const override
Gets the access mode by querying all ValueConfigs for it.
Definition: float_node.hpp:100
double DisplayPrecision() const
Gets the current display precision value.
Definition: float_node.hpp:263
T IncrementConfig() const
Gets and sets the increment configuration of this float node.
Definition: float_node.hpp:74
static FloatNodePtr Create(const String &name, const GevServer::Namespace &nameSpace)
Creates a new FloatNode with the given name and nameSpace .
Definition: float_node.hpp:40
std::chrono::duration< Rep, Period > PollingTime() const
Gets the polling time by querying all ValueConfigs for it.
Definition: float_node.hpp:130
Basic GevServer node for device feature access.
Definition: decl_node.hpp:36
static GevServer::Namespace ParseNamespace(const String &name)
Gets the Namespace from the given name .
Definition: decl_node.hpp:567
static String ParseName(const String &name)
Gets the name part of the given node name .
Definition: decl_node.hpp:588
void * Handle() const noexcept
Classic API node handle.
Definition: decl_node.hpp:100
CacheMode
Defines how the value is cached.
Definition: genapi.hpp:220
@ NoCache
No caching used.
AccessMode
Access possibility of the node.
Definition: genapi.hpp:185
@ ReadWrite
Node can be read and written to.
Namespace
The possible name spaces a node can be in.
Definition: gevserver.hpp:147
@ DisplayPrecision
Accesses the float node's display precision configuration.
@ Unit
Accesses the unit of a node as string.
@ Value
Accesses the value configuration.
@ Max
Gets the maximum value.
@ Increment
Gets the increment.
@ Min
Gets the minimum value.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
char Char
Character type for wide characters or unicode characters.
Definition: string.hpp:70