From 06fe42cc5bdbb53d20d6705c63f01d92b74fcafe Mon Sep 17 00:00:00 2001 From: Petr Zejdl <petr.zejdl@cern.ch> Date: Tue, 1 Feb 2022 19:18:14 +0100 Subject: [PATCH] Introducing ProcessorType option as a replacement for SystemName --- src/config.h | 16 +++++++++++++--- src/controls.h | 1 - src/output.cc | 4 ++-- src/processor.cc | 15 ++++++++------- src/processor.h | 7 +++++-- src/scdaq.cc | 3 +-- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/config.h b/src/config.h index bf70abc0..d7e20edb 100644 --- a/src/config.h +++ b/src/config.h @@ -6,6 +6,7 @@ #include "boost/lexical_cast.hpp" #include <map> #include <stdexcept> +#include "processor.h" class config{ public: @@ -48,9 +49,6 @@ public: std::string v = vmap.at("packets_per_report"); return boost::lexical_cast<uint32_t>(v.c_str()); } - const std::string& getSystemName() const { - return vmap.at("system_name"); - } const std::string& getInputFile() const { return vmap.at("input_file"); } @@ -66,6 +64,18 @@ public: std::string v = vmap.at("pt_cut"); return boost::lexical_cast<uint32_t>(v.c_str()); } + + StreamProcessor::ProcessorType getProcessorType() const { + const std::string& input = vmap.at("processor_type"); + if (input == "PASS_THROUGH") { + return StreamProcessor::ProcessorType::PASS_THROUGH; + } + if (input == "GMT") { + return StreamProcessor::ProcessorType::GMT; + } + throw std::invalid_argument("Configuration error: Wrong processor type '" + input + "'"); + } + const std::string& getOutputFilenamePrefix() const { return vmap.at("output_filename_prefix"); diff --git a/src/controls.h b/src/controls.h index 80cb0a0b..cf93686f 100644 --- a/src/controls.h +++ b/src/controls.h @@ -6,7 +6,6 @@ struct ctrl { uint32_t run_number; - std::string system_name; std::atomic<bool> running; /* Always write data to a file regardless of the run status */ bool output_force_write; diff --git a/src/output.cc b/src/output.cc index 44c19648..35e2f8ef 100644 --- a/src/output.cc +++ b/src/output.cc @@ -114,7 +114,7 @@ void* OutputStream::operator()( void* item ) } /* - * Create a properly formated file name + * Create a properly formatted file name * TODO: Change to C++ */ static std::string format_run_file_stem(std::string& filename_prefix, uint32_t run_number, int32_t file_count) @@ -178,7 +178,7 @@ void OutputStream::open_next_file() LOG(INFO) << " using index: " << file_count; } - // Create the ouput directory + // Create the output directory std::string output_directory = my_output_filename_base + "/" + working_dir; create_output_directory(output_directory); diff --git a/src/processor.cc b/src/processor.cc index e2726f2d..26b8b88b 100644 --- a/src/processor.cc +++ b/src/processor.cc @@ -4,12 +4,12 @@ #include "log.h" #include <iomanip> -StreamProcessor::StreamProcessor(size_t max_size_, bool doZS_, std::string systemName_) : +StreamProcessor::StreamProcessor(size_t max_size_, bool doZS_, ProcessorType processorType_) : tbb::filter(parallel), max_size(max_size_), nbPackets(0), doZS(doZS_), - systemName(systemName_) + processorType(processorType_) { LOG(TRACE) << "Created transform filter at " << static_cast<void*>(this); myfile.open ("example.txt"); @@ -28,11 +28,12 @@ Slice* StreamProcessor::process(Slice& input, Slice& out) char* q = out.begin(); uint32_t counts = 0; - if(systemName =="DMX"){ - memcpy(q,p,input.size()); - out.set_end(out.begin() + input.size()); - out.set_counts(1); - return &out;} + if (processorType == ProcessorType::PASS_THROUGH) { + memcpy(q,p,input.size()); + out.set_end(out.begin() + input.size()); + out.set_counts(1); + return &out; + } int bsize = sizeof(block1); if((input.size()-constants::orbit_trailer_size)%bsize!=0){ diff --git a/src/processor.h b/src/processor.h index fe12e5a2..736e9149 100644 --- a/src/processor.h +++ b/src/processor.h @@ -11,7 +11,10 @@ class Slice; class StreamProcessor: public tbb::filter { public: - StreamProcessor(size_t, bool, std::string); + enum class ProcessorType { PASS_THROUGH, GMT }; + +public: + StreamProcessor(size_t max_size_, bool doZS_, ProcessorType processorType_); void* operator()( void* item )/*override*/; ~StreamProcessor(); @@ -23,7 +26,7 @@ private: size_t max_size; uint64_t nbPackets; bool doZS; - std::string systemName; + ProcessorType processorType; }; #endif diff --git a/src/scdaq.cc b/src/scdaq.cc index d8a254cd..699429f4 100644 --- a/src/scdaq.cc +++ b/src/scdaq.cc @@ -66,7 +66,7 @@ int run_pipeline( int nbThreads, ctrl& control, config& conf ) // Create reformatter and add it to the pipeline // TODO: Created here so we are not subject of scoping, fix later... - StreamProcessor stream_processor(packetBufferSize, conf.getDoZS(), conf.getSystemName()); + StreamProcessor stream_processor(packetBufferSize, conf.getDoZS(), conf.getProcessorType()); if ( conf.getEnableStreamProcessor() ) { pipeline.add_filter( stream_processor ); } @@ -117,7 +117,6 @@ int main( int argc, char* argv[] ) { control.running = false; control.run_number = 0; - control.system_name = conf.getSystemName(); control.max_file_size = conf.getOutputMaxFileSize();//in Bytes control.packets_per_report = conf.getPacketsPerReport(); control.output_force_write = conf.getOutputForceWrite(); -- GitLab