17#include "TimesliceInputArchive.hpp"
18#include "TimesliceSubscriber.hpp"
20#include "FairMQLogger.h"
21#include "FairMQProgOptions.h"
25#include <boost/archive/binary_oarchive.hpp>
37 using std::runtime_error::runtime_error;
59 fFileName = fConfig->GetValue<
string>(
"filename");
60 fHost = fConfig->GetValue<
string>(
"flib-host");
61 fPort = fConfig->GetValue<uint64_t>(
"flib-port");
66 LOG(info) <<
"Host: " <<
fHost;
67 LOG(info) <<
"Port: " <<
fPort;
79 int noChannel = fChannels.size();
80 LOG(info) <<
"Number of defined output channels: " << noChannel;
81 for (
auto const& entry : fChannels) {
82 LOG(info) <<
"Channel name: " << entry.first;
87 std::string connector =
"tcp://" +
fHost +
":" + std::to_string(
fPort);
88 LOG(info) <<
"Open TSPublisher at " << connector;
89 fSource =
new fles::TimesliceSubscriber(connector, 1);
93 LOG(info) <<
"Open the Flib input file " <<
fFileName;
95 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
96 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
101 fTime = std::chrono::steady_clock::now();
104 LOG(error) << e.what();
112 LOG(info) <<
"Channel name " << channelName <<
" found in list of allowed channel names.";
116 LOG(info) <<
"Channel name " << channelName <<
" not found in list of allowed channel names.";
117 LOG(error) <<
"Stop device.";
126 auto timeslice =
fSource->get();
132 const fles::Timeslice& ts = *timeslice;
136 LOG(info) <<
"Found " << ts.num_components() <<
" different components in timeslice";
157 std::chrono::duration<double> run_time = std::chrono::steady_clock::now() -
fTime;
159 LOG(info) <<
"Runtime: " << run_time.count();
160 LOG(info) <<
"No more input data";
166 LOG(info) <<
"Header ID: Ox" << std::hex << static_cast<int>(mdsc.hdr_id) << std::dec;
167 LOG(info) <<
"Header version: Ox" << std::hex << static_cast<int>(mdsc.hdr_ver) << std::dec;
168 LOG(info) <<
"Equipement ID: " << mdsc.eq_id;
169 LOG(info) <<
"Flags: " << mdsc.flags;
170 LOG(info) <<
"Sys ID: Ox" << std::hex << static_cast<int>(mdsc.sys_id) << std::dec;
171 LOG(info) <<
"Sys version: Ox" << std::hex << static_cast<int>(mdsc.sys_ver) << std::dec;
172 LOG(info) <<
"Microslice Idx: " << mdsc.idx;
173 LOG(info) <<
"Checksum: " << mdsc.crc;
174 LOG(info) <<
"Size: " << mdsc.size;
175 LOG(info) <<
"Offset: " << mdsc.offset;
180 if (0 == ts.num_components()) {
181 LOG(error) <<
"No Component in TS " << ts.index();
184 LOG(info) <<
"Found " << ts.num_components() <<
" different components in timeslice";
186 for (
size_t c = 0; c < ts.num_components(); ++c) {
187 LOG(info) <<
"Found " << ts.num_microslices(c) <<
" microslices in component " << c;
188 LOG(info) <<
"Component " << c <<
" has a size of " << ts.size_component(c) <<
" bytes";
189 LOG(info) <<
"Component " << c <<
" has the system id 0x" << std::hex
190 <<
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)
bool CheckTimeslice(const fles::Timeslice &ts)
fles::TimesliceSource * fSource
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor &mdsc)
void ChangeState(FairMQDevice *device, cbm::mq::Transition transition)