10 #include "daq/expreco/ERecoEventSampler.h"
13 #include <sys/types.h>
20 #define RFEVSOUT stdout
25 ERecoEventSampler::ERecoEventSampler(
string conffile)
29 m_conffile = conffile;
30 m_conf =
new RFConf(conffile.c_str());
31 char* nodename = m_conf->getconf(
"eventsampler",
"nodename");
34 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/sampler";
36 mkdir(execdir.c_str(), 0755);
37 chdir(execdir.c_str());
40 char* rbufout = m_conf->getconf(
"eventsampler",
"ringbufout");
41 int rbufsize = m_conf->getconfi(
"eventsampler",
"ringbufoutsize");
48 m_log =
new RFLogManager(nodename, m_conf->getconf(
"system",
"lognode"));
54 ERecoEventSampler::~ERecoEventSampler()
82 printf(
"ERecoEventSampler : Configure done\n");
105 printf(
"ERecoEventSampler : Unconfigure done\n");
112 char* sampler = m_conf->getconf(
"eventsampler",
"script");
113 m_pid_sampler = m_proc->Execute(sampler, (
char*)m_conffile.c_str());
123 printf(
"ERecoEventSampler : Configure done\n");
133 printf(
"ERecoEventSampler: Unconfigure pids = %d %d\n", m_pid_sampler, m_pid_server);
135 if (m_pid_sampler != 0) {
136 kill(m_pid_sampler, SIGINT);
137 waitpid(m_pid_sampler, &status, 0);
152 void 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());