ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
managerMock.hpp
Go to the documentation of this file.
1 #ifndef DAQ_OCM_SERVER_MOCK_MANAGER_MOCK_HPP_
2 #define DAQ_OCM_SERVER_MOCK_MANAGER_MOCK_HPP_
3 #include <daq/manager.hpp>
4 #include <daq/status.hpp>
5 #include <daq/daqController.hpp>
6 
7 #include <gmock/gmock.h>
8 
10  MOCK_CONST_METHOD2(HaveDaq, bool(std::string_view, std::string_view));
11  MOCK_CONST_METHOD1(MakeDaqId, std::string(std::chrono::system_clock::time_point*));
13  MOCK_METHOD1(StartDaqAsync, boost::future<daq::State>(daq::DaqContext));
14  MOCK_METHOD2(StopDaqAsync, boost::future<daq::Status>(std::string_view, daq::ErrorPolicy));
15  MOCK_METHOD2(AbortDaqAsync, boost::future<daq::Status>(std::string_view, daq::ErrorPolicy));
17  boost::future<daq::Result<daq::Status>>(std::string_view,
18  daq::State,
19  std::chrono::milliseconds));
20 
21  MOCK_METHOD2(UpdateKeywords, void(std::string_view, daq::fits::KeywordVector const&));
24  MOCK_METHOD0(GetDaqControllers, std::vector<std::shared_ptr<daq::DaqController const>>());
25 };
26 
28  DaqControllerFake(std::shared_ptr<daq::ObservableStatus> status_arg)
29  : status(std::move(status_arg)), ctx() {
30  ctx.id = status->GetId();
31  }
32  boost::future<daq::State> StartAsync() override {
33  throw std::runtime_error("not implemented");
34  }
35  boost::future<daq::Status> StopAsync(daq::ErrorPolicy policy) override {
36  throw std::runtime_error("not implemented");
37  }
38  boost::future<daq::Status> AbortAsync(daq::ErrorPolicy policy) override {
39  throw std::runtime_error("not implemented");
40  }
41  boost::future<daq::State> ScheduleMergeAsync() override {
42  throw std::runtime_error("not implemented");
43  }
44  void UpdateKeywords(daq::fits::KeywordVector const& keywords) override {
45  throw std::runtime_error("not implemented");
46  }
47  boost::future<daq::State>
48  AwaitAsync(std::vector<std::string> sources, std::chrono::milliseconds timeout) override {
49  throw std::runtime_error("not implemented");
50  }
51  daq::State GetState() const DAQ_NOEXCEPT override {
52  return status->GetState();
53  }
54  std::shared_ptr<daq::ObservableStatus> GetStatus() DAQ_NOEXCEPT override {
55  return status;
56  }
57  std::shared_ptr<daq::ObservableStatus const> GetStatus() const DAQ_NOEXCEPT override {
58  return status;
59  }
60  std::shared_ptr<daq::ObservableEventLog> GetEventLog() DAQ_NOEXCEPT override {
61  throw std::runtime_error("not implemented");
62  }
63  std::string const& GetId() const DAQ_NOEXCEPT override {
64  return status->GetId();
65  }
66  bool GetErrorFlag() const DAQ_NOEXCEPT override {
67  return status->GetError();
68  }
69  daq::DaqContext const& GetContext() const DAQ_NOEXCEPT override {
70  return ctx;
71  }
72 
73  boost::signals2::connection
74  ConnectContext(ContextSignal::slot_type const& slot) override {
75  return signal.connect(slot);
76  }
77 
79 
80  std::shared_ptr<daq::ObservableStatus> status;
82 };
83 
84 #endif // #ifndef DAQ_OCM_SERVER_MOCK_MANAGER_MOCK_HPP_
DaqControllerFake::AbortAsync
boost::future< daq::Status > AbortAsync(daq::ErrorPolicy policy) override
Aborts the data acquisition.
Definition: managerMock.hpp:38
ManagerMock::MOCK_CONST_METHOD1
MOCK_CONST_METHOD1(GetStatus, daq::Status(std::string_view))
daq::State
State
Observable states of the data acquisition process.
Definition: state.hpp:39
daq::Manager::UpdateKeywords
virtual void UpdateKeywords(std::string_view id, fits::KeywordVector const &keywords)=0
Update FITS keywords for DaqController identified by id.
DaqControllerFake::ConnectContext
boost::signals2::connection ConnectContext(ContextSignal::slot_type const &slot) override
Connect observer that is invoked when context is modified.
Definition: managerMock.hpp:74
ManagerMock::MOCK_CONST_METHOD1
MOCK_CONST_METHOD1(MakeDaqId, std::string(std::chrono::system_clock::time_point *))
ManagerMock::MOCK_METHOD0
MOCK_METHOD0(GetStatusSignal, daq::StatusSignal &())
DaqControllerFake::GetContext
daq::DaqContext const & GetContext() const DAQ_NOEXCEPT override
Definition: managerMock.hpp:69
ManagerMock
Definition: managerMock.hpp:9
manager.hpp
Declaration of daq::Manager
DaqControllerFake::UpdateKeywords
void UpdateKeywords(daq::fits::KeywordVector const &keywords) override
Updates (replace or add) list of keywords.
Definition: managerMock.hpp:44
daq::DaqContext::id
std::string id
DAQ identfier, possibly provided by user.
Definition: daqContext.hpp:64
daq::Manager::HaveDaq
virtual bool HaveDaq(std::string_view id, std::string_view file_id={}) const DAQ_NOEXCEPT=0
Query existing data acquisition by id and optional file_id.
ManagerMock::MOCK_METHOD2
MOCK_METHOD2(UpdateKeywords, void(std::string_view, daq::fits::KeywordVector const &))
DaqControllerFake::GetStatus
std::shared_ptr< daq::ObservableStatus > GetStatus() DAQ_NOEXCEPT override
Definition: managerMock.hpp:54
DAQ_NOEXCEPT
#define DAQ_NOEXCEPT
Definition: config.hpp:16
daq::Manager::GetStatusSignal
virtual StatusSignal & GetStatusSignal()=0
DaqControllerFake::GetId
std::string const & GetId() const DAQ_NOEXCEPT override
Definition: managerMock.hpp:63
ManagerMock::MOCK_METHOD0
MOCK_METHOD0(RestoreFromWorkspace, void())
DaqControllerFake::StartAsync
boost::future< daq::State > StartAsync() override
Starts the data acquisition.
Definition: managerMock.hpp:32
DaqControllerFake::status
std::shared_ptr< daq::ObservableStatus > status
Definition: managerMock.hpp:80
daq::Manager::AwaitDaqStateAsync
virtual boost::future< Result< Status > > AwaitDaqStateAsync(std::string_view id, State state, std::chrono::milliseconds timeout)=0
Await DAQ state.
DaqControllerFake::StopAsync
boost::future< daq::Status > StopAsync(daq::ErrorPolicy policy) override
Stops the data acquisition.
Definition: managerMock.hpp:35
daq::StatusSignal
Observes any status.
Definition: manager.hpp:77
daq::DaqContext
Structure carrying context needed to start a Data Acquisition and construct a Data Product Specificat...
Definition: daqContext.hpp:48
daq::Manager::MakeDaqId
virtual std::string MakeDaqId(std::chrono::system_clock::time_point *time=nullptr) const =0
Creates a new unique identifier based on the instrument id and current time.
daq::Manager::StopDaqAsync
virtual boost::future< Status > StopDaqAsync(std::string_view id, ErrorPolicy policy)=0
Stop DaqController identified by id.
DaqControllerFake::DaqControllerFake
DaqControllerFake(std::shared_ptr< daq::ObservableStatus > status_arg)
Definition: managerMock.hpp:28
DaqControllerFake::signal
ContextSignal signal
Definition: managerMock.hpp:78
daq::Manager::StartDaqAsync
virtual boost::future< State > StartDaqAsync(DaqContext ctx)=0
Start DaqController identified by id.
daq::Result
Utility class that represents a result and an error.
Definition: utility.hpp:17
daqController.hpp
Contains declaration for for DaqController.
daq::Manager::GetDaqControllers
virtual std::vector< std::shared_ptr< DaqController const > > GetDaqControllers()=0
status.hpp
Contains declaration for Status and ObservableStatus.
ManagerMock::MOCK_CONST_METHOD2
MOCK_CONST_METHOD2(HaveDaq, bool(std::string_view, std::string_view))
DaqControllerFake::GetState
daq::State GetState() const DAQ_NOEXCEPT override
Definition: managerMock.hpp:51
DaqControllerFake::AwaitAsync
boost::future< daq::State > AwaitAsync(std::vector< std::string > sources, std::chrono::milliseconds timeout) override
Awaits that data acquisition stops or aborts.
Definition: managerMock.hpp:48
ManagerMock::MOCK_METHOD2
MOCK_METHOD2(AbortDaqAsync, boost::future< daq::Status >(std::string_view, daq::ErrorPolicy))
DaqControllerFake::GetErrorFlag
bool GetErrorFlag() const DAQ_NOEXCEPT override
Definition: managerMock.hpp:66
DaqControllerFake
Definition: managerMock.hpp:27
ManagerMock::MOCK_METHOD1
MOCK_METHOD1(StartDaqAsync, boost::future< daq::State >(daq::DaqContext))
daq::Status
Non observable status object that keeps stores status of data acquisition.
Definition: status.hpp:120
daq::Manager::RestoreFromWorkspace
virtual void RestoreFromWorkspace()=0
Restore from state stored in workspace.
daq::fits::KeywordVector
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
Definition: keyword.hpp:414
ManagerMock::MOCK_METHOD2
MOCK_METHOD2(StopDaqAsync, boost::future< daq::Status >(std::string_view, daq::ErrorPolicy))
DaqControllerFake::GetStatus
std::shared_ptr< daq::ObservableStatus const > GetStatus() const DAQ_NOEXCEPT override
Definition: managerMock.hpp:57
DaqControllerFake::ScheduleMergeAsync
boost::future< daq::State > ScheduleMergeAsync() override
Schedules DAQ for merging by sending request to DPM.
Definition: managerMock.hpp:41
ManagerMock::MOCK_METHOD3
MOCK_METHOD3(AwaitDaqStateAsync, boost::future< daq::Result< daq::Status >>(std::string_view, daq::State, std::chrono::milliseconds))
daq::DaqController
Controls the execution of single data acquisition that ultimately result in a set of FITS keywords an...
Definition: daqController.hpp:214
daq::DaqController::ContextSignal
boost::signals2::signal< void(DaqContext const &)> ContextSignal
Definition: daqController.hpp:315
daq::ErrorPolicy
ErrorPolicy
Error policy supported by certain operations.
Definition: error.hpp:25
DaqControllerFake::ctx
daq::DaqContext ctx
Definition: managerMock.hpp:81
daq::Manager::GetStatus
virtual Status GetStatus(std::string_view id) const =0
Get status.
ManagerMock::MOCK_METHOD0
MOCK_METHOD0(GetDaqControllers, std::vector< std::shared_ptr< daq::DaqController const >>())
daq::Manager
Manager owns DaqController and FitsController (active data acquisitions) instances and multiplexes re...
Definition: manager.hpp:124
DaqControllerFake::GetEventLog
std::shared_ptr< daq::ObservableEventLog > GetEventLog() DAQ_NOEXCEPT override
Definition: managerMock.hpp:60
daq::Manager::AbortDaqAsync
virtual boost::future< Status > AbortDaqAsync(std::string_view id, ErrorPolicy policy)=0
Abort DaqController identified by id.