From fa28b34a2c018cec0c780f6dc01c8f86a0d616b3 Mon Sep 17 00:00:00 2001 From: Alessandro Thea Date: Wed, 7 Aug 2024 16:04:34 +0200 Subject: [PATCH 1/2] fixed broken include --- .../tde/TDEEthFrameProcessor.hpp | 8 +-- src/tde/TDEEthFrameProcessor.cpp | 63 +++++++++++-------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp b/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp index ff4a5bb..0614914 100644 --- a/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp +++ b/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp @@ -13,7 +13,7 @@ #include "iomanager/Sender.hpp" #include "logging/Logging.hpp" -#include "readoutlibs/models/TaskRawDataProcessorModel.hpp" +#include "datahandlinglibs/models/TaskRawDataProcessorModel.hpp" #include "fdreadoutlibs/FDReadoutIssues.hpp" #include "fdreadoutlibs/TDEEthTypeAdapter.hpp" @@ -37,16 +37,16 @@ namespace dunedaq { namespace fdreadoutlibs { -class TDEEthFrameProcessor : public readoutlibs::TaskRawDataProcessorModel +class TDEEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel { public: - using inherited = readoutlibs::TaskRawDataProcessorModel; + using inherited = datahandlinglibs::TaskRawDataProcessorModel; using frameptr = types::TDEEthTypeAdapter*; using constframeptr = const types::TDEEthTypeAdapter*; using tdeframeptr = dunedaq::fddetdataformats::TDEEthFrame*; - explicit TDEEthFrameProcessor(std::unique_ptr& error_registry); + explicit TDEEthFrameProcessor(std::unique_ptr& error_registry); ~TDEEthFrameProcessor(); diff --git a/src/tde/TDEEthFrameProcessor.cpp b/src/tde/TDEEthFrameProcessor.cpp index 65a43d7..ec9aaa3 100644 --- a/src/tde/TDEEthFrameProcessor.cpp +++ b/src/tde/TDEEthFrameProcessor.cpp @@ -6,24 +6,25 @@ * received with this code. */ #include "fdreadoutlibs/tde/TDEEthFrameProcessor.hpp" // NOLINT(build/include) +#include "confmodel/GeoId.hpp" +#include "appmodel/RawDataProcessor.hpp" -#include "appfwk/DAQModuleHelper.hpp" #include "iomanager/Sender.hpp" #include "logging/Logging.hpp" -#include "readoutlibs/FrameErrorRegistry.hpp" -#include "readoutlibs/ReadoutIssues.hpp" -#include "readoutlibs/ReadoutLogging.hpp" -#include "readoutlibs/models/IterableQueueModel.hpp" -#include "readoutlibs/readoutconfig/Nljs.hpp" -#include "readoutlibs/readoutinfo/InfoNljs.hpp" -#include "readoutlibs/utils/ReusableThread.hpp" +#include "datahandlinglibs/FrameErrorRegistry.hpp" +#include "datahandlinglibs/DataHandlingIssues.hpp" +#include "datahandlinglibs/ReadoutLogging.hpp" +#include "datahandlinglibs/models/IterableQueueModel.hpp" +// #include "datahandlinglibs/readoutconfig/Nljs.hpp" +#include "datahandlinglibs/readoutinfo/InfoNljs.hpp" +#include "datahandlinglibs/utils/ReusableThread.hpp" #include "fddetdataformats/TDEEthFrame.hpp" #include "fdreadoutlibs/TDEEthTypeAdapter.hpp" -#include "fdreadoutlibs/TriggerPrimitiveTypeAdapter.hpp" +#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include #include @@ -36,8 +37,8 @@ #include #include -using dunedaq::readoutlibs::logging::TLVL_BOOKKEEPING; -using dunedaq::readoutlibs::logging::TLVL_TAKE_NOTE; +using dunedaq::datahandlinglibs::logging::TLVL_BOOKKEEPING; +using dunedaq::datahandlinglibs::logging::TLVL_TAKE_NOTE; // THIS SHOULDN'T BE HERE!!!!! But it is necessary..... DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TriggerPrimitiveTypeAdapter, "TriggerPrimitive") @@ -46,7 +47,7 @@ DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TriggerPrimitiveTypeAdapter, namespace dunedaq { namespace fdreadoutlibs { -TDEEthFrameProcessor::TDEEthFrameProcessor(std::unique_ptr& error_registry) +TDEEthFrameProcessor::TDEEthFrameProcessor(std::unique_ptr& error_registry) : TaskRawDataProcessorModel(error_registry) { } @@ -85,18 +86,30 @@ TDEEthFrameProcessor::init(const nlohmann::json& args) } void -TDEEthFrameProcessor::conf(const nlohmann::json& cfg) +TDEEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) { - auto config = cfg["rawdataprocessorconf"].get(); - - m_sourceid.subsystem = types::TDEEthTypeAdapter::subsystem; + auto config = cfg["rawdataprocessorconf"].get(); + + for (auto output : conf->get_outputs()) { + try { + if (output->get_data_type() == "TriggerPrimitive") { + m_tp_sink = get_iom_sender(output->UID()); + } + } catch (const ers::Issue& excpt) { + ers::error(datahandlinglibs::ResourceQueueError(ERS_HERE, "tp", "DefaultRequestHandlerModel", excpt)); + } + } - m_crate_no = config.crate_id; - m_slot_no = config.slot_id; - m_stream_id = config.link_id; - // Setup pre-processing pipeline - inherited::add_preprocess_task(std::bind(&TDEEthFrameProcessor::sequence_check, this, std::placeholders::_1)); - inherited::add_preprocess_task(std::bind(&TDEEthFrameProcessor::timestamp_check, this, std::placeholders::_1)); + m_sourceid.id = conf->get_source_id(); + m_sourceid.subsystem = types::DUNEWIBEthTypeAdapter::subsystem; + auto geo_id = conf->get_geo_id(); + if (geo_id != nullptr) { + m_det_id = geo_id->get_detector_id(); + m_crate_id = geo_id->get_crate_id(); + m_slot_id = geo_id->get_slot_id(); + m_stream_id = geo_id->get_stream_id(); + } + m_emulator_mode = conf->get_emulation_mode(); inherited::conf(cfg); } @@ -104,7 +117,7 @@ TDEEthFrameProcessor::conf(const nlohmann::json& cfg) void TDEEthFrameProcessor::get_info(opmonlib::InfoCollector& ci, int level) { - readoutlibs::readoutinfo::RawDataProcessorInfo info; + datahandlinglibs::readoutinfo::RawDataProcessorInfo info; info.num_seq_id_errors = m_seq_id_error_ctr.load(); info.min_seq_id_jump = m_seq_id_min_jump.exchange(0); @@ -158,7 +171,7 @@ TDEEthFrameProcessor::sequence_check(frameptr fp) m_seq_id_max_jump = std::max(delta_seq_id, m_seq_id_max_jump.load()); m_seq_id_min_jump = std::min(delta_seq_id, m_seq_id_min_jump.load()); - m_error_registry->add_error("SEQUENCE_ID_JUMP", readoutlibs::FrameErrorRegistry::ErrorInterval(expected_seq_id, m_current_seq_id)); + m_error_registry->add_error("SEQUENCE_ID_JUMP", datahandlinglibs::FrameErrorRegistry::ErrorInterval(expected_seq_id, m_current_seq_id)); if (m_first_seq_id_mismatch) { // log once TLOG_DEBUG(TLVL_BOOKKEEPING) << "First sequence id MISSMATCH! -> | previous: " << std::to_string(m_previous_seq_id) << " current: " + std::to_string(m_current_seq_id); m_first_seq_id_mismatch = false; @@ -210,7 +223,7 @@ TDEEthFrameProcessor::timestamp_check(frameptr fp) // Check timestamp if (m_current_ts - m_previous_ts != tdeeth_frame_tick_difference) { ++m_ts_error_ctr; - m_error_registry->add_error("MISSING_FRAMES", readoutlibs::FrameErrorRegistry::ErrorInterval(m_previous_ts + tdeeth_frame_tick_difference, m_current_ts)); + m_error_registry->add_error("MISSING_FRAMES", datahandlinglibs::FrameErrorRegistry::ErrorInterval(m_previous_ts + tdeeth_frame_tick_difference, m_current_ts)); if (m_first_ts_missmatch) { // log once TLOG_DEBUG(TLVL_BOOKKEEPING) << "First timestamp MISSMATCH! -> | previous: " << std::to_string(m_previous_ts) << " current: " + std::to_string(m_current_ts); m_first_ts_missmatch = false; From 678ebe3d1e2fd2f653632858899dc1979f704c0f Mon Sep 17 00:00:00 2001 From: Alessandro Thea Date: Wed, 7 Aug 2024 16:27:32 +0200 Subject: [PATCH 2/2] realigning TDE methods with v5 --- .../tde/TDEEthFrameProcessor.hpp | 12 ++-- src/tde/TDEEthFrameProcessor.cpp | 66 +++++++++---------- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp b/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp index 0614914..15f5827 100644 --- a/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp +++ b/include/fdreadoutlibs/tde/TDEEthFrameProcessor.hpp @@ -17,6 +17,7 @@ #include "fdreadoutlibs/FDReadoutIssues.hpp" #include "fdreadoutlibs/TDEEthTypeAdapter.hpp" +#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include "daqdataformats/Types.hpp" @@ -54,9 +55,9 @@ class TDEEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< void stop(const nlohmann::json& args) override; - void init(const nlohmann::json& args) override; + // void init(const nlohmann::json& args) override; - void conf(const nlohmann::json& cfg) override; + void conf(const appmodel::DataHandlerModule* conf) override; void get_info(opmonlib::InfoCollector& ci, int level) override; @@ -100,9 +101,12 @@ class TDEEthFrameProcessor : public datahandlinglibs::TaskRawDataProcessorModel< private: uint32_t m_det_id; // NOLINT(build/unsigned) - uint32_t m_crate_no; // NOLINT(build/unsigned) - uint32_t m_slot_no; // NOLINT(build/unsigned) + uint32_t m_crate_id; // NOLINT(build/unsigned) + uint32_t m_slot_id; // NOLINT(build/unsigned) uint32_t m_stream_id; // NOLINT(build/unsigned) + bool m_emulator_mode = false; + + std::shared_ptr> m_tp_sink; }; diff --git a/src/tde/TDEEthFrameProcessor.cpp b/src/tde/TDEEthFrameProcessor.cpp index ec9aaa3..7524bab 100644 --- a/src/tde/TDEEthFrameProcessor.cpp +++ b/src/tde/TDEEthFrameProcessor.cpp @@ -41,7 +41,7 @@ using dunedaq::datahandlinglibs::logging::TLVL_BOOKKEEPING; using dunedaq::datahandlinglibs::logging::TLVL_TAKE_NOTE; // THIS SHOULDN'T BE HERE!!!!! But it is necessary..... -DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TriggerPrimitiveTypeAdapter, "TriggerPrimitive") +DUNE_DAQ_TYPESTRING(dunedaq::trigger::TriggerPrimitiveTypeAdapter, "TriggerPrimitive") namespace dunedaq { @@ -79,16 +79,10 @@ TDEEthFrameProcessor::stop(const nlohmann::json& args) inherited::stop(args); } -void -TDEEthFrameProcessor::init(const nlohmann::json& args) -{ -// inherited::init(args); -} - void TDEEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) { - auto config = cfg["rawdataprocessorconf"].get(); + // auto config = cfg["rawdataprocessorconf"].get(); for (auto output : conf->get_outputs()) { try { @@ -101,7 +95,7 @@ TDEEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) } m_sourceid.id = conf->get_source_id(); - m_sourceid.subsystem = types::DUNEWIBEthTypeAdapter::subsystem; + m_sourceid.subsystem = types::TDEEthTypeAdapter::subsystem; auto geo_id = conf->get_geo_id(); if (geo_id != nullptr) { m_det_id = geo_id->get_detector_id(); @@ -111,7 +105,7 @@ TDEEthFrameProcessor::conf(const appmodel::DataHandlerModule* conf) } m_emulator_mode = conf->get_emulation_mode(); - inherited::conf(cfg); + inherited::conf(conf); } void @@ -137,19 +131,19 @@ void TDEEthFrameProcessor::sequence_check(frameptr fp) { - // If EMU data, emulate perfectly incrementing timestamp - if (inherited::m_emulator_mode) { // emulate perfectly incrementing timestamp - // uint64_t ts_next = m_previous_seq_id + 1; // NOLINT(build/unsigned) - auto tf = reinterpret_cast(((uint8_t*)fp)); // NOLINT - for (unsigned int i = 0; i < fp->get_num_frames(); ++i) { // NOLINT(build/unsigned) - //auto wfh = const_cast(tf->header()); - tf->daq_header.crate_id = m_crate_no; - tf->daq_header.slot_id = m_slot_no; - tf->daq_header.stream_id = m_stream_id; - tf->daq_header.seq_id = (m_previous_seq_id+i) & 0xfff; - tf++; - } - } + // // If EMU data, emulate perfectly incrementing timestamp + // if (inherited::m_emulator_mode) { // emulate perfectly incrementing timestamp + // // uint64_t ts_next = m_previous_seq_id + 1; // NOLINT(build/unsigned) + // auto tf = reinterpret_cast(((uint8_t*)fp)); // NOLINT + // for (unsigned int i = 0; i < fp->get_num_frames(); ++i) { // NOLINT(build/unsigned) + // //auto wfh = const_cast(tf->header()); + // tf->daq_header.crate_id = m_crate_no; + // tf->daq_header.slot_id = m_slot_no; + // tf->daq_header.stream_id = m_stream_id; + // tf->daq_header.seq_id = (m_previous_seq_id+i) & 0xfff; + // tf++; + // } + // } // Acquire timestamp auto wfptr = reinterpret_cast(fp); // NOLINT @@ -202,19 +196,19 @@ TDEEthFrameProcessor::timestamp_check(frameptr fp) uint16_t tdeeth_frame_tick_difference = tdeeth_tick_difference * fp->get_num_frames(); // If EMU data, emulate perfectly incrementing timestamp - if (inherited::m_emulator_mode) { // emulate perfectly incrementing timestamp - uint64_t ts_next = m_previous_ts + tdeeth_frame_tick_difference; // NOLINT(build/unsigned) - auto tf = reinterpret_cast(((uint8_t*)fp)); // NOLINT - for (unsigned int i = 0; i < fp->get_num_frames(); ++i) { // NOLINT(build/unsigned) - //auto wfh = const_cast(tf->header()); - tf->daq_header.crate_id = m_crate_no; - tf->daq_header.slot_id = m_slot_no; - tf->daq_header.stream_id = m_stream_id; - tf->set_timestamp(ts_next); - ts_next += tdeeth_tick_difference; - tf++; - } - } + // if (inherited::m_emulator_mode) { // emulate perfectly incrementing timestamp + // uint64_t ts_next = m_previous_ts + tdeeth_frame_tick_difference; // NOLINT(build/unsigned) + // auto tf = reinterpret_cast(((uint8_t*)fp)); // NOLINT + // for (unsigned int i = 0; i < fp->get_num_frames(); ++i) { // NOLINT(build/unsigned) + // //auto wfh = const_cast(tf->header()); + // tf->daq_header.crate_id = m_crate_no; + // tf->daq_header.slot_id = m_slot_no; + // tf->daq_header.stream_id = m_stream_id; + // tf->set_timestamp(ts_next); + // ts_next += tdeeth_tick_difference; + // tf++; + // } + // } // Acquire timestamp auto wfptr = reinterpret_cast(fp); // NOLINT