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 (std::string qi, std::atomic< bool > &run_marker)=0
 
void do_conf (const nlohmann::json &)
 
void do_scrap (const nlohmann::json &)
 
void do_start (const nlohmann::json &)
 
void do_stop (const nlohmann::json &)
 
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< 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 ( std::string qi,
std::atomic< bool > & run_marker )
pure virtual

◆ do_conf()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_conf ( const nlohmann::json & )

Definition at line 43 of file FakeCardReaderBase.hxx.

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

◆ do_scrap()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_scrap ( const nlohmann::json & args)

Definition at line 89 of file FakeCardReaderBase.hxx.

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

◆ do_start()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_start ( const nlohmann::json & args)

Definition at line 102 of file FakeCardReaderBase.hxx.

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

◆ do_stop()

void dunedaq::datahandlinglibs::FakeCardReaderBase::do_stop ( const nlohmann::json & args)

Definition at line 116 of file FakeCardReaderBase.hxx.

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

◆ 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 qi : ini->get_outputs()) {
21
22 try {
23 if (m_source_emus.find(qi->UID()) != m_source_emus.end()) {
24 TLOG() << get_fcr_name() << "Same queue instance used twice";
25 throw datahandlinglibs::FailedFakeCardInitialization(ERS_HERE, get_fcr_name(), "");
26 }
27 m_source_emus[qi->UID()] = create_source_emulator(qi->UID(), m_run_marker);
28 if (m_source_emus[qi->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[qi->UID()]->init(cfg);
33 m_source_emus[qi->UID()]->set_sender(qi->UID());
34 } catch (const ers::Issue& excpt) {
35 throw datahandlinglibs::ResourceQueueError(ERS_HERE, qi->UID(), get_fcr_name(), excpt);
36 }
37 }
38 }
40}
virtual std::shared_ptr< datahandlinglibs::SourceEmulatorConcept > create_source_emulator(std::string qi, 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: