ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
dpmService.hpp
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup daq_dpm
4 * @copyright (c) Copyright ESO 2022
5 * All Rights Reserved
6 * ESO (eso.org) is an Intergovernmental Organisation, and therefore special legal conditions apply.
7 *
8 * @brief daq::dpm::DpmService implements MAL services daqif::DpmControl and daqif::DpmDaqControl.
9 */
10#ifndef DAQ_DPM_DPMREPLIER_HPP
11#define DAQ_DPM_DPMREPLIER_HPP
12#include <daq/config.hpp>
13
14#include <boost/asio/executor_work_guard.hpp>
15#include <boost/asio/signal_set.hpp>
16#include <log4cplus/logger.h>
17#include <mal/Mal.hpp>
18#include <rad/ioExecutor.hpp>
19
20#include <Daqif.hpp>
21
22#include <daq/dpm/scheduler.hpp>
23#include <daq/dpm/workspace.hpp>
24#include <daq/state.hpp>
25
26namespace daq::dpm {
27
28/**
29 * daqif::DpmControl and DpmDaqControl implementation.
30 *
31 * It is mainly responsible for acting as gateway between CII and rest of application.
32 *
33 * Aspects to consider
34 *
35 * - "Requests" are method calls from foreign thread -> requires synchronization, typically by
36 * posting to main thread via io_context.
37 * - Accept requests and transform CII arguments to application format.
38 */
39class DpmService : public ::daqif::AsyncDpmControl, public ::daqif::AsyncDpmDaqControl {
40public:
41 static constexpr char const* LOGGER_NAME = "dpm.replier";
42
43 /**
44 * Construct replier.
45 *
46 * @param executor Executor to use, including the native asio::io_context.
47 */
49 elt::mal::Mal& mal,
50 Workspace& workspace,
51 Scheduler& scheduler);
52 /**
53 * @name AsyncDpmControl
54 */
55 /// @{
56 boost::future<std::shared_ptr<::daqif::StorageStatus>> QueryStorageStatus() override;
57 /**
58 * Cancels any started merges and terminates application.
59 *
60 * @returns future that is set only after all other active operations are cancelled.
61 */
62 boost::future<std::string> Exit() override;
63
64 boost::future<std::string> GetVersion() override;
65 /// @}
66 /**
67 * @name AsyncDpmDaqControl
68 */
69 /// @{
70 boost::future<std::shared_ptr<::daqif::DaqReply>>
71 QueueDaq(std::string const& status, std::string const& specification) override;
72
73 boost::future<std::shared_ptr<::daqif::DaqReply>> AbortDaq(const std::string& id) override;
74
75 boost::future<std::shared_ptr<::daqif::DaqStatus>> GetDaqStatus(const std::string& id) override;
76
77 boost::future<std::vector<std::shared_ptr<::daqif::DaqStatus>>> GetActiveDaqs() override;
78
79 boost::future<std::string> GetInternalDaqStatus(const std::string& id) override;
80 /// @}
81
82private:
83 void InitiateSignalHandler();
84 void HandleExit();
85 /**
86 * Should only be invoked from main thread.
87 */
88 std::shared_ptr<daqif::DaqStatus> GetDaqStatusSync(std::string const& id);
89
90 rad::IoExecutor& m_executor;
91 elt::mal::Mal& m_mal;
92 /**
93 * @name Must be accessed from main thread via exectuor
94 */
95 ///@{
96 Workspace& m_workspace;
97 Scheduler& m_scheduler;
98 ///@}
99 boost::asio::executor_work_guard<boost::asio::io_context::executor_type> m_work_guard;
100 boost::asio::signal_set m_sigset;
101 log4cplus::Logger m_logger;
102};
103
104} // namespace daq::dpm
105
106#endif // #ifndef DAQ_DPM_DPMREPLIER_HPP
daqif::DpmControl and DpmDaqControl implementation.
Definition: dpmService.hpp:39
boost::future< std::string > GetVersion() override
Cancels any started merges and terminates application.
Definition: dpmService.cpp:71
boost::future< std::shared_ptr<::daqif::StorageStatus > > QueryStorageStatus() override
Cancels any started merges and terminates application.
Definition: dpmService.cpp:41
boost::future< std::string > Exit() override
Cancels any started merges and terminates application.
Definition: dpmService.cpp:59
static constexpr char const * LOGGER_NAME
Definition: dpmService.hpp:41
boost::future< std::vector< std::shared_ptr<::daqif::DaqStatus > > > GetActiveDaqs() override
Definition: dpmService.cpp:176
boost::future< std::shared_ptr<::daqif::DaqReply > > AbortDaq(const std::string &id) override
Definition: dpmService.cpp:106
boost::future< std::string > GetInternalDaqStatus(const std::string &id) override
Definition: dpmService.cpp:153
boost::future< std::shared_ptr<::daqif::DaqStatus > > GetDaqStatus(const std::string &id) override
Definition: dpmService.cpp:134
boost::future< std::shared_ptr<::daqif::DaqReply > > QueueDaq(std::string const &status, std::string const &specification) override
Definition: dpmService.cpp:76
Schedules asynchronous activities that results in merged Data Product and delivery.
Definition: scheduler.hpp:222
Interface to interact with DPM workspace.
Definition: workspace.hpp:133
Adapts boost::asio::io_context into a compatible boost::thread Executor type.
Definition: ioExecutor.hpp:12
daq::dpm::Workspace interface and implementation declaration
Declares daq::State and related functions.
daq::dpm::Scheduler and related class declarations.