IDS peak genericC++ v1.12.0
Loading...
Searching...
No Matches
peak_command_node.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13
16#include <peak/dll_interface/peak_dll_interface_util.hpp>
19#include <type_traits>
20
21
22namespace peak
23{
24namespace core
25{
26namespace nodes
27{
28
33class CommandNode : public Node
34{
35public:
36 static constexpr auto NodeType = nodes::NodeType::Command;
37 using NodeDataType = void;
38 using NodeHasRange = std::false_type;
39
40 CommandNode() = delete;
41 ~CommandNode() override = default;
42 CommandNode(const CommandNode& other) = delete;
43 CommandNode& operator=(const CommandNode& other) = delete;
44 CommandNode(CommandNode&& other) = delete;
45 CommandNode& operator=(CommandNode&& other) = delete;
46
58 bool IsDone() const;
59
68 void Execute();
69
80 void WaitUntilDone(Timeout waitTimeout_ms = 500);
81
82
83private:
84 friend ClassCreator<CommandNode>;
85 CommandNode(PEAK_COMMAND_NODE_HANDLE commandNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap);
86 PEAK_COMMAND_NODE_HANDLE m_backendHandle;
87};
88
89} /* namespace nodes */
90} /* namespace core */
91} /* namespace peak */
92
93/* Implementation */
94namespace peak
95{
96namespace core
97{
98namespace nodes
99{
100
102 PEAK_COMMAND_NODE_HANDLE commandNodeHandle, const std::weak_ptr<NodeMap>& parentNodeMap)
103 : Node(QueryNumericFromCInterfaceFunction<PEAK_NODE_HANDLE>([&](PEAK_NODE_HANDLE* nodeHandle) {
104 return PEAK_C_ABI_PREFIX PEAK_CommandNode_ToNode(commandNodeHandle, nodeHandle);
105 }),
106 parentNodeMap)
107 , m_backendHandle(commandNodeHandle)
108{}
109
110inline bool CommandNode::IsDone() const
111{
112 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](PEAK_BOOL8* isDone) {
113 return PEAK_C_ABI_PREFIX PEAK_CommandNode_GetIsDone(m_backendHandle, isDone);
114 }) > 0;
115}
117{
118 CallAndCheckCInterfaceFunction([&] { return PEAK_C_ABI_PREFIX PEAK_CommandNode_Execute(m_backendHandle); });
119}
120
121inline void CommandNode::WaitUntilDone(Timeout waitTimeout_ms /*= 500*/)
122{
123 CallAndCheckCInterfaceFunction(
124 [&] { return PEAK_C_ABI_PREFIX PEAK_CommandNode_WaitUntilDone(m_backendHandle, waitTimeout_ms); });
125}
126
127} /* namespace nodes */
128} /* namespace core */
129} /* namespace peak */
Represents a timeout value in milliseconds.
Definition peak_timeout.hpp:31
CommandNode & operator=(CommandNode &&other)=delete
std::false_type NodeHasRange
Definition peak_command_node.hpp:38
static constexpr auto NodeType
Definition peak_command_node.hpp:36
void NodeDataType
Definition peak_command_node.hpp:37
void WaitUntilDone(Timeout waitTimeout_ms=500)
(Blocking) Wait for the executed command to be finished, i.e. until IsDone() is true.
Definition peak_command_node.hpp:121
CommandNode(const CommandNode &other)=delete
CommandNode(CommandNode &&other)=delete
~CommandNode() override=default
bool IsDone() const
Checks whether the command is done.
Definition peak_command_node.hpp:110
void Execute()
Executes the command associated with this node.
Definition peak_command_node.hpp:116
CommandNode & operator=(const CommandNode &other)=delete
The "nodes" namespace contains all GenAPI node types.
Definition peak_boolean_node.hpp:26
@ Command
Definition peak_node.hpp:90
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:34
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
PEAK_C_API PEAK_CommandNode_ToNode(PEAK_COMMAND_NODE_HANDLE commandNodeHandle, PEAK_NODE_HANDLE *nodeHandle)
Casts the given command node to a node.
struct PEAK_COMMAND_NODE * PEAK_COMMAND_NODE_HANDLE
Definition peak_backend.h:441
struct PEAK_NODE * PEAK_NODE_HANDLE
Definition peak_backend.h:429
PEAK_C_API PEAK_CommandNode_Execute(PEAK_COMMAND_NODE_HANDLE commandNodeHandle)
Tells the given command node to execute its associated command.
int8_t PEAK_BOOL8
Definition peak_backend.h:43
PEAK_C_API PEAK_CommandNode_WaitUntilDone(PEAK_COMMAND_NODE_HANDLE commandNodeHandle, uint64_t waitTimeout_ms)
Waits (blocking) until the previously executed command is finished, i.e. PEAK_CommandNode_GetIsDone()...
PEAK_C_API PEAK_CommandNode_GetIsDone(PEAK_COMMAND_NODE_HANDLE commandNodeHandle, PEAK_BOOL8 *isDone)
Asks the given command node whether its associated command is done.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16