ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
daqController.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_test
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief Mock of DaqController
7  */
8 #ifndef OCM_DAQ_TEST_MOCK_DAQ_CONTROLLER_HPP_
9 #define OCM_DAQ_TEST_MOCK_DAQ_CONTROLLER_HPP_
10 // GCOVR_EXCL_START
11 #include <chrono>
12 
13 #include <daq/daqController.hpp>
14 #include <gmock/gmock.h>
15 
16 namespace daq {
17 
18 
19 /**
20  * Mock version of daq::DaqController
21  */
23  MOCK_METHOD0(StartAsync, boost::future<daq::State>());
24  MOCK_METHOD1(StopAsync, boost::future<daq::Status>(ErrorPolicy));
25  MOCK_METHOD1(AbortAsync, boost::future<daq::Status>(ErrorPolicy));
26  MOCK_METHOD0(ScheduleMergeAsync, boost::future<daq::State>());
29  boost::future<daq::State>(std::vector<std::string>, std::chrono::milliseconds));
31  MOCK_METHOD0(GetStatus, std::shared_ptr<daq::ObservableStatus>());
32  MOCK_CONST_METHOD0(GetStatus, std::shared_ptr<daq::ObservableStatus const>());
33  MOCK_METHOD0(GetEventLog, std::shared_ptr<daq::ObservableEventLog>());
34  MOCK_CONST_METHOD0(GetId, std::string const&());
36  // Implement by delegating to mock method
37  daq::State GetState() const override {
38  return GetStatus()->GetState();
39  }
40 
41  boost::signals2::connection
42  ConnectContext(ContextSignal::slot_type const& slot) override {
43  return signal.connect(slot);
44  }
46 };
47 
48 /**
49  * Factory that creates mock versions
50  */
52  auto MakeOcmPhase(DaqContext daq_ctx,
53  std::shared_ptr<ObservableStatus> status,
54  std::shared_ptr<ObservableEventLog> event_log)
55  -> std::shared_ptr<DaqController> override {
56  return ocm_mocks.at(daq_ctx.id);
57  }
58  auto MakeDpmPhase(DaqContext daq_ctx,
59  std::shared_ptr<ObservableStatus> status,
60  std::shared_ptr<ObservableEventLog> event_log)
61  -> std::shared_ptr<DaqController> override {
62  return dpm_mocks.at(daq_ctx.id);
63  }
64 
65  std::map<std::string, std::shared_ptr<DaqControllerMock>> ocm_mocks;
66  std::map<std::string, std::shared_ptr<DaqControllerMock>> dpm_mocks;
67 };
68 
69 } // namespace daq
70 
71 // GCOVR_EXCL_STOP
72 #endif // #define OCM_DAQ_TEST_MOCK_DAQ_CONTROLLER_HPP_
Abstract factory for DaqControllers.
Controls the execution of single data acquisition that ultimately result in a set of FITS keywords an...
virtual boost::future< Status > StopAsync(ErrorPolicy policy)=0
Stops the data acquisition.
virtual std::shared_ptr< ObservableStatus > GetStatus() DAQ_NOEXCEPT=0
virtual boost::future< Status > AbortAsync(ErrorPolicy policy)=0
Aborts the data acquisition.
virtual boost::future< State > AwaitAsync(std::vector< std::string > sources, std::chrono::milliseconds timeout)=0
Awaits that data acquisition stops or aborts.
virtual DaqContext const & GetContext() const DAQ_NOEXCEPT=0
virtual boost::future< State > ScheduleMergeAsync()=0
Schedules DAQ for merging by sending request to DPM.
virtual void UpdateKeywords(fits::KeywordVector const &keywords)=0
Updates (replace or add) list of keywords.
virtual boost::future< State > StartAsync()=0
Starts the data acquisition.
virtual std::string const & GetId() const DAQ_NOEXCEPT=0
virtual bool GetErrorFlag() const DAQ_NOEXCEPT=0
boost::signals2::signal< void(DaqContext const &)> ContextSignal
virtual std::shared_ptr< ObservableEventLog > GetEventLog() DAQ_NOEXCEPT=0
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
Definition: keyword.hpp:414
ErrorPolicy
Error policy supported by certain operations.
Definition: error.hpp:25
State
Observable states of the data acquisition process.
Definition: state.hpp:39
Contains declaration for for DaqController.
Structure carrying context needed to start a Data Acquisition and construct a Data Product Specificat...
Definition: daqContext.hpp:44
Factory that creates mock versions.
auto MakeOcmPhase(DaqContext daq_ctx, std::shared_ptr< ObservableStatus > status, std::shared_ptr< ObservableEventLog > event_log) -> std::shared_ptr< DaqController > override
Create instance for the OCM phase of the DAQ process.
auto MakeDpmPhase(DaqContext daq_ctx, std::shared_ptr< ObservableStatus > status, std::shared_ptr< ObservableEventLog > event_log) -> std::shared_ptr< DaqController > override
Create instance for the DPM phase of the DAQ process.
std::map< std::string, std::shared_ptr< DaqControllerMock > > dpm_mocks
std::map< std::string, std::shared_ptr< DaqControllerMock > > ocm_mocks
Mock version of daq::DaqController.
MOCK_CONST_METHOD0(GetStatus, std::shared_ptr< daq::ObservableStatus const >())
MOCK_METHOD2(AwaitAsync, boost::future< daq::State >(std::vector< std::string >, std::chrono::milliseconds))
MOCK_CONST_METHOD0(GetErrorFlag, bool())
MOCK_METHOD1(StopAsync, boost::future< daq::Status >(ErrorPolicy))
MOCK_METHOD0(StartAsync, boost::future< daq::State >())
MOCK_METHOD0(GetEventLog, std::shared_ptr< daq::ObservableEventLog >())
boost::signals2::connection ConnectContext(ContextSignal::slot_type const &slot) override
Connect observer that is invoked when context is modified.
MOCK_CONST_METHOD0(GetContext, DaqContext const &())
MOCK_METHOD0(ScheduleMergeAsync, boost::future< daq::State >())
MOCK_METHOD0(GetStatus, std::shared_ptr< daq::ObservableStatus >())
daq::State GetState() const override
MOCK_METHOD1(AbortAsync, boost::future< daq::Status >(ErrorPolicy))
MOCK_CONST_METHOD0(GetId, std::string const &())
MOCK_METHOD1(UpdateKeywords, void(fits::KeywordVector const &))