16#include "FairMQLogger.h"
17#include "FairMQProgOptions.h"
18#include "TimesliceInputArchive.hpp"
19#include "TimesliceSubscriber.hpp"
21#include <boost/archive/binary_oarchive.hpp>
33 using std::runtime_error::runtime_error;
55 fFileName = fConfig->GetValue<
string>(
"filename");
56 fHost = fConfig->GetValue<
string>(
"flib-host");
57 fPort = fConfig->GetValue<uint64_t>(
"flib-port");
62 LOG(info) <<
"Host: " <<
fHost;
63 LOG(info) <<
"Port: " <<
fPort;
75 int noChannel = fChannels.size();
76 LOG(info) <<
"Number of defined output channels: " << noChannel;
77 for (
auto const& entry : fChannels) {
78 LOG(info) <<
"Channel name: " << entry.first;
83 std::string connector =
"tcp://" +
fHost +
":" + std::to_string(
fPort);
84 LOG(info) <<
"Open TSPublisher at " << connector;
85 fSource =
new fles::TimesliceSubscriber(connector, 1);
89 LOG(info) <<
"Open the Flib input file " <<
fFileName;
91 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
92 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
97 fTime = std::chrono::steady_clock::now();
100 LOG(error) << e.what();
108 LOG(info) <<
"Channel name " << channelName <<
" found in list of allowed channel names.";
112 LOG(info) <<
"Channel name " << channelName <<
" not found in list of allowed channel names.";
113 LOG(error) <<
"Stop device.";
122 auto timeslice =
fSource->get();
128 const fles::Timeslice& ts = *timeslice;
132 LOG(info) <<
"Found " << ts.num_components() <<
" different components in timeslice";
153 std::chrono::duration<double> run_time = std::chrono::steady_clock::now() -
fTime;
155 LOG(info) <<
"Runtime: " << run_time.count();
156 LOG(info) <<
"No more input data";
162 LOG(info) <<
"Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) << std::dec;
163 LOG(info) <<
"Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) << std::dec;
164 LOG(info) <<
"Equipement ID: " << mdsc.eq_id;
165 LOG(info) <<
"Flags: " << mdsc.flags;
166 LOG(info) <<
"Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) << std::dec;
167 LOG(info) <<
"Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) << std::dec;
168 LOG(info) <<
"Microslice Idx: " << mdsc.idx;
169 LOG(info) <<
"Checksum: " << mdsc.crc;
170 LOG(info) <<
"Size: " << mdsc.size;
171 LOG(info) <<
"Offset: " << mdsc.offset;
176 if (0 == ts.num_components()) {
177 LOG(error) <<
"No Component in TS " << ts.index();
180 LOG(info) <<
"Found " << ts.num_components() <<
" different components in timeslice";
182 for (
size_t c = 0; c < ts.num_components(); ++c) {
183 LOG(info) <<
"Found " << ts.num_microslices(c) <<
" microslices in component " << c;
184 LOG(info) <<
"Component " << c <<
" has a size of " << ts.size_component(c) <<
" bytes";
185 LOG(info) <<
"Component " << c <<
" has the system id 0x" << std::hex
186 <<
static_cast<int>(ts.descriptor(c, 0).sys_id) << std::dec;
std::vector< std::string > fAllowedChannels
virtual bool ConditionalRun()
std::chrono::steady_clock::time_point fTime
bool IsChannelNameAllowed(std::string)
std::vector< std::string > fInputFileList
List of input files.
bool CheckTimeslice(const fles::Timeslice &ts)
fles::TimesliceSource * fSource
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor &mdsc)
void ChangeState(FairMQDevice *device, cbm::mq::Transition transition)