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");
59 B2INFO(
"Rx: Constructor done.");
63Rbuf2DsModule::~Rbuf2DsModule()
69 gSystem->Load(
"libdataobjects");
84 char* evtbuf =
new char[MAXEVTSIZE];
85 while ((size = m_rbuf->
remq((
int*)evtbuf)) == 0) {
88 if (signalled != 0)
break;
102 B2INFO(
"Rx initialized.");
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.");
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....");
169 B2INFO(
"Rbuf2Ds: DataStore Restored!!");
178 B2INFO(
"Rbuf2Ds: endRun done.");
184 B2INFO(
"Rbuf2Ds: terminate called");
Stream/restore DataStore objects to/from EvtMessage.
int restoreDataStore(EvtMessage *msg)
Restore DataStore objects from EvtMessage.
static Environment & Instance()
Static method to get a reference to the Environment instance.
Class to manage streamed object.
ERecordType type() const
Get record type.
void setDescription(const std::string &description)
Sets the description of the module.
DataStoreStreamer * m_streamer
DataStore streamer.
void initialize() override
Module functions to be called from main process.
void event() override
This method is the core of the module.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
void beginRun() override
Module functions to be called from event process.
int m_nrecv
No. of sent events.
int m_compressionLevel
Compression Level.
std::string m_rbufname
RingBuffer ID.
Rbuf2DsModule()
Constructor / Destructor.
Class to manage a Ring Buffer placed in an IPC shared memory.
int remq(int *buf)
Pick up a buffer from the RingBuffer.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.