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.
 
FakeCardReaderBaseoperator= (const FakeCardReaderBase &)=delete
 FakeCardReaderBase is not copy-assignable.
 
 FakeCardReaderBase (FakeCardReaderBase &&)=delete
 FakeCardReaderBase is not move-constructible.
 
FakeCardReaderBaseoperator= (FakeCardReaderBase &&)=delete
 FakeCardReaderBase is not move-assignable.
 
void init (std::shared_ptr< appfwk::ConfigurationManager > cfg)
 
virtual std::shared_ptr< datahandlinglibs::SourceEmulatorConceptcreate_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::FileSourceBufferm_source_buffer
 
std::atomic< boolm_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 42 of file FakeCardReaderBase.hxx.

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

◆ do_scrap()

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

Definition at line 86 of file FakeCardReaderBase.hxx.

87{
89
90 for (auto& [name, emu] : m_source_emus) {
91 emu->scrap(args);
92 }
93
94 m_configured = false;
95
97}

◆ do_start()

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

Definition at line 99 of file FakeCardReaderBase.hxx.

100{
102
103 m_run_marker.store(true);
104
105 for (auto& [name, emu] : m_source_emus) {
106 emu->start(args);
107 }
108
110}

◆ do_stop()

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

Definition at line 113 of file FakeCardReaderBase.hxx.

114{
116
117 m_run_marker = false;
118
119 for (auto& [name, emu] : m_source_emus) {
120 emu->stop(args);
121 }
122
124}

◆ get_fcr_name()

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

Definition at line 73 of file FakeCardReaderBase.hpp.

73{ 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 //auto ini = args.get<appfwk::app::ModInit>();
17 auto ini = cfg->get_dal<appmodel::DataReaderModule>(m_name);
18 if (ini != nullptr && ini->get_configuration()->get_emulation_mode()) {
19
20 for (auto cb : ini->get_raw_data_callbacks()) {
21
22 try {
23 if (m_source_emus.find(cb->UID()) != m_source_emus.end()) {
24 TLOG() << get_fcr_name() << "Same callback instance used twice";
25 throw datahandlinglibs::FailedFakeCardInitialization(ERS_HERE, get_fcr_name(), "");
26 }
28 if (m_source_emus[cb->UID()].get() == nullptr) {
29 TLOG() << get_fcr_name() << "Source emulator could not be created";
30 throw datahandlinglibs::FailedFakeCardInitialization(ERS_HERE, get_fcr_name(), "");
31 }
32 // m_source_emus[cb->UID()]->init(cfg);
33 } catch (const ers::Issue& excpt) {
34 throw datahandlinglibs::ResourceQueueError(ERS_HERE, cb->UID(), get_fcr_name(), excpt);
35 }
36 }
37 }
39}
virtual std::shared_ptr< datahandlinglibs::SourceEmulatorConcept > create_source_emulator(const appmodel::DataMoveCallbackConf *cb, std::atomic< bool > &run_marker)=0
Base class for any user define issue.
Definition Issue.hpp:69

◆ 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 79 of file FakeCardReaderBase.hpp.

◆ m_configured

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

Definition at line 77 of file FakeCardReaderBase.hpp.

◆ m_name

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

Definition at line 78 of file FakeCardReaderBase.hpp.

◆ m_run_marker

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

Definition at line 87 of file FakeCardReaderBase.hpp.

◆ m_source_buffer

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

Definition at line 84 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 81 of file FakeCardReaderBase.hpp.


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