ifw-daq
2.1.0-pre1
IFW Data Acquisition modules
|
Go to the documentation of this file.
8 #ifndef OCM_DAQ_MANAGER_HPP_
9 #define OCM_DAQ_MANAGER_HPP_
13 #include <string_view>
16 #include <boost/asio/deadline_timer.hpp>
17 #include <boost/thread/future.hpp>
18 #include <log4cplus/logger.h>
68 std::chrono::system_clock::time_point* out =
nullptr);
81 template <
class Observer>
83 return m_signal.connect(std::move(o));
153 virtual std::string
MakeDaqId(std::chrono::system_clock::time_point* time =
nullptr)
const = 0;
222 virtual boost::future<Result<Status>>
261 std::shared_ptr<ObservableEventLog> event_log,
269 std::string
MakeDaqId(std::chrono::system_clock::time_point* time =
nullptr)
const override;
271 bool HaveDaq(std::string_view
id, std::string_view file_id = {})
const noexcept
override;
281 boost::future<Result<Status>>
292 Daq(std::string id_arg,
293 std::shared_ptr<DaqController> controller_arg,
294 boost::signals2::connection conn_status_arg,
295 boost::signals2::connection conn_context_arg) noexcept;
298 std::shared_ptr<DaqController> controller;
300 boost::signals2::scoped_connection conn_status;
301 boost::signals2::scoped_connection conn_context;
307 using Func = std::function<bool()>;
308 OpAbortFunc(Func&& f);
309 OpAbortFunc(OpAbortFunc&&) =
default;
310 OpAbortFunc& operator=(OpAbortFunc&&) =
default;
312 uint64_t GetId()
const noexcept;
313 bool Abort() noexcept;
316 static uint64_t NextId();
318 std::function<bool()> m_func;
321 enum class Store { Yes, No };
338 void AddDaq(std::shared_ptr<DaqController>
daq, Store store = Store::Yes);
346 void RemoveDaq(std::string_view
id);
347 void ArchiveDaq(std::string
const&
id);
351 void StoreActiveDaqs()
const;
354 void RemoveAbortFunc(uint64_t
id) noexcept;
355 DaqController const* FindDaq(std::string_view
id)
const noexcept;
358 DaqController const& FindDaqOrThrow(std::string_view
id)
const;
363 void MoveToMergePhase(std::string_view
id);
371 void ScheduleDaqsAsync();
373 std::shared_ptr<bool> m_alive_token;
377 std::shared_ptr<ObservableEventLog> m_event_log;
382 std::vector<Daq> m_daq_controllers;
385 std::vector<OpAbortFunc> m_abort_funcs;
386 log4cplus::Logger m_logger;
389 std::optional<boost::asio::deadline_timer> m_schedule_retry;
393 #endif // #ifndef OCM_DAQ_MANAGER_HPP_
boost::signals2::signal< void(ObservableStatus const &)> SignalType
boost::future< State > StartDaqAsync(DaqContext ctx) override
Start DaqController identified by id.
State
Observable states of the data acquisition process.
bool HaveDaq(std::string_view id, std::string_view file_id={}) const noexcept override
Query existing data acquisition by id and optional file_id.
virtual void UpdateKeywords(std::string_view id, fits::KeywordVector const &keywords)=0
Update FITS keywords for DaqController identified by id.
std::string instrument_id
Instrument identifier.
Interface to interact with DPM workspace.
void Signal(ObservableStatus const &status)
Adapts boost::asio::io_context into a compatible boost::thread Executor type.
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.
void UpdateKeywords(std::string_view id, fits::KeywordVector const &keywords) override
Update FITS keywords for DaqController identified by id.
virtual StatusSignal & GetStatusSignal()=0
std::string MakeIdCandidate(char const *instrument_id, unsigned jitter=0, std::chrono::system_clock::time_point *out=nullptr)
Creates a DAQ id candidate that may or may not be unique.
boost::future< Status > StopDaqAsync(std::string_view id, ErrorPolicy policy) override
Stop DaqController identified by id.
virtual boost::future< Result< Status > > AwaitDaqStateAsync(std::string_view id, State state, std::chrono::milliseconds timeout)=0
Await DAQ state.
boost::signals2::connection ConnectObserver(Observer o)
Stores data acquisition status and allows subscription to status changes.
Contains declaration for EventLog, ObservableEventLog and related events.
Config class header file.
Structure carrying context needed to start a Data Acquisition and construct a Data Product Specificat...
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.
virtual boost::future< Status > StopDaqAsync(std::string_view id, ErrorPolicy policy)=0
Stop DaqController identified by id.
virtual boost::future< State > StartDaqAsync(DaqContext ctx)=0
Start DaqController identified by id.
std::chrono::hours merging_stale_age
Age of DAQ in merging state, after which it is automatically considered abandoned and will be archive...
virtual std::vector< std::shared_ptr< DaqController const > > GetDaqControllers()=0
Contains declaration for Status and ObservableStatus.
std::vector< std::shared_ptr< DaqController const > > GetDaqControllers() override
Contains declaration of daq::Context.
std::string MakeDaqId(std::chrono::system_clock::time_point *time=nullptr) const override
Creates a new unique identifier based on the instrument id and current time.
boost::future< Result< Status > > AwaitDaqStateAsync(std::string_view id, State, std::chrono::milliseconds timeout) override
Await DAQ state.
std::chrono::hours acquiring_stale_age
Age of DAQ in acquiring state after which it is automatically considered abandoned and will be archiv...
Declares daq::State and related functions.
boost::future< Status > AbortDaqAsync(std::string_view id, ErrorPolicy policy) override
Abort DaqController identified by id.
Status GetStatus(std::string_view id) const override
Get status.
Non observable status object that keeps stores status of data acquisition.
void RestoreFromWorkspace() override
Loads status and constructs DaqControllers corresponding to stored state.
virtual void RestoreFromWorkspace()=0
Restore from state stored in workspace.
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
StatusSignal & GetStatusSignal() override
Configurations parameters directly related to manager.
Controls the execution of single data acquisition that ultimately result in a set of FITS keywords an...
boost::signals2::signal< void(ObservableStatus const &)> Signal
ErrorPolicy
Error policy supported by certain operations.
virtual Status GetStatus(std::string_view id) const =0
Get status.
Declaration of utilities.
Manager owns DaqController and FitsController (active data acquisitions) instances and multiplexes re...
Contains error related declarations for DAQ.
ManagerImpl(rad::IoExecutor &executor, ManagerParams params, Workspace &workspace, std::shared_ptr< ObservableEventLog > event_log, DaqControllerFactory &daq_factory)
Abstract factory for DaqControllers.
virtual boost::future< Status > AbortDaqAsync(std::string_view id, ErrorPolicy policy)=0
Abort DaqController identified by id.