9 #include <daq/rfarm/event/modules/Rbuf2DsModule.h>
14 #include "framework/core/Environment.h"
21 static int signalled = 0;
22 static void signalHandler(
int sig)
25 printf(
"Rbuf2Ds : Signal received\n");
45 setDescription(
"Encode DataStore into RingBuffer");
48 addParam(
"RingBufferName", m_rbufname,
"Name of RingBuffer",
50 addParam(
"CompressionLevel", m_compressionLevel,
"Compression level",
55 m_compressionLevel = 0;
59 B2INFO(
"Rx: Constructor done.");
63 Rbuf2DsModule::~Rbuf2DsModule()
67 void Rbuf2DsModule::initialize()
69 gSystem->Load(
"libdataobjects");
84 char* evtbuf =
new char[MAXEVTSIZE];
85 while ((size = m_rbuf->remq((
int*)evtbuf)) == 0) {
88 if (signalled != 0)
break;
94 m_streamer->restoreDataStore(evtmsg);
102 B2INFO(
"Rx initialized.");
106 void Rbuf2DsModule::beginRun()
108 if (Environment::Instance().getNumberProcesses() != 0) {
110 memset(&s,
'\0',
sizeof(s));
111 s.sa_handler = signalHandler;
112 sigemptyset(&s.sa_mask);
113 if (sigaction(SIGINT, &s, NULL) != 0) {
114 B2FATAL(
"Rbuf2Ds: Error to connect signal handler");
116 printf(
"Ds2Rbuf : Signal Handler installed.\n");
118 B2INFO(
"beginRun called.");
122 void Rbuf2DsModule::event()
126 if (m_nrecv == 0)
return;
131 char* evtbuf =
new char[MAXEVTSIZE];
132 while ((size = m_rbuf->remq((
int*)evtbuf)) == 0) {
134 if (signalled != 0)
break;
139 B2INFO(
"Rbuf2Ds: got an event from RingBuffer, size=" << size <<
140 " (proc= " << (
int)getpid() <<
")");
144 if (msg->
type() == MSG_TERMINATE) {
145 B2INFO(
"Rx: got termination message. Exitting....");
153 m_streamer->restoreDataStore(msg);
169 B2INFO(
"Rbuf2Ds: DataStore Restored!!");
174 void Rbuf2DsModule::endRun()
178 B2INFO(
"Rbuf2Ds: endRun done.");
182 void Rbuf2DsModule::terminate()
184 B2INFO(
"Rbuf2Ds: terminate called");
Stream/restore DataStore objects to/from EvtMessage.
Class to manage streamed object.
ERecordType type() const
Get record type.
A class definition of an input module for Sequential ROOT I/O.
Class to manage a Ring Buffer placed in an IPC shared memory.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.