13#include <framework/logging/Logger.h>
15#include <daq/storage/BinData.h>
16#include <daq/storage/SharedEventBuffer.h>
18#include <daq/slc/base/IOException.h>
19#include <daq/slc/readout/RunInfoBuffer.h>
21#include <daq/slc/system/TCPSocket.h>
22#include <daq/slc/system/TCPSocketReader.h>
23#include <daq/slc/system/Time.h>
24#include <daq/slc/system/LogFile.h>
28int main(
int argc,
char** argv)
31 LogFile::debug(
"%s : bufname bufsize hostname port "
32 "[nodename, nodeid]", argv[0]);
37 bool use_info = (argc > 6);
39 info.open(argv[5], atoi(argv[6]));
42 ibuf.open(argv[1], atoi(argv[2]) * 1000000);
46 int* evtbuf =
new int[10000000];
48 data.setBuffer(evtbuf);
55 while (socket.get_fd() <= 0) {
58 B2INFO(
"Connected to data source");
59 socket.setBufferSize(32 * 1024 * 1024);
61 if (info.isAvailable()) {
62 info.setInputPort(socket.getLocalPort());
63 info.setInputAddress(socket.getLocalAddress());
68 if (info.isAvailable()) {
70 info.setInputAddress(0);
73 B2WARNING(
"failed to connect to eb2 (try=" << ntried++ <<
")");
80 B2INFO(
"storagein: Cconnected to eb2.");
83 reader.read(data.getBuffer(),
sizeof(
int));
84 unsigned int nbyte = data.getByteSize() -
sizeof(int);
85 int nword = data.getWordSize();
86 reader.read((data.getBuffer() + 1), nbyte);
88 if (info.isAvailable()) {
89 info.addInputCount(1);
90 info.addInputNBytes(nbyte);
92 if (expno > data.getExpNumber() || runno > data.getRunNumber()) {
100 }
else if (expno < data.getExpNumber() || runno < data.getRunNumber()) {
101 expno = data.getExpNumber();
102 runno = data.getRunNumber();
103 B2INFO(
"new run detected : exp=" << expno <<
" runno=" << runno);
105 iheader->expno = expno;
106 iheader->runno = runno;
107 iheader->subno = subno;
108 if (info.isAvailable()) {
109 info.setExpNumber(expno);
110 info.setRunNumber(runno);
111 info.setSubNumber(subno);
112 info.setInputCount(0);
113 info.setInputNBytes(0);
114 info.setOutputCount(0);
115 info.setOutputNBytes(0);
119 if (count < 1000000 && (count < 10 ||
120 (count > 10 && count < 100 && count % 10 == 0) ||
121 (count > 100 && count < 1000 && count % 100 == 0) ||
122 (count > 1000 && count < 10000 && count % 1000 == 0) ||
123 (count > 10000 && count < 100000 && count % 10000 == 0) ||
124 (count > 100000 && count % 100000 == 0))) {
125 std::cout <<
"[DEBUG] Event count = " << count <<
" nword = " << nword << std::endl;
128 ibuf.write(data.getBuffer(), nword,
true);
129 if (info.isAvailable()) {
130 info.addOutputCount(1);
131 info.addOutputNBytes(nword *
sizeof(
int));
136 if (info.isAvailable()) info.setInputPort(0);
137 B2WARNING(
"Connection to eb2 broken.");
Abstract base class for different kinds of events.