ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
daq::OcmDaqController Class Reference

Implements daq::DaqController for states responsible to be executed by OCM. More...

#include <daqController.hpp>

+ Inheritance diagram for daq::OcmDaqController:

Classes

struct  Aborted
 
struct  Aborting
 
struct  Acquiring
 
struct  NotStarted
 
struct  Starting
 
struct  Stopped
 
struct  Stopping
 

Public Member Functions

boost::future< StateStartAsync () override
 Starts the data acquisition. More...
 
boost::future< StatusStopAsync (ErrorPolicy policy) override
 Stops the data acquisition. More...
 
boost::future< StatusAbortAsync (ErrorPolicy policy) override
 Aborts the data acquisition. More...
 
boost::future< StateScheduleMergeAsync () override
 Schedules DAQ for merging by sending request to DPM. More...
 
void UpdateKeywords (fits::KeywordVector const &keywords) override
 Updates (replace or add) list of keywords. More...
 
boost::future< StateAwaitAsync (std::vector< std::string > sources, std::chrono::milliseconds timeout) override
 Awaits that data acquisition stops or aborts. More...
 
State GetState () const DAQ_NOEXCEPT override
 
constexpr log4cplus::Logger const & GetLogger () const noexcept
 
- Public Member Functions inherited from daq::CommonDaqController
 CommonDaqController (boost::asio::io_context &io_context, DaqContext context, std::shared_ptr< ObservableStatus > status, std::shared_ptr< ObservableEventLog > event_log)
 
std::shared_ptr< ObservableStatusGetStatus () DAQ_NOEXCEPT override
 
std::shared_ptr< ObservableStatus const > GetStatus () const DAQ_NOEXCEPT override
 
std::shared_ptr< ObservableEventLogGetEventLog () DAQ_NOEXCEPT override
 
std::string const & GetId () const DAQ_NOEXCEPT override
 
bool GetErrorFlag () const DAQ_NOEXCEPT override
 
DaqContext const & GetContext () const DAQ_NOEXCEPT override
 
boost::signals2::connection ConnectContext (ContextSignal::slot_type const &slot) override
 Connect observer that is invoked when context is modified. More...
 
- Public Member Functions inherited from daq::DaqController
 DaqController ()=default
 
virtual ~DaqController ()=default
 

Static Public Member Functions

static std::shared_ptr< OcmDaqControllerCreate (boost::asio::io_context &io_context, DaqContext context, DaqSources const &sources, std::shared_ptr< ObservableStatus > status, std::shared_ptr< ObservableEventLog > event_log, OcmAsyncOperations operations)
 Construct object. More...
 

Protected Types

using StateVariant = std::variant< NotStarted, Starting, Acquiring, Stopping, Stopped, Aborting, Aborted >
 

Protected Member Functions

StateVariant MakeState (State s) const noexcept
 
 OcmDaqController (boost::asio::io_context &io_context, DaqContext context, DaqSources const &sources, std::shared_ptr< ObservableStatus > status, std::shared_ptr< ObservableEventLog > event_log, OcmAsyncOperations ops)
 
op::AsyncOpParams MakeParams (op::AlertState &)
 Constructs the parameters used for asynchronous operations. More...
 
op::AwaitOpParams MakeAwaitParams (op::AlertState &)
 
void InitiateAwaitPrimarySources ()
 Await completion of primary sources. More...
 
void AddInitialKeywords ()
 
void SetErrorFlag (bool error) noexcept
 
void SetState (StateVariant &&s) noexcept
 
std::optional< std::variant< gsl::not_null< Source< PrimSource > * >, gsl::not_null< Source< MetaSource > * > > > FindSource (std::string_view source_id)
 
template<class SourceType >
std::vector< Source< SourceType > > MakeSources (std::vector< SourceType > sources)
 Helper to build source vector. More...
 
- Protected Member Functions inherited from daq::CommonDaqController
template<class T , class... Args>
void AddEvent (Args &&... args)
 
boost::asio::io_context & GetIoCtx () noexcept
 
rad::IoExecutorGetIoExecutor () noexcept
 
DaqContextGetContextMut () noexcept
 
ObservableEventLogGetEventLogRef () noexcept
 
ObservableStatusGetStatusRef () noexcept
 
ObservableStatus const & GetStatusRef () const noexcept
 
void EmitContextSignal ()
 

Protected Attributes

StateVariant m_state
 
std::vector< Source< PrimSource > > m_prim_sources
 Note: Consider vector immutable! More...
 
std::vector< Source< MetaSource > > m_meta_sources
 Note: Consider vector immutable! More...
 
OcmAsyncOperations m_async_ops
 
std::shared_ptr< PendingRepliesm_pending_replies
 
std::vector< std::unique_ptr< boost::asio::steady_timer > > m_timers
 
std::function< bool()> m_abort_await_primary_sources
 If DaqController is awaiting the completion of primary data sources this function will hold the abort function. More...
 
log4cplus::Logger m_logger
 

Additional Inherited Members

- Public Types inherited from daq::DaqController
using ContextSignal = boost::signals2::signal< void(DaqContext const &)>
 

Detailed Description

Implements daq::DaqController for states responsible to be executed by OCM.

The states executed by DPM are implemented by DpmDaqController.

Definition at line 390 of file daqController.hpp.


Class Documentation

◆ daq::OcmDaqController::Aborted

struct daq::OcmDaqController::Aborted

Definition at line 435 of file daqController.hpp.

◆ daq::OcmDaqController::Aborting

struct daq::OcmDaqController::Aborting

Definition at line 434 of file daqController.hpp.

◆ daq::OcmDaqController::Acquiring

struct daq::OcmDaqController::Acquiring

Definition at line 431 of file daqController.hpp.

◆ daq::OcmDaqController::NotStarted

struct daq::OcmDaqController::NotStarted

Definition at line 429 of file daqController.hpp.

◆ daq::OcmDaqController::Starting

struct daq::OcmDaqController::Starting

Definition at line 430 of file daqController.hpp.

◆ daq::OcmDaqController::Stopped

struct daq::OcmDaqController::Stopped

Definition at line 433 of file daqController.hpp.

◆ daq::OcmDaqController::Stopping

struct daq::OcmDaqController::Stopping

Definition at line 432 of file daqController.hpp.

Member Typedef Documentation

◆ StateVariant

Definition at line 437 of file daqController.hpp.

Constructor & Destructor Documentation

◆ OcmDaqController()

daq::OcmDaqController::OcmDaqController ( boost::asio::io_context &  io_context,
DaqContext  context,
DaqSources const &  sources,
std::shared_ptr< ObservableStatus status,
std::shared_ptr< ObservableEventLog event_log,
OcmAsyncOperations  ops 
)
protected

Definition at line 174 of file daqController.cpp.

Member Function Documentation

◆ AbortAsync()

boost::future< Status > daq::OcmDaqController::AbortAsync ( ErrorPolicy  policy)
overridevirtual

Aborts the data acquisition.

Parameters
policyError policy determining if errors are tolerated or not.

It is possible to issue this request more than once, to e.g. retry a failed abort attempt.

Precondition
GetState() not in (State::Aborted, State::Stopped)
Postcondition
GetState() == State::Aborting if a data acquisition was ongoing otherwise GetState() == State::Aborted.

Implements daq::DaqController.

Definition at line 409 of file daqController.cpp.

◆ AddInitialKeywords()

void daq::OcmDaqController::AddInitialKeywords ( )
protected

Definition at line 293 of file daqController.cpp.

◆ AwaitAsync()

boost::future< State > daq::OcmDaqController::AwaitAsync ( std::vector< std::string >  sources,
std::chrono::milliseconds  timeout 
)
overridevirtual

Awaits that data acquisition stops or aborts.

It is possible to await only only a subset of data sources by specifying their ids in sources.

Parameters
sourcesAn optional vector of source-ids to await, if empty all primary sources are awaited on.
Returns
future set with std::invalid_argument if source-id is not recognized.
future set with boost::broken_promise if DaqController is destroyed before operation completes.

Implements daq::DaqController.

Definition at line 493 of file daqController.cpp.

◆ Create()

std::shared_ptr< OcmDaqController > daq::OcmDaqController::Create ( boost::asio::io_context &  io_context,
DaqContext  context,
DaqSources const &  sources,
std::shared_ptr< ObservableStatus status,
std::shared_ptr< ObservableEventLog event_log,
OcmAsyncOperations  operations 
)
static

Construct object.

Parameters
io_contextExecutor used for continuations and timer.
contextGeneral context used to control DAQ execution.
statusData acquisition status object, also contains identifier (may not be empty). Caller is responsible for making the id unique.
primPrimary data sources
metaMetadata sources
Precondition
status == true.
event_log == true.
Exceptions
std::invalid_argumentif arguments are invalid.

Definition at line 157 of file daqController.cpp.

◆ FindSource()

std::optional< std::variant< gsl::not_null< Source< PrimSource > * >, gsl::not_null< Source< MetaSource > * > > > daq::OcmDaqController::FindSource ( std::string_view  source_id)
protected

Definition at line 632 of file daqController.cpp.

◆ GetLogger()

constexpr log4cplus::Logger const & daq::OcmDaqController::GetLogger ( ) const
constexprnoexcept
Returns
Logger associated with this DaqController.

Definition at line 231 of file daqController.cpp.

◆ GetState()

State daq::OcmDaqController::GetState ( ) const
overridevirtual
Returns
state of data acquisition.

Implements daq::DaqController.

Definition at line 204 of file daqController.cpp.

◆ InitiateAwaitPrimarySources()

void daq::OcmDaqController::InitiateAwaitPrimarySources ( )
protected

Await completion of primary sources.

If there are no sources this method does nothing.

Definition at line 669 of file daqController.cpp.

◆ MakeAwaitParams()

op::AwaitOpParams daq::OcmDaqController::MakeAwaitParams ( op::AlertState alerts)
protected

Definition at line 280 of file daqController.cpp.

◆ MakeParams()

op::AsyncOpParams daq::OcmDaqController::MakeParams ( op::AlertState alerts)
protected

Constructs the parameters used for asynchronous operations.

Note
OcmAsyncOpParams will bind references to member variables so caller must guarantee that DaqController outlives the async operation. This is normally done by holding a shared copy in the last .then continuation for the async operation, thus guaranteeing that all intermediate continuations will access a valid object.

Definition at line 268 of file daqController.cpp.

◆ MakeSources()

template<class SourceType >
std::vector< Source< SourceType > > daq::OcmDaqController::MakeSources ( std::vector< SourceType >  sources)
protected

Helper to build source vector.

Definition at line 657 of file daqController.cpp.

◆ MakeState()

OcmDaqController::StateVariant daq::OcmDaqController::MakeState ( State  s) const
protectednoexcept

Definition at line 235 of file daqController.cpp.

◆ ScheduleMergeAsync()

boost::future< State > daq::OcmDaqController::ScheduleMergeAsync ( )
overridevirtual

Schedules DAQ for merging by sending request to DPM.

Returns
future containing exception:
  • std::logic_error if DAQ has already been scheduled
  • mal::TimeoutException if DPM is offline (timeout).
  • unspecified DPM fails

Implements daq::DaqController.

Definition at line 473 of file daqController.cpp.

◆ SetErrorFlag()

void daq::OcmDaqController::SetErrorFlag ( bool  error)
protectednoexcept

Definition at line 258 of file daqController.cpp.

◆ SetState()

void daq::OcmDaqController::SetState ( OcmDaqController::StateVariant &&  s)
protectednoexcept

Definition at line 262 of file daqController.cpp.

◆ StartAsync()

boost::future< State > daq::OcmDaqController::StartAsync ( )
overridevirtual

Starts the data acquisition.

Returns
A future that will be Set once data acquisition has started or or fails.
Exceptions
std::exception-derivedexception if internal error occurs.
Returns
Future that is ready once all sources are started or failed.
Precondition
GetState() == State::Notstarted
Postcondition
GetState() == State::Starting on success GetState() == State::Error on error

Implements daq::DaqController.

Definition at line 297 of file daqController.cpp.

◆ StopAsync()

boost::future< Status > daq::OcmDaqController::StopAsync ( ErrorPolicy  policy)
overridevirtual

Stops the data acquisition.

Precondition
GetState() not in (State::Stopped or State::Aborted)
Postcondition
GetState() == State::Stopping

Implements daq::DaqController.

Definition at line 340 of file daqController.cpp.

◆ UpdateKeywords()

void daq::OcmDaqController::UpdateKeywords ( fits::KeywordVector const &  keywords)
overridevirtual

Updates (replace or add) list of keywords.

Parameters
keywordsKeywords to add.

Implements daq::DaqController.

Definition at line 478 of file daqController.cpp.

Member Data Documentation

◆ m_abort_await_primary_sources

std::function<bool()> daq::OcmDaqController::m_abort_await_primary_sources
protected

If DaqController is awaiting the completion of primary data sources this function will hold the abort function.

@important Users must check if it is valid before invoking it.

Definition at line 501 of file daqController.hpp.

◆ m_async_ops

OcmAsyncOperations daq::OcmDaqController::m_async_ops
protected

Definition at line 491 of file daqController.hpp.

◆ m_logger

log4cplus::Logger daq::OcmDaqController::m_logger
protected

Definition at line 502 of file daqController.hpp.

◆ m_meta_sources

std::vector<Source<MetaSource> > daq::OcmDaqController::m_meta_sources
protected

Note: Consider vector immutable!

Definition at line 489 of file daqController.hpp.

◆ m_pending_replies

std::shared_ptr<PendingReplies> daq::OcmDaqController::m_pending_replies
protected

Definition at line 492 of file daqController.hpp.

◆ m_prim_sources

std::vector<Source<PrimSource> > daq::OcmDaqController::m_prim_sources
protected

Note: Consider vector immutable!

Definition at line 488 of file daqController.hpp.

◆ m_state

StateVariant daq::OcmDaqController::m_state
protected

Definition at line 486 of file daqController.hpp.

◆ m_timers

std::vector<std::unique_ptr<boost::asio::steady_timer> > daq::OcmDaqController::m_timers
protected

Definition at line 493 of file daqController.hpp.


The documentation for this class was generated from the following files: