9#include <daq/rfarm/manager/RFRoiSender.h>
24RFRoiSender::RFRoiSender(
string conffile)
27 m_conf =
new RFConf(conffile.c_str());
28 char* nodename = m_conf->getconf(
"roisender",
"nodename");
29 printf(
"RoiSender : nodename = %s\n", nodename);
35 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/roisender";
37 mkdir(execdir.c_str(), 0755);
38 chdir(execdir.c_str());
41 string shmname = string(m_conf->getconf(
"system",
"unitname")) +
":" +
44 printf(
"RoiSender : shmname = %s\n", shmname.c_str());
50 m_log =
new RFLogManager(nodename, m_conf->getconf(
"system",
"lognode"));
53 m_flow =
new RFFlowStat((
char*)shmname.c_str());
61RFRoiSender::~RFRoiSender()
73 char* roisw = m_conf->getconf(
"roisender",
"enabled");
75 roisw = (
char*) nsmm->datap;
76 printf(
"Configure: roisender enable flag is overridden : %s\n", roisw);
78 if (strstr(roisw,
"yes") == 0)
return 0;
81 char* merger = m_conf->getconf(
"roisender",
"merger");
82 char* mergerport = m_conf->getconf(
"roisender",
"mergerport");
83 char* mergerhost = m_conf->getconf(
"roisender",
"mergerhost");
84 char* onsenhost = m_conf->getconf(
"roisender",
"onsenhost");
85 char* onsenport = m_conf->getconf(
"roisender",
"onsenport");
87 string shmname = string(m_conf->getconf(
"system",
"unitname")) +
":" +
88 string(m_conf->getconf(
"roisender",
"nodename"));
91 if (strstr(merger,
"none") == 0) {
93 sprintf(idbuf,
"%2.2d", RF_ROI_ID);
94 m_pid_merger = m_proc->
Execute(merger, (
char*)shmname.c_str(), idbuf, onsenhost, onsenport, mergerport);
99 char* sender = m_conf->getconf(
"roisender",
"sender");
100 int nqueue = m_conf->getconfi(
"roisender",
"nqueues");
104 arglist[0] = mergerhost;
105 arglist[1] = mergerport;
108 for (
int i = 0; i < nqueue; i++) {
109 sprintf(roiqs[i],
"/roi%d", i);
110 arglist[i + 2] = roiqs[i];
114 m_pid_sender = m_proc->
Execute(sender, nargs, arglist);
124 if (m_pid_sender != 0) {
125 kill(m_pid_sender, SIGINT);
126 waitpid(m_pid_sender, &statx, 0);
129 if (m_pid_merger != 0) {
130 kill(m_pid_merger, SIGINT);
131 waitpid(m_pid_merger, &statx, 0);
134 printf(
"UnConfigure : done\n");
151 printf(
"RFRoiSender : Restarted!!!!!\n");
161 RFRoiSender::UnConfigure(nsmmsg, nsmcontext);
163 RFRoiSender::Configure(nsmmsg, nsmcontext);
169void RFRoiSender::server()
172 pid_t pid = m_proc->CheckProcess();
174 printf(
"RFRoiSender : process dead. pid=%d\n", pid);
175 if (pid == m_pid_sender) {
176 m_log->Fatal(
"RFRoiSender : hltout2merger dead. pid = %d\n", pid);
178 }
else if (pid == m_pid_merger) {
179 m_log->Fatal(
"RFRoiSender : merger2merge dead. pid = %d\n", pid);
184 int st = m_proc->CheckOutput();
186 perror(
"RFRoiSender::server");
189 m_log->ProcessLog(m_proc->GetFd());
191 m_flow->fillNodeInfo(RF_ROI_ID, GetNodeInfo(),
true);
195void RFRoiSender::cleanup()
197 printf(
"RFRoiSender : cleaning up\n");
198 UnConfigure(NULL, NULL);
199 printf(
"RFRoiSender: Done. Exitting\n");
int Execute(char *script, int nargs, char **args)
Abstract base class for different kinds of events.