Motion Master
Loading...
Searching...
No Matches
command_worker.h
Go to the documentation of this file.
1#pragma once
2
3#include <readerwriterqueue/readerwriterqueue.h>
4
5#include <chrono>
6#include <list>
7#include <thread>
8#include <zmq.hpp>
9
11#include "motion_master_error.h"
12
13class Notifier;
14class VirtualDevice;
16
18 public:
20 IncomingMachineMessage &incoming_machine_message);
21
25 void run();
26
34
41 const std::string &get_connection_id() const;
42
48 moodycamel::ReaderWriterQueue<motionmaster::MotionMasterMessage> &
50
57 bool is_done();
58
65
67
68 private:
70 Notifier &notifier_;
71
72 IncomingMachineMessage incoming_machine_message_;
73 const motionmaster::MotionMasterMessage::Request &request_;
74
75 moodycamel::ReaderWriterQueue<motionmaster::MotionMasterMessage>
76 outgoing_message_queue_;
77 MotionMasterError error_;
78 // Set in the constructor depending on the request type
79 bool device_address_must_be_supplied_ = true;
80 uint32_t device_address_;
81 VirtualDevice *virtual_device_ = nullptr;
82 bool done_ = false;
83
91 void populate_device_parameter_values_message(
92 const motionmaster::MotionMasterMessage::Request::GetDeviceParameterValues
93 &get_device_parameter_values_request,
94 VirtualDevice *virtual_device,
95 motionmaster::MotionMasterMessage::Status::DeviceParameterValues
96 *parameter_values_msg);
97
105 static void set_device_parameter_values(
106 const motionmaster::MotionMasterMessage::Request::SetDeviceParameterValues
107 &set_device_parameter_values_request,
108 VirtualDevice *virtual_device,
109 motionmaster::MotionMasterMessage::Status::DeviceParameterValues
110 *parameter_values_msg);
111
120 static MotionMasterError sii_restore(const std::vector<uint8_t> &sii_content,
121 int32_t device_position);
122
126 void notify_if_hardware_description_missing();
127
133 void send_status(motionmaster::MotionMasterMessage::Status *status);
134};
Definition: command_worker.h:17
void run()
Execute the Command Worker.
Definition: command_worker.cc:208
moodycamel::ReaderWriterQueue< motionmaster::MotionMasterMessage > & get_status_queue()
Get all of the Status messages meant for the client.
Definition: command_worker.cc:2996
void abort_motion_operations()
Definition: command_worker.cc:3006
const std::string & get_connection_id() const
Get the ID of the client that has sent the request (command) Command Worker is working on.
Definition: command_worker.cc:2991
MotionMasterError get_error()
Get the current error (if any)
Definition: command_worker.cc:3004
MachineMessage::Protocol get_protocol() const
Get the protocol of the client that has sent the request (command) Command Worker is working on.
Definition: command_worker.cc:2987
bool is_done()
Check if the Command Worker is done processing the request (command)
Definition: command_worker.cc:3000
Definition: incoming_machine_message.h:5
Protocol
Definition: machine_message.h:9
Definition: motion_master_error.h:6
Definition: notifier.h:10
Definition: virtual_device_manager.h:16
Definition: virtual_device.h:20