12 #include "FairMQLogger.h"
13 #include "FairMQProgOptions.h"
15 #include "TimesliceInputArchive.hpp"
16 #include "TimesliceSubscriber.hpp"
18 #include <boost/archive/binary_oarchive.hpp>
30 using std::runtime_error::runtime_error;
49 fFileName = fConfig->GetValue<
string>(
"filename");
50 fHost = fConfig->GetValue<
string>(
"flib-host");
51 fPort = fConfig->GetValue<uint64_t>(
"flib-port");
56 LOG(info) <<
"Host: " <<
fHost;
57 LOG(info) <<
"Port: " <<
fPort;
69 int noChannel = fChannels.size();
70 LOG(info) <<
"Number of defined output channels: " << noChannel;
71 for (
auto const& entry : fChannels) {
72 LOG(info) <<
"Channel name: " << entry.first;
78 std::string connector =
"tcp://" +
fHost +
":" + std::to_string(
fPort);
79 LOG(info) <<
"Open TSPublisher at " << connector;
80 fSource =
new fles::TimesliceSubscriber(connector);
83 LOG(info) <<
"Open the Flib input file " <<
fFileName;
85 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
86 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
91 fTime = std::chrono::steady_clock::now();
93 LOG(error) << e.what();
101 LOG(info) <<
"Channel name " << channelName
102 <<
" found in list of allowed channel names.";
105 LOG(info) <<
"Channel name " << channelName
106 <<
" not found in list of allowed channel names.";
107 LOG(error) <<
"Stop device.";
115 auto timeslice =
fSource->get();
121 const fles::Timeslice& ts = *timeslice;
125 LOG(info) <<
"Found " << ts.num_components()
126 <<
" different components in timeslice";
146 std::chrono::duration<double> run_time =
147 std::chrono::steady_clock::now() -
fTime;
149 LOG(info) <<
"Runtime: " << run_time.count();
150 LOG(info) <<
"No more input data";
155 const fles::MicrosliceDescriptor& mdsc) {
156 LOG(info) <<
"Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id)
158 LOG(info) <<
"Header version: Ox" << std::hex
159 <<
static_cast<int>(mdsc.hdr_ver) << std::dec;
160 LOG(info) <<
"Equipement ID: " << mdsc.eq_id;
161 LOG(info) <<
"Flags: " << mdsc.flags;
162 LOG(info) <<
"Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id)
164 LOG(info) <<
"Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver)
166 LOG(info) <<
"Microslice Idx: " << mdsc.idx;
167 LOG(info) <<
"Checksum: " << mdsc.crc;
168 LOG(info) <<
"Size: " << mdsc.size;
169 LOG(info) <<
"Offset: " << mdsc.offset;
173 if (0 == ts.num_components()) {
174 LOG(error) <<
"No Component in TS " << ts.index();
177 LOG(info) <<
"Found " << ts.num_components()
178 <<
" different components in timeslice";
180 for (
size_t c = 0; c < ts.num_components(); ++c) {
181 LOG(info) <<
"Found " << ts.num_microslices(c)
182 <<
" microslices in component " << c;
183 LOG(info) <<
"Component " << c <<
" has a size of " << ts.size_component(c)
185 LOG(info) <<
"Component " << c <<
" has the system id 0x" << std::hex
186 <<
static_cast<int>(ts.descriptor(c, 0).sys_id) << std::dec;