9#include <daq/storage/modules/PartialSeqRootReader.h>
29 m_buf =
new char[1024 * 1024 * 100];
32 addParam(
"FilePath", m_path,
"File path ", std::string(
""));
33 addParam(
"FileNoMin", m_filemin,
"Minimum filenumber ", 0);
34 addParam(
"FileNoMax", m_filemax,
"Maximum filenumber ", -1);
37 B2INFO(
"PartialSeqRootReader: Constructor done.");
41PartialSeqRootReaderModule::~PartialSeqRootReaderModule()
47int PartialSeqRootReaderModule::openFile(
int fileno)
49 if (m_fd > 0) close(m_fd);
50 if (fileno > m_filemax)
return -1;
53 sprintf(filename,
"%s-%d", m_path.c_str(), fileno);
54 }
else if (fileno == 0) {
55 sprintf(filename,
"%s", m_path.c_str());
57 int fd = ::open(filename, O_RDONLY);
59 B2ERROR(
"file open error (" << strerror(errno) <<
"): " << filename);
62 std::cout <<
"SeqFile: " << filename <<
" opened (fd=" << m_fd <<
")" << std::endl;
63 B2INFO(
"SeqFile: " << filename <<
" opened (fd=" << m_fd <<
")");
67int PartialSeqRootReaderModule::readFile()
69 int ret = ::read(m_fd, m_buf,
sizeof(
int));
72 }
else if (ret == 0) {
73 m_fd = openFile(m_fileno++);
74 if (m_fd <= 0)
return -1;
75 ret = ::read(m_fd, m_buf,
sizeof(
int));
77 int size = *(
int*)m_buf;
78 ret = ::read(m_fd, (
char*)(m_buf +
sizeof(
int)), size -
sizeof(
int));
87 B2INFO(
"PartialSeqRootReader: initialize() started.");
92 if (readFile() < 0)
return;
95 if (evtmsg->
type() == MSG_STREAMERINFO) {
96 B2INFO(
"Reading StreamerInfo");
104 m_fd = openFile(m_fileno++);
109 if (readFile() < 0)
return;
112 if (evtmsg->
type() == MSG_STREAMERINFO) {
113 B2INFO(
"Reading StreamerInfo");
121 B2INFO(
"PartialSeqRootReader: initialize() done.");
127 if (readFile() < 0)
return;
130 if (evtmsg->
type() == MSG_STREAMERINFO) {
131 B2INFO(
"Reading StreamerInfo");
142 B2INFO(
"PartialSeqRootReader: beginRun called.");
147 B2INFO(
"PartialSeqRootReader: endRun done.");
153 B2INFO(
"PartialSeqRootReader: terminate called");
Stream/restore DataStore objects to/from EvtMessage.
int restoreDataStore(EvtMessage *msg)
Restore DataStore objects from EvtMessage.
Class to manage streamed object.
ERecordType type() const
Get record type.
void setDescription(const std::string &description)
Sets the description of the module.
PartialSeqRootReaderModule()
Constructor / Destructor.
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.
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.