9#include <daq/storage/modules/StorageDeserializer.h>
11#include <framework/datastore/StoreObjPtr.h>
12#include <framework/dataobjects/EventMetaData.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/pcore/MsgHandler.h>
17#include <rawdata/dataobjects/RawPXD.h>
43 addParam(
"CompressionLevel", m_compressionLevel,
"Compression level", 0);
44 addParam(
"EB2", m_eb2,
"Over capsuled by eb2", 1);
45 addParam(
"InputBufferName", m_ibuf_name,
"Input buffer name", std::string(
""));
46 addParam(
"InputBufferSize", m_ibuf_size,
"Input buffer size", 100);
47 addParam(
"NodeName", m_nodename,
"Node(subsystem) name", std::string(
""));
48 addParam(
"NodeID", m_nodeid,
"Node(subsystem) ID", 0);
49 addParam(
"UseShmFlag", m_shmflag,
"Use shared memory to communicate with Runcontroller", 0);
53 B2DEBUG(100,
"StorageDeserializer: Constructor done.");
57StorageDeserializerModule::~StorageDeserializerModule()
63 std::cout <<
"StorageDeserializer: initialize() started." << std::endl;
64 if (m_ibuf_name.size() > 0 && m_ibuf_size > 0) {
65 m_ibuf.open(m_ibuf_name, m_ibuf_size * 1000000);
67 B2FATAL(
"Failed to load arguments for shared buffer (" <<
68 m_ibuf_name.c_str() <<
":" << m_ibuf_size <<
")");
71 if (m_nodename.size() == 0 || m_nodeid < 0) {
74 m_info.open(m_nodename, m_nodeid);
77 m_handler =
new MsgHandler(m_compressionLevel);
81 rawpxdarray.registerInDataStore();
82 if (m_info.isAvailable()) {
87 m_package->setSerial(m_ibuf.read((
int*)m_package->getData().getBuffer(),
true,
false));
88 if (m_package->restore()) {
89 if (m_info.isAvailable()) {
90 m_info.setInputNBytes(m_package->getData().getByteSize());
91 m_info.setInputCount(1);
96 if (m_info.isAvailable()) {
99 std::cout <<
"StorageDeserializer: initialize() done." << std::endl;
105 if (m_count == 1)
return;
107 m_package->setSerial(m_ibuf.read((
int*)m_package->getData().getBuffer(),
true,
false));
108 if (m_package->restore()) {
109 if (m_info.isAvailable()) {
110 m_info.addInputNBytes(m_package->getData().getByteSize());
111 m_info.setInputCount(m_count);
118 if (m_expno != evtmetadata->getExperiment() ||
119 m_runno != evtmetadata->getRun()) {
120 if (m_info.isAvailable()) {
121 m_info.setInputNBytes(m_package->getData().getByteSize());
122 m_info.setInputCount(1);
125 m_expno = evtmetadata->getExperiment();
126 m_runno = evtmetadata->getRun();
127 m_evtno = evtmetadata->getEvent();
128 if (m_info.isAvailable()) {
129 m_info.setExpNumber(m_expno);
130 m_info.setRunNumber(m_runno);
133 B2WARNING(
"NO event meta data " << m_package->getData().getExpNumber() <<
"." <<
134 m_package->getData().getRunNumber() <<
"." <<
135 m_package->getData().getEventNumber() <<
" nword = " <<
136 m_package->getData().getWordSize());
137 B2WARNING(
"Last event meta data " << m_expno <<
"." << m_runno <<
"." << m_evtno);
143 std::cout <<
"StorageDeserializer: beginRun called." << std::endl;
148 std::cout <<
"StorageDeserializer: endRun done." << std::endl;
154 std::cout <<
"StorageDeserializer: terminate called" << std::endl;
Stream/restore DataStore objects to/from EvtMessage.
void setDescription(const std::string &description)
Sets the description of the module.
A class to encode/decode an EvtMessage.
DataStoreStreamer * m_streamer
DataStoreStreamer.
void initialize() override
Module functions to be called from main process.
void event() override
This method is the core of the module.
StorageDeserializerModule()
Constructor / Destructor.
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.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
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.