9#include "daq/expreco/ERecoEventSampler.h"
19#define RFEVSOUT stdout
24ERecoEventSampler::ERecoEventSampler(
string conffile)
28 m_conffile = conffile;
29 m_conf =
new RFConf(conffile.c_str());
30 char* nodename = m_conf->getconf(
"eventsampler",
"nodename");
33 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/sampler";
35 mkdir(execdir.c_str(), 0755);
36 chdir(execdir.c_str());
39 char* rbufout = m_conf->getconf(
"eventsampler",
"ringbufout");
40 int rbufsize = m_conf->getconfi(
"eventsampler",
"ringbufoutsize");
47 m_log =
new RFLogManager(nodename, m_conf->getconf(
"system",
"lognode"));
53ERecoEventSampler::~ERecoEventSampler()
81 printf(
"ERecoEventSampler : Configure done\n");
104 printf(
"ERecoEventSampler : Unconfigure done\n");
111 char* sampler = m_conf->getconf(
"eventsampler",
"script");
112 m_pid_sampler = m_proc->
Execute(sampler, (
char*)m_conffile.c_str());
122 printf(
"ERecoEventSampler : Configure done\n");
132 printf(
"ERecoEventSampler: Unconfigure pids = %d %d\n", m_pid_sampler, m_pid_server);
134 if (m_pid_sampler != 0) {
135 kill(m_pid_sampler, SIGINT);
136 waitpid(m_pid_sampler, &status, 0);
152void ERecoEventSampler::server()
155 pid_t pid = m_proc->CheckProcess();
157 if (pid == m_pid_sampler)
158 printf(
"ERecoEventSampler : eventsampler process dead. pid = %d\n", pid);
160 printf(
"ERecoEventSampler : unknown process dead. pid = %d\n", pid);
163 int st = m_proc->CheckOutput();
165 perror(
"ERecoEventSampler::server");
168 m_log->ProcessLog(m_proc->GetFd());
int Execute(char *script, int nargs, char **args)
Class to manage a Ring Buffer placed in an IPC shared memory.
Abstract base class for different kinds of events.