Skip to content
Snippets Groups Projects
Commit 0b2cf448 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau
Browse files

Add more detail in printout and more options in tsadump binary

- Print helper block with description of the miscoslice descriptor dump lines
- Add option to select a given system ID
- Add option to print only a given number of microslices for each component in each TS
parent b43b6264
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include "Application.h"
#include "CbmFormatMsHeaderPrintout.h"
#include "CbmFormatTsPrintout.h"
#include <StorableTimeslice.hpp>
......@@ -22,13 +23,17 @@ void Application::Run()
LOG(info) << fOpts.sFullFilename;
fles::TimesliceAutoSource* fTsSource = new fles::TimesliceAutoSource(fOpts.sFullFilename);
LOG(info) << "Selected SysID: " << std::hex << fOpts.selSysId << std::dec;
LOG(info) << FormatMsHeaderHelp();
std::unique_ptr<fles::Timeslice> ts;
ts = fTsSource->get();
uint64_t uTsNb = 0;
while (ts) {
// Use << operator defined in <cbmroot_src>core/base/utils/flestools/CbmFormatTsPrintout.h
std::stringstream ss;
ss << (*(ts.get()));
ss << FormatTsPrintout(*(ts.get()), fOpts.selSysId, fOpts.nbMsPerComp);
LOG(info) << "=====================================\n" << ss.str();
uTsNb++;
if (fOpts.uNbTimeslices == uTsNb) {
......
......@@ -6,6 +6,7 @@
#include <boost/program_options.hpp>
#include <functional>
#include <iostream>
namespace po = boost::program_options;
......@@ -25,6 +26,14 @@ ProgramOptions::ProgramOptions(int argc, char** argv)
optional.add_options()
("timeslices,n", po::value(&uNbTimeslices),
"number of timeslices")
("sys,s", po::value<std::string>()->notifier(std::bind(&ProgramOptions::ConvertSysId, this, std::placeholders::_1)),
"SysId to select (component level), in hex! 0x00 to 0xFF!")
// Hint: cannot use std::underlying_type_t<fles::Subsystem> directly for two reasons (-_-)
// 1) this resolves to uint8_t and boost then want a character as program argument, not a number (which is typically
// multiple characters)
// 2) boost program_options cannot digest hexadecimal numbers (0xYY) as input
("mspercomp,m", po::value(&nbMsPerComp),
"number of microslices to dump per component")
("help,h", "Print help message")
;
// clang-format on
......@@ -59,4 +68,24 @@ ProgramOptions::ProgramOptions(int argc, char** argv)
std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE);
}
catch (const po::invalid_option_value& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE);
}
}
void ProgramOptions::ConvertSysId(const std::string& sOption)
{
std::stringstream interpreter;
interpreter << std::hex << sOption;
interpreter >> selSysId;
if (0xFF < selSysId) {
std::stringstream ss;
// Not sure why the option name is not shown at same place as in default error message, probably wrong step in boost
// program_options calls sequence or wrong error type.... gave up, not important
ss << sOption << ": Value out of range (bigger than 0xFF) for --sys";
throw po::invalid_option_value(ss.str());
}
}
......@@ -4,11 +4,19 @@
#pragma once
#include "MicrosliceDescriptor.hpp"
#include <cstdint> // For SIZE_MAX
#include <string>
struct ProgramOptions {
ProgramOptions(int argc, char** argv);
uint64_t uNbTimeslices = 0;
std::string sFullFilename;
uint64_t uNbTimeslices = 0;
// FIXME: define "reserved/undefined" system ID somewhere (best in flesnet microslice descriptor header)
uint16_t selSysId = 0x00;
size_t nbMsPerComp = SIZE_MAX;
void ConvertSysId(const std::string& option);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment