9#include <framework/logging/Logger.h>
11#include <daq/storage/SharedEventBuffer.h>
13#include <daq/slc/base/IOException.h>
14#include <daq/slc/readout/RunInfoBuffer.h>
16#include <daq/slc/system/TCPServerSocket.h>
17#include <daq/slc/system/TCPSocketWriter.h>
18#include <daq/slc/system/LogFile.h>
24int main(
int argc,
char** argv)
27 LogFile::debug(
"usage: %s bufname bufsize "
28 "port [nodename, nodeid]", argv[0]);
32 bool use_info = (argc > 5);
34 info.open(argv[4], atoi(argv[5]));
37 ibuf.open(argv[1], atoi(argv[2]) * 1000000);
38 int* evtbuf =
new int[10000000];
40 const int port = atoi(argv[3]);
45 B2ERROR(
"Failed to open server socket 0.0.0.0:" << port);
49 unsigned int count_in = 0;
50 unsigned int count_out = 0;
51 unsigned int expno = 0;
52 unsigned int runno = 0;
53 unsigned int subno = 0;
55 if (use_info) info.setOutputPort(0);
58 LogFile::info(
"Connected from expreco.");
59 if (use_info) info.setOutputPort(port);
62 long long nbyte = (ibuf.read(evtbuf,
false,
false, &hdr)) *
sizeof(
int);
63 if (expno < hdr.expno || runno < hdr.runno) {
67 info.setExpNumber(expno);
68 info.setRunNumber(runno);
69 info.setSubNumber(subno);
70 info.setInputCount(0);
71 info.setInputNBytes(0);
72 info.setOutputCount(0);
73 info.setOutputNBytes(0);
74 count_in = count_out = 0;
79 info.addInputCount(1);
80 info.addInputNBytes(nbyte);
82 unsigned long long nbyte_out = 0;
84 unsigned int nByte = htonl(evtbuf[0]);
85 nbyte_out = writer.write(&nByte,
sizeof(
int));
86 nbyte_out += writer.write(evtbuf, evtbuf[0]);
89 LogFile::warning(
"Lost connection to expreco %s", e.what());
93 LogFile::warning(
"Connection to expreco broken.");
94 if (use_info) info.setInputPort(0);
95 info.reportError(RunInfoBuffer::SOCKET_OUT);
100 info.addOutputCount(1);
101 info.addOutputNBytes(nbyte_out);
106 }
catch (
const std::exception& e) {
107 B2ERROR(
"Unknown error: " << e.what());
Abstract base class for different kinds of events.