Motion Master
Loading...
Searching...
No Matches
machine.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <list>
5#include <queue>
6
10
12class Notifier;
13class CommandWorker;
14namespace ctpl {
15class thread_pool;
16}
17
18class Machine {
19 public:
25 void add_message(IncomingMachineMessage& incoming_machine_message);
26
33 virtual void execute(uint64_t pending_signals) = 0;
34
40 virtual void abort_client_requests(const std::string& connection_id) = 0;
41
54
61 virtual bool done() = 0;
62
63 protected:
64 Machine(VirtualDeviceManager& vdm, ctpl::thread_pool& thread_pool,
65 Notifier& notifier,
67 outgoing_machine_message_queue);
68
69 virtual ~Machine();
70
72 ctpl::thread_pool& thread_pool_;
73 std::queue<IncomingMachineMessage> incoming_message_queue_;
75
81 void start_command_worker(IncomingMachineMessage& incoming_machine_message);
82
89 std::function<void(CommandWorker*)> process = nullptr);
90
99 std::string connection_id,
100 motionmaster::MotionMasterMessage& message);
101
102 private:
104 outgoing_machine_message_queue_;
105 std::list<CommandWorker*> command_workers_;
106};
Definition command_worker.h:15
Definition incoming_machine_message.h:5
Protocol
Definition machine_message.h:9
Notifier & notifier_
Definition machine.h:74
void process_command_workers(std::function< void(CommandWorker *)> process=nullptr)
Process all of the available Command Workers.
Definition machine.cc:31
ctpl::thread_pool & thread_pool_
Definition machine.h:72
VirtualDeviceManager & vdm_
Definition machine.h:71
virtual void abort_client_requests(const std::string &connection_id)=0
Abort all of the requests a certain client has issues.
Definition machine.cc:71
virtual ~Machine()
Definition machine.cc:16
virtual bool done()=0
Check if all of the machine started processes are done (including the Command Workers)
std::queue< IncomingMachineMessage > incoming_message_queue_
Definition machine.h:73
void send_response(MachineMessage::Protocol protocol, std::string connection_id, motionmaster::MotionMasterMessage &message)
Send the response (Status protobuf message) to the proper client.
Definition machine.cc:81
virtual void execute(uint64_t pending_signals)=0
Execute the machine.
void start_command_worker(IncomingMachineMessage &incoming_machine_message)
Definition machine.cc:62
void add_message(IncomingMachineMessage &incoming_machine_message)
Add a new incoming machine message to the queue.
Definition machine.cc:58
Machine(VirtualDeviceManager &vdm, ctpl::thread_pool &thread_pool, Notifier &notifier, mm::core::containers::ThreadSafeQueue< OutgoingMachineMessage > &outgoing_machine_message_queue)
Definition machine.cc:7
bool command_workers_done()
Check if all started Command Workers are done.
Definition machine.cc:79
Definition notifier.h:9
Definition virtual_device_manager.h:16
Thread-safe FIFO queue with optional capacity limit.
Definition thread_safe_queue.h:23
Definition machine.h:14