Psyllid  v1.12.4
Project 8 Data Acquisisition Software
batch_executor.hh
Go to the documentation of this file.
1 /*
2  * batch_executor.hh
3  *
4  * Created on: April 12, 2018
5  * Author: laroque
6  */
7 
8 #ifndef PSYLLID_BATCH_EXECUTOR_HH_
9 #define PSYLLID_BATCH_EXECUTOR_HH_
10 
11 #include "control_access.hh"
12 
13 // scarab includes
14 #include "cancelable.hh"
15 #include "concurrent_queue.hh"
16 #include "param.hh"
17 
18 // dripline
19 #include "message.hh"
20 
21 #include <condition_variable>
22 
23 namespace psyllid
24 {
46  // forward declarations
47  class request_receiver;
48  class daq_control;
49 
50  struct action_info
51  {
53  dripline::request_ptr_t f_request_ptr;
55  };
56 
57  // local content
58  class batch_executor : public control_access, public scarab::cancelable
59  {
60  public:
62  batch_executor( const scarab::param_node& a_master_config, std::shared_ptr< request_receiver > a_request_receiver );
63  virtual ~batch_executor();
64 
65  mv_referrable_const( scarab::param_node, batch_commands );
66 
67  public:
68  void clear_queue();
69  void add_to_queue( const scarab::param_node& an_action );
70  void add_to_queue( const scarab::param_array& actions_array );
71  void add_to_queue( const std::string& a_batch_command_name );
72  void replace_queue( const scarab::param_node& an_action );
73  void replace_queue( const scarab::param_array& actions_array );
74  void replace_queue( const std::string& a_batch_command_name );
75 
76  dripline::reply_ptr_t do_batch_cmd_request( const std::string& a_command, const dripline::request_ptr_t a_request );
77  dripline::reply_ptr_t do_replace_actions_request( const std::string& a_command, const dripline::request_ptr_t a_request );
78 
79  void execute( std::condition_variable& a_daq_control_ready_cv, std::mutex& a_daq_control_ready_mutex, bool a_run_forever = false );
80 
81  private:
82  std::shared_ptr<request_receiver> f_request_receiver;
83  scarab::concurrent_queue< action_info > f_action_queue;
84  scarab::param_node f_condition_actions;
85 
86  void do_an_action();
87 
88  static action_info parse_action( const scarab::param_node& a_action );
89 
90  };
91 
92 } /* namespace psyllid */
93 
94 #endif /*PSYLLID_BATCH_EXECUTOR_HH_*/
Gives other classes access to daq_control.
A class sequentially execute a list of actions, equivalent to a sequence of dripline requests...
scarab::concurrent_queue< action_info > f_action_queue
scarab::param_node f_condition_actions
dripline::request_ptr_t f_request_ptr
std::shared_ptr< request_receiver > f_request_receiver