DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::datahandlinglibs::FakeCardReaderBase Class Referenceabstract

#include <FakeCardReaderBase.hpp>

Public Member Functions

 FakeCardReaderBase (const std::string &name)
 FakeCardReaderBase Constructor.
virtual ~FakeCardReaderBase ()
 FakeCardReaderBase (const FakeCardReaderBase &)=delete
 FakeCardReaderBase is not copy-constructible.
FakeCardReaderBase & operator= (const FakeCardReaderBase &)=delete
 FakeCardReaderBase is not copy-assignable.
 FakeCardReaderBase (FakeCardReaderBase &&)=delete
 FakeCardReaderBase is not move-constructible.
FakeCardReaderBase & operator= (FakeCardReaderBase &&)=delete
 FakeCardReaderBase is not move-assignable.
void init (std::shared_ptr< appfwk::ConfigurationManager > cfg)
virtual std::shared_ptr< datahandlinglibs::SourceEmulatorConcept > create_source_emulator (const appmodel::DataMoveCallbackConf *cb, std::atomic< bool > &run_marker)=0
void do_conf (const appfwk::DAQModule::CommandData_t &)
void do_scrap (const appfwk::DAQModule::CommandData_t &)
void do_start (const appfwk::DAQModule::CommandData_t &)
void do_stop (const appfwk::DAQModule::CommandData_t &)
std::string get_fcr_name ()

Private Attributes

bool m_configured
std::string m_name
std::shared_ptr< appfwk::ConfigurationManager > m_cfg
std::map< std::string, std::shared_ptr< datahandlinglibs::SourceEmulatorConcept > > m_source_emus
std::unique_ptr< datahandlinglibs::FileSourceBuffer > m_source_buffer
std::atomic< bool > m_run_marker

Detailed Description

Definition at line 46 of file FakeCardReaderBase.hpp.

Constructor & Destructor Documentation

◆ FakeCardReaderBase() [1/3]

dunedaq::datahandlinglibs::FakeCardReaderBase::FakeCardReaderBase ( const std::string & name)
explicit

FakeCardReaderBase Constructor.

Parameters
nameInstance name for this FakeCardReaderBase instance

Definition at line 4 of file FakeCardReaderBase.hxx.

◆ ~FakeCardReaderBase()

virtual dunedaq::datahandlinglibs::FakeCardReaderBase::~FakeCardReaderBase ( )
inlinevirtual

Definition at line 54 of file FakeCardReaderBase.hpp.

54{}

◆ FakeCardReaderBase() [2/3]

dunedaq::datahandlinglibs::FakeCardReaderBase::FakeCardReaderBase ( const FakeCardReaderBase & )
delete

FakeCardReaderBase is not copy-constructible.

◆ FakeCardReaderBase() [3/3]

dunedaq::datahandlinglibs::FakeCardReaderBase::FakeCardReaderBase ( FakeCardReaderBase && )
delete

FakeCardReaderBase is not move-constructible.

Member Function Documentation

◆ create_source_emulator()

virtual std::shared_ptr< datahandlinglibs::SourceEmulatorConcept > dunedaq::datahandlinglibs::FakeCardReaderBase::create_source_emulator ( const appmodel::DataMoveCallbackConf * cb,
std::atomic< bool > & run_marker )
pure virtual

◆ do_conf()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_conf ( const appfwk::DAQModule::CommandData_t & )

Definition at line 44 of file FakeCardReaderBase.hxx.

45{
47 << get_fcr_name() << ": Entering do_conf() method";
48
49 if (m_configured) {
50 TLOG_DEBUG(dunedaq::datahandlinglibs::logging::TLVL_WORK_STEPS) << "This module is already configured!";
51 } else {
52 auto cfg = m_cfg->get_dal<appmodel::DataReaderModule>(get_fcr_name());
53
54 std::map<uint32_t, const confmodel::DetectorStream*> streams;
55 for (const auto& det_connections : cfg->get_connections()) {
56
57 for (const auto& stream : det_connections->streams()) {
58 streams[stream->get_source_id()] = stream;
59 }
60 }
61
62 for (const auto& cb : cfg->get_raw_data_callbacks()) {
63 if (m_source_emus.find(cb->UID()) == m_source_emus.end()) {
64 TLOG() << "Cannot find queue: " << cb->UID() << std::endl;
65 throw datahandlinglibs::GenericConfigurationError(ERS_HERE, "Cannot find queue: " + cb->UID());
66 }
67 if (m_source_emus[cb->UID()]->is_configured()) {
68 TLOG() << "Emulator for queue name " << cb->UID() << " was already configured";
69 throw datahandlinglibs::GenericConfigurationError(ERS_HERE, "Emulator configured twice: " + cb->UID());
70 }
71 m_source_emus[cb->UID()]->set_sink_config(cb);
72 m_source_emus[cb->UID()]->conf(streams[cb->get_source_id()], cfg->get_configuration()->get_emulation_conf());
73 }
74 for (auto& [name, emu] : m_source_emus) {
75 if (!emu->is_configured()) {
76 throw datahandlinglibs::GenericConfigurationError(ERS_HERE, "Not all links were configured");
77 }
78 }
79
80 // Mark configured
81 m_configured = true;
82 }
83
85 << get_fcr_name() << ": Exiting do_conf() method";
86}
#define ERS_HERE
std::map< std::string, std::shared_ptr< datahandlinglibs::SourceEmulatorConcept > > m_source_emus
std::shared_ptr< appfwk::ConfigurationManager > m_cfg
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
#define TLOG(...)
Definition macro.hpp:21

◆ do_scrap()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_scrap ( const appfwk::DAQModule::CommandData_t & args)

Definition at line 89 of file FakeCardReaderBase.hxx.

90{
92 << get_fcr_name() << ": Entering do_scrap() method";
93
94 for (auto& [name, emu] : m_source_emus) {
95 emu->scrap(args);
96 }
97
98 m_configured = false;
99
101 << get_fcr_name() << ": Exiting do_scrap() method";
102}

◆ do_start()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_start ( const appfwk::DAQModule::CommandData_t & args)

Definition at line 104 of file FakeCardReaderBase.hxx.

105{
107 << get_fcr_name() << ": Entering do_start() method";
108
109 m_run_marker.store(true);
110
111 for (auto& [name, emu] : m_source_emus) {
112 emu->acquire_callback();
113 emu->start(args);
114 }
115
117 << get_fcr_name() << ": Exiting do_start() method";
118}

◆ do_stop()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_stop ( const appfwk::DAQModule::CommandData_t & args)

Definition at line 121 of file FakeCardReaderBase.hxx.

122{
124 << get_fcr_name() << ": Entering do_stop() method";
125
126 m_run_marker = false;
127
128 for (auto& [name, emu] : m_source_emus) {
129 emu->stop(args);
130 }
131
133 << get_fcr_name() << ": Exiting do_stop() method";
134}

◆ get_fcr_name()

std::string dunedaq::datahandlinglibs::FakeCardReaderBase::get_fcr_name ( )
inline

Definition at line 74 of file FakeCardReaderBase.hpp.

74{ return m_name; }

◆ init()

void dunedaq::datahandlinglibs::FakeCardReaderBase::init ( std::shared_ptr< appfwk::ConfigurationManager > cfg)

Definition at line 12 of file FakeCardReaderBase.hxx.

13{
14 m_cfg = cfg;
16 << get_fcr_name() << ": Entering init() method";
17 // auto ini = args.get<appfwk::app::ModInit>();
18 auto ini = cfg->get_dal<appmodel::DataReaderModule>(m_name);
19 if (ini != nullptr && ini->get_configuration()->get_emulation_mode()) {
20
21 for (auto cb : ini->get_raw_data_callbacks()) {
22
23 try {
24 if (m_source_emus.find(cb->UID()) != m_source_emus.end()) {
25 TLOG() << get_fcr_name() << "Same callback instance used twice";
26 throw datahandlinglibs::FailedFakeCardInitialization(ERS_HERE, get_fcr_name(), "");
27 }
29 if (m_source_emus[cb->UID()].get() == nullptr) {
30 TLOG() << get_fcr_name() << "Source emulator could not be created";
31 throw datahandlinglibs::FailedFakeCardInitialization(ERS_HERE, get_fcr_name(), "");
32 }
33 // m_source_emus[cb->UID()]->init(cfg);
34 } catch (const ers::Issue& excpt) {
35 throw datahandlinglibs::ResourceQueueError(ERS_HERE, cb->UID(), get_fcr_name(), excpt);
36 }
37 }
38 }
40 << get_fcr_name() << ": Exiting init() method";
41}
virtual std::shared_ptr< datahandlinglibs::SourceEmulatorConcept > create_source_emulator(const appmodel::DataMoveCallbackConf *cb, std::atomic< bool > &run_marker)=0

◆ operator=() [1/2]

FakeCardReaderBase & dunedaq::datahandlinglibs::FakeCardReaderBase::operator= ( const FakeCardReaderBase & )
delete

FakeCardReaderBase is not copy-assignable.

◆ operator=() [2/2]

FakeCardReaderBase & dunedaq::datahandlinglibs::FakeCardReaderBase::operator= ( FakeCardReaderBase && )
delete

FakeCardReaderBase is not move-assignable.

Member Data Documentation

◆ m_cfg

std::shared_ptr<appfwk::ConfigurationManager> dunedaq::datahandlinglibs::FakeCardReaderBase::m_cfg
private

Definition at line 80 of file FakeCardReaderBase.hpp.

◆ m_configured

bool dunedaq::datahandlinglibs::FakeCardReaderBase::m_configured
private

Definition at line 78 of file FakeCardReaderBase.hpp.

◆ m_name

std::string dunedaq::datahandlinglibs::FakeCardReaderBase::m_name
private

Definition at line 79 of file FakeCardReaderBase.hpp.

◆ m_run_marker

std::atomic<bool> dunedaq::datahandlinglibs::FakeCardReaderBase::m_run_marker
private

Definition at line 88 of file FakeCardReaderBase.hpp.

◆ m_source_buffer

std::unique_ptr<datahandlinglibs::FileSourceBuffer> dunedaq::datahandlinglibs::FakeCardReaderBase::m_source_buffer
private

Definition at line 85 of file FakeCardReaderBase.hpp.

◆ m_source_emus

std::map<std::string, std::shared_ptr<datahandlinglibs::SourceEmulatorConcept> > dunedaq::datahandlinglibs::FakeCardReaderBase::m_source_emus
private

Definition at line 82 of file FakeCardReaderBase.hpp.


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