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

Add new service binary: tsadump -f xxxxx.tsa

parent dbac5286
No related branches found
No related tags found
1 merge request!1979Binary to dump TSA file using flestool TS and MS formatters
add_subdirectory(archive_explorer)
add_subdirectory(histserv)
add_subdirectory(online_par_dump)
add_subdirectory(tsa_dump)
/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "Application.h"
#include "CbmFormatTsPrintout.h"
#include <StorableTimeslice.hpp>
#include <TimesliceAutoSource.hpp>
#include <Logger.h>
#include <iomanip>
#include <ios>
#include <iostream>
#include <sstream>
void Application::Run()
{
LOG(info) << "Calling string constructor with ";
LOG(info) << fOpts.sFullFilename;
fles::TimesliceAutoSource* fTsSource = new fles::TimesliceAutoSource(fOpts.sFullFilename);
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()));
LOG(info) << "=====================================\n" << ss.str();
uTsNb++;
if (fOpts.uNbTimeslices == uTsNb) {
break;
}
ts = fTsSource->get();
}
if (fOpts.uNbTimeslices == uTsNb) {
LOG(info) << "Requested number of TS reached; stopping there. Dumped " << uTsNb << " TS";
}
else {
LOG(info) << "End of archive reached; stopping there. Dumped " << uTsNb << " TS";
}
}
/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#pragma once
#include "ProgramOptions.h"
class Application {
public:
Application(ProgramOptions opts) : fOpts(opts) {}
void Run();
private:
ProgramOptions fOpts;
};
# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
# SPDX-License-Identifier: GPL-3.0-only
# Authors: Pierre-Alain Loizeau [committer]
set(APP tsadump)
set(INCLUDE_DIRECTORIES
${INCLUDE_DIRECTORIES}
${CMAKE_CURRENT_SOURCE_DIR}
${CBMROOT_SOURCE_DIR}
)
set(SRCS
Application.cxx
ProgramOptions.cxx
main.cxx
)
set(HEADERS
Application.h
ProgramOptions.h
)
add_executable(${APP} ${SRCS} ${HEADERS})
target_link_libraries(${APP}
PUBLIC
CbmFlibFlesTools
FairLogger::FairLogger
external::fles_ipc
libzmq
cppzmq
PRIVATE
Boost::program_options
external::fles_logging # Needed for TimesliceSource in CbmSourceTsArchive, not sure of conflicts with FairLogger
)
install(TARGETS ${APP} DESTINATION bin)
/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "ProgramOptions.h"
#include <boost/program_options.hpp>
#include <iostream>
namespace po = boost::program_options;
ProgramOptions::ProgramOptions(int argc, char** argv)
{
po::options_description required("Required options");
// clang-format off
required.add_options()
("filename,f", po::value(&sFullFilename)->value_name("<outputDir>")->required(),
"Full path to TSA file")
;
// clang-format on
po::options_description optional{"Other options"};
// clang-format off
optional.add_options()
("timeslices,n", po::value(&uNbTimeslices),
"number of timeslices")
("help,h", "Print help message")
;
// clang-format on
po::options_description cmdline_options;
cmdline_options.add(required).add(optional);
po::variables_map vm;
po::command_line_parser parser{argc, argv};
parser.options(cmdline_options);
try {
auto result = parser.run();
po::store(result, vm);
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE);
}
if (vm.count("help") > 0) {
std::cout << cmdline_options << std::endl;
std::exit(EXIT_SUCCESS);
}
try {
po::notify(vm);
}
catch (const po::required_option& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE);
}
}
/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#pragma once
#include <string>
struct ProgramOptions {
ProgramOptions(int argc, char** argv);
uint64_t uNbTimeslices = 0;
std::string sFullFilename;
};
/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "Application.h"
int main(int argc, char** argv)
{
ProgramOptions opts{argc, argv};
Application app{opts};
app.Run();
return 0;
}
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