8#include "daq/slc/readout/FlowMonitor.h"
10#include <daq/slc/system/Time.h>
19 if (m_info->isAvailable()) {
20 m_status.nodeid = m_info->getNodeId();
21 m_nbyte[0] = m_nbyte[1] = 0;
22 m_ioinfo[0].setLocalPort(m_info->getInputPort());
23 m_ioinfo[0].setLocalAddress(m_info->getInputAddress());
24 m_ip[0] = m_ioinfo[0].getLocalIP();
25 m_ioinfo[1].setLocalPort(m_info->getOutputPort());
26 m_ioinfo[1].setLocalAddress(m_info->getOutputAddress());
27 m_ip[1] = m_ioinfo[1].getLocalIP();
32bool FlowMonitor::close()
39 if (m_info->isAvailable()) {
40 m_ioinfo[0].setLocalAddress(m_info->getInputAddress());
41 m_ioinfo[0].setLocalPort(m_info->getInputPort());
42 m_ioinfo[1].setLocalAddress(m_info->getOutputAddress());
43 m_ioinfo[1].setLocalPort(m_info->getOutputPort());
44 IOInfo::checkTCP(m_ioinfo);
45 unsigned int ctime =
Time().getSecond();
48 memcpy(&(m_status.header), &(info.header),
sizeof(
event_header));
49 double length = ctime - m_status.ctime;
50 m_status.eflag = info.eflag;
51 m_status.state = info.state;
52 m_status.expno = info.expno;
53 m_status.runno = info.runno;
54 m_status.subno = info.subno;
55 m_status.reserved_i[0] = info.reserved[0];
56 m_status.reserved_i[1] = info.reserved[1];
57 m_status.reserved_f[0] = info.reserved_f[0];
58 m_status.reserved_f[1] = info.reserved_f[1];
59 m_status.reserved_f[2] = info.reserved_f[2];
60 m_status.reserved_f[3] = info.reserved_f[3];
61 m_status.ctime = ctime;
65 m_status.evtrate_in = 0;
66 m_status.evtsize_in = 0;
67 m_status.flowrate_in = 0;
68 m_status.evtrate_out = 0;
69 m_status.evtsize_out = 0;
70 m_status.flowrate_out = 0;
71 if (m_ioinfo[0].getLocalPort() > 0) {
72 m_status.connection_in = m_ioinfo[0].getState() == 1;
73 m_status.nqueue_in = m_ioinfo[0].getRXQueue();
75 if (m_ioinfo[1].getLocalPort() > 0) {
76 m_status.connection_out = m_ioinfo[1].getState() == 1;
77 m_status.nqueue_out = m_ioinfo[1].getRXQueue();
79 if ((dcount = info.io[0].count - m_status.nevent_in) > 0) {
80 dnbyte = info.io[0].nbyte - m_nbyte[0];
81 m_status.evtrate_in = dcount / length / 1000.;
82 m_status.evtsize_in = dnbyte / dcount / 1000.;
83 m_status.flowrate_in = dnbyte / length / 1000000.;
84 m_status.nevent_in = info.io[0].count;
85 m_nbyte[0] = info.io[0].nbyte;
87 m_status.evtrate_in = 0;
88 m_status.evtsize_in = 0;
89 m_status.flowrate_in = 0;
91 if ((dcount = info.io[1].count - m_status.nevent_out) > 0) {
92 dnbyte = info.io[1].nbyte - m_nbyte[1];
93 m_status.evtrate_out = dcount / length / 1000.;
94 m_status.evtsize_out = dnbyte / dcount / 1000.;
95 m_status.flowrate_out = dnbyte / length / 1000000.;
96 m_status.nevent_out = info.io[1].count;
97 m_nbyte[1] = info.io[1].nbyte;
99 m_status.evtrate_out = 0;
100 m_status.evtsize_out = 0;
101 m_status.flowrate_out = 0;
Abstract base class for different kinds of events.