IDS peak genericC++  v1.6.0
peak_float_node.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
13 
15 #include <peak/dll_interface/peak_dll_interface_util.hpp>
18 
19 #include <cstdint>
20 #include <string>
21 #include <vector>
22 
23 
24 namespace peak
25 {
26 namespace core
27 {
28 namespace nodes
29 {
30 
35 {
36  Automatic,
37  Fixed,
39 };
40 
44 class FloatNode : public Node
45 {
46 public:
47  FloatNode() = delete;
48  ~FloatNode() override = default;
49  FloatNode(const FloatNode& other) = delete;
50  FloatNode& operator=(const FloatNode& other) = delete;
51  FloatNode(FloatNode&& other) = delete;
52  FloatNode& operator=(FloatNode&& other) = delete;
53 
63  double Minimum() const;
73  double Maximum() const;
83  double Increment() const;
93  NodeIncrementType IncrementType() const;
106  std::vector<double> ValidValues() const;
116  NodeRepresentation Representation() const;
126  std::string Unit() const;
136  NodeDisplayNotation DisplayNotation() const;
146  int64_t DisplayPrecision() const;
157  bool HasConstantIncrement() const;
158 
170  double Value(NodeCacheUsePolicy cacheUsePolicy = NodeCacheUsePolicy::UseCache) const;
180  void SetValue(double value);
181 
182 private:
183  friend ClassCreator<FloatNode>;
184  FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
185  PEAK_FLOAT_NODE_HANDLE m_backendHandle;
186 };
187 
188 } /* namespace nodes */
189 } /* namespace core */
190 } /* namespace peak */
191 
192 /* Implementation */
193 namespace peak
194 {
195 namespace core
196 {
197 namespace nodes
198 {
199 
200 inline std::string ToString(NodeDisplayNotation entry)
201 {
202  std::string entryString;
203 
204  if (entry == NodeDisplayNotation::Automatic)
205  {
206  entryString = "Automatic";
207  }
208  else if (entry == NodeDisplayNotation::Fixed)
209  {
210  entryString = "Fixed";
211  }
212  else if (entry == NodeDisplayNotation::Scientific)
213  {
214  entryString = "Scientific";
215  }
216 
217  return entryString;
218 }
219 
220 inline FloatNode::FloatNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
221  : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
222  return PEAK_C_ABI_PREFIX PEAK_FloatNode_ToNode(floatNodeHandle, nodeHandle);
223  }),
224  parentNodeMap)
225  , m_backendHandle(floatNodeHandle)
226 {}
227 
228 inline double FloatNode::Minimum() const
229 {
230  return QueryNumericFromCInterfaceFunction<double>(
231  [&](double* minimum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMinimum(m_backendHandle, minimum); });
232 }
233 
234 inline double FloatNode::Maximum() const
235 {
236  return QueryNumericFromCInterfaceFunction<double>(
237  [&](double* maximum) { return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetMaximum(m_backendHandle, maximum); });
238 }
239 
240 inline double FloatNode::Increment() const
241 {
242  return QueryNumericFromCInterfaceFunction<double>([&](double* increment) {
243  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrement(m_backendHandle, increment);
244  });
245 }
246 
248 {
249  return static_cast<NodeIncrementType>(QueryNumericFromCInterfaceFunction<PEAK_NODE_INCREMENT_TYPE>(
250  [&](PEAK_NODE_INCREMENT_TYPE* incrementType) {
251  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetIncrementType(m_backendHandle, incrementType);
252  }));
253 }
254 
255 inline std::vector<double> FloatNode::ValidValues() const
256 {
257  return QueryNumericArrayFromCInterfaceFunction<double>([&](double* validValues, size_t* validValuesSize) {
258  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetValidValues(m_backendHandle, validValues, validValuesSize);
259  });
260 }
261 
263 {
264  return static_cast<NodeRepresentation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_REPRESENTATION>(
265  [&](PEAK_NODE_REPRESENTATION* representation) {
266  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetRepresentation(m_backendHandle, representation);
267  }));
268 }
269 
270 inline std::string FloatNode::Unit() const
271 {
272  return QueryStringFromCInterfaceFunction([&](char* unit, size_t* unitSize) {
273  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetUnit(m_backendHandle, unit, unitSize);
274  });
275 }
276 
278 {
279  return static_cast<NodeDisplayNotation>(QueryNumericFromCInterfaceFunction<PEAK_NODE_DISPLAY_NOTATION>(
280  [&](PEAK_NODE_DISPLAY_NOTATION* displayNotation) {
281  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayNotation(m_backendHandle, displayNotation);
282  }));
283 }
284 
285 inline int64_t FloatNode::DisplayPrecision() const
286 {
287  return QueryNumericFromCInterfaceFunction<int64_t>([&](int64_t* displayPrecision) {
288  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetDisplayPrecision(m_backendHandle, displayPrecision);
289  });
290 }
291 
293 {
294  return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](PEAK_BOOL8* hasConstantIncrement) {
295  return PEAK_C_ABI_PREFIX PEAK_FloatNode_GetHasConstantIncrement(m_backendHandle, hasConstantIncrement);
296  }) > 0;
297 }
298 
299 inline double FloatNode::Value(NodeCacheUsePolicy cacheUsePolicy /* = NodeCacheUsePolicy::UseCache */) const
300 {
301  return QueryNumericFromCInterfaceFunction<double>([&](double* value) {
303  m_backendHandle, static_cast<PEAK_NODE_CACHE_USE_POLICY>(cacheUsePolicy), value);
304  });
305 }
306 
307 inline void FloatNode::SetValue(double value)
308 {
309  CallAndCheckCInterfaceFunction(
310  [&] { return PEAK_C_ABI_PREFIX PEAK_FloatNode_SetValue(m_backendHandle, value); });
311 }
312 
313 } /* namespace nodes */
314 } /* namespace core */
315 } /* namespace peak */
PEAK_C_API PEAK_FloatNode_GetDisplayNotation(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_DISPLAY_NOTATION *displayNotation)
Asks the given float node for its display notation.
PEAK_C_API PEAK_FloatNode_GetRepresentation(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_REPRESENTATION *representation)
Asks the given float node for its representation.
PEAK_C_API PEAK_FloatNode_GetIncrementType(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_INCREMENT_TYPE *incrementType)
Asks the given float node for its increment type.
PEAK_C_API PEAK_FloatNode_GetMinimum(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *minimum)
Asks the given float node for its minimum.
int8_t PEAK_BOOL8
Definition: peak_backend.h:26
std::vector< double > ValidValues() const
Returns the valid values.
Definition: peak_float_node.hpp:255
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition: peak_dynamic_loader.h:32
NodeCacheUsePolicy
Definition: peak_common_node_enums.hpp:24
Represents a GenAPI float node.
Definition: peak_float_node.hpp:44
double Increment() const
Returns the increment.
Definition: peak_float_node.hpp:240
int32_t PEAK_NODE_INCREMENT_TYPE
Definition: peak_backend.h:243
double Value(NodeCacheUsePolicy cacheUsePolicy=NodeCacheUsePolicy::UseCache) const
Returns the value.
Definition: peak_float_node.hpp:299
void SetValue(double value)
Sets the given value.
Definition: peak_float_node.hpp:307
NodeIncrementType IncrementType() const
Returns the increment type.
Definition: peak_float_node.hpp:247
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition: peak_backend.h:409
int32_t PEAK_NODE_DISPLAY_NOTATION
Definition: peak_backend.h:234
std::string ToString(NodeCacheUsePolicy entry)
Definition: peak_common_node_enums.hpp:54
double Maximum() const
Returns the maximum.
Definition: peak_float_node.hpp:234
PEAK_C_API PEAK_FloatNode_GetMaximum(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *maximum)
Asks the given float node for its maximum.
NodeIncrementType
Definition: peak_common_node_enums.hpp:33
int64_t DisplayPrecision() const
Returns the display precision.
Definition: peak_float_node.hpp:285
std::string Unit() const
Returns the unit.
Definition: peak_float_node.hpp:270
PEAK_C_API PEAK_FloatNode_GetHasConstantIncrement(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_BOOL8 *hasConstantIncrement)
Asks the given float node whether it has a constant increment.
PEAK_C_API PEAK_FloatNode_SetValue(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double value)
Tells the given float node to set the given value.
PEAK_C_API PEAK_FloatNode_ToNode(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_HANDLE *nodeHandle)
Casts the given float node to a node.
PEAK_C_API PEAK_FloatNode_GetDisplayPrecision(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, int64_t *displayPrecision)
Asks the given float node for its display precision.
NodeDisplayNotation
Display notation for numbers in FloatNode.
Definition: peak_float_node.hpp:34
double Minimum() const
Returns the minimum.
Definition: peak_float_node.hpp:228
struct PEAK_FLOAT_NODE * PEAK_FLOAT_NODE_HANDLE
Definition: peak_backend.h:425
PEAK_C_API PEAK_FloatNode_GetIncrement(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *increment)
Asks the given float node for its increment.
PEAK_C_API PEAK_FloatNode_GetValue(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, PEAK_NODE_CACHE_USE_POLICY cacheUsePolicy, double *value)
Asks the given float node for its value.
NodeDisplayNotation DisplayNotation() const
Returns the display notation.
Definition: peak_float_node.hpp:277
#define PEAK_C_ABI_PREFIX
Definition: peak_dll_defines.h:16
PEAK_C_API PEAK_FloatNode_GetValidValues(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, double *validValues, size_t *validValuesSize)
Asks the given float node for its valid values.
NodeRepresentation
Definition: peak_common_node_enums.hpp:43
PEAK_C_API PEAK_FloatNode_GetUnit(PEAK_FLOAT_NODE_HANDLE floatNodeHandle, char *unit, size_t *unitSize)
Asks the given float node for its unit.
Represents a GenAPI node.
Definition: peak_node.hpp:121
int32_t PEAK_NODE_REPRESENTATION
Definition: peak_backend.h:264
bool HasConstantIncrement() const
Checks whether the node has a constant increment.
Definition: peak_float_node.hpp:292
NodeRepresentation Representation() const
Returns the representation.
Definition: peak_float_node.hpp:262