Belle II Software development
ERecoEventSampler Class Reference
Inheritance diagram for ERecoEventSampler:
RFServerBase

Public Member Functions

 ERecoEventSampler (std::string conffile)
 
int Configure (NSMmsg *, NSMcontext *) override
 
int UnConfigure (NSMmsg *, NSMcontext *) override
 
int Start (NSMmsg *, NSMcontext *) override
 
int Stop (NSMmsg *, NSMcontext *) override
 
int Restart (NSMmsg *, NSMcontext *) override
 
void server ()
 
virtual int Pause (NSMmsg *, NSMcontext *)
 
virtual int Resume (NSMmsg *, NSMcontext *)
 
virtual int Status (NSMmsg *, NSMcontext *)
 
virtual void SetNodeInfo (RfNodeInfo *ptr)
 
virtual RfNodeInfoGetNodeInfo ()
 

Static Public Attributes

static RFServerBases_instance
 

Private Attributes

RFConfm_conf
 
std::string m_conffile
 
RFProcessManagerm_proc
 
RFLogManagerm_log
 
RingBufferm_rbufout
 
int m_pid_sampler
 
int m_pid_server
 
RfNodeInfom_nsmmem
 

Detailed Description

Definition at line 29 of file ERecoEventSampler.h.

Constructor & Destructor Documentation

◆ ERecoEventSampler()

ERecoEventSampler ( std::string  conffile)

Definition at line 24 of file ERecoEventSampler.cc.

25{
26
27 // 0. Initialize configuration manager
28 m_conffile = conffile;
29 m_conf = new RFConf(conffile.c_str());
30 char* nodename = m_conf->getconf("eventsampler", "nodename");
31
32 // 1. Set execution directory
33 string execdir = string(m_conf->getconf("system", "execdir_base")) + "/sampler";
34
35 mkdir(execdir.c_str(), 0755);
36 chdir(execdir.c_str());
37
38 // 2. Initialize RingBuffers
39 char* rbufout = m_conf->getconf("eventsampler", "ringbufout");
40 int rbufsize = m_conf->getconfi("eventsampler", "ringbufoutsize");
41 m_rbufout = new RingBuffer(rbufout, rbufsize);
42
43 // 3. Initialize process manager
44 m_proc = new RFProcessManager(nodename);
45
46 // 4. Initialize LogManager
47 m_log = new RFLogManager(nodename, m_conf->getconf("system", "lognode"));
48
49 m_pid_sampler = 0;
50
51}
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition: RingBuffer.h:39

◆ ~ERecoEventSampler()

Definition at line 53 of file ERecoEventSampler.cc.

54{
55 delete m_log;
56 delete m_proc;
57 delete m_conf;
58 delete m_rbufout;
59}

Member Function Documentation

◆ Configure()

int Configure ( NSMmsg ,
NSMcontext  
)
overridevirtual

Reimplemented from RFServerBase.

Definition at line 64 of file ERecoEventSampler.cc.

65{
66
67 /*
68 // 1. Run EventSampler
69 char* sampler = m_conf->getconf("eventsampler", "script");
70 m_pid_sampler = m_proc->Execute(sampler, (char*)m_conffile.c_str());
71 */
72
73 /* Public event server moved outside
74 // 2. Run EventServer
75 char* server = m_conf->getconf("eventsampler", "server", "script");
76 char* rbuf = m_conf->getconf("eventsampler", "ringbufout");
77 char* port = m_conf->getconf("eventsampler", "server", "port");
78 m_pid_server = m_proc->Execute(server, rbuf, port);
79 */
80
81 printf("ERecoEventSampler : Configure done\n");
82 return 0;
83}

◆ GetNodeInfo()

virtual RfNodeInfo * GetNodeInfo ( )
inlinevirtualinherited

Definition at line 38 of file RFServerBase.h.

39 {
40 return m_nsmmem;
41 };

◆ Pause()

virtual int Pause ( NSMmsg ,
NSMcontext  
)
inlinevirtualinherited

Definition at line 28 of file RFServerBase.h.

28{ return 0; };

◆ Restart()

int Restart ( NSMmsg ,
NSMcontext  
)
overridevirtual

Reimplemented from RFServerBase.

Definition at line 145 of file ERecoEventSampler.cc.

146{
147 return 0;
148}

◆ Resume()

virtual int Resume ( NSMmsg ,
NSMcontext  
)
inlinevirtualinherited

Definition at line 29 of file RFServerBase.h.

29{ return 0; };

◆ server()

void server ( )

Definition at line 152 of file ERecoEventSampler.cc.

153{
154 while (true) {
155 pid_t pid = m_proc->CheckProcess();
156 if (pid > 0) {
157 if (pid == m_pid_sampler)
158 printf("ERecoEventSampler : eventsampler process dead. pid = %d\n", pid);
159 else
160 printf("ERecoEventSampler : unknown process dead. pid = %d\n", pid);
161 }
162
163 int st = m_proc->CheckOutput();
164 if (st < 0) {
165 perror("ERecoEventSampler::server");
166 // exit ( -1 );
167 } else if (st > 0) {
168 m_log->ProcessLog(m_proc->GetFd());
169 }
170 }
171}

◆ SetNodeInfo()

virtual void SetNodeInfo ( RfNodeInfo ptr)
inlinevirtualinherited

Definition at line 33 of file RFServerBase.h.

34 {
35 m_nsmmem = ptr;
36 };

◆ Start()

int Start ( NSMmsg ,
NSMcontext  
)
overridevirtual

Reimplemented from RFServerBase.

Definition at line 108 of file ERecoEventSampler.cc.

109{
110 // 1. Run EventSampler
111 char* sampler = m_conf->getconf("eventsampler", "script");
112 m_pid_sampler = m_proc->Execute(sampler, (char*)m_conffile.c_str());
113
114 /* Public event server moved outside
115 // 2. Run EventServer
116 char* server = m_conf->getconf("eventsampler", "server", "script");
117 char* rbuf = m_conf->getconf("eventsampler", "ringbufout");
118 char* port = m_conf->getconf("eventsampler", "server", "port");
119 m_pid_server = m_proc->Execute(server, rbuf, port);
120 */
121
122 printf("ERecoEventSampler : Configure done\n");
123
124
125 // m_rbufin->clear();
126 return 0;
127}
int Execute(char *script, int nargs, char **args)

◆ Status()

virtual int Status ( NSMmsg ,
NSMcontext  
)
inlinevirtualinherited

Definition at line 31 of file RFServerBase.h.

31{ return 0; };

◆ Stop()

int Stop ( NSMmsg ,
NSMcontext  
)
overridevirtual

Reimplemented from RFServerBase.

Definition at line 129 of file ERecoEventSampler.cc.

130{
131 int status;
132 printf("ERecoEventSampler: Unconfigure pids = %d %d\n", m_pid_sampler, m_pid_server);
133 fflush(stdout);
134 if (m_pid_sampler != 0) {
135 kill(m_pid_sampler, SIGINT);
136 waitpid(m_pid_sampler, &status, 0);
137 m_pid_sampler = 0;
138 }
139
140// m_rbufin->clear();
141 return 0;
142}

◆ UnConfigure()

int UnConfigure ( NSMmsg ,
NSMcontext  
)
overridevirtual

Reimplemented from RFServerBase.

Definition at line 85 of file ERecoEventSampler.cc.

86{
87 /*
88 int status;
89 printf("ERecoEventSampler: Unconfigure pids = %d %d\n", m_pid_sampler, m_pid_server);
90 fflush(stdout);
91 if (m_pid_sampler != 0) {
92 kill(m_pid_sampler, SIGINT);
93 waitpid(m_pid_sampler, &status, 0);
94 m_pid_sampler = 0;
95 }
96 */
97 /*
98 if (m_pid_server != 0) {
99 kill(m_pid_server, SIGINT);
100 waitpid(m_pid_server, &status, 0);
101 m_pid_server = 0;
102 }
103 */
104 printf("ERecoEventSampler : Unconfigure done\n");
105 return 0;
106}

Member Data Documentation

◆ m_conf

RFConf* m_conf
private

Definition at line 45 of file ERecoEventSampler.h.

◆ m_conffile

std::string m_conffile
private

Definition at line 46 of file ERecoEventSampler.h.

◆ m_log

RFLogManager* m_log
private

Definition at line 48 of file ERecoEventSampler.h.

◆ m_nsmmem

RfNodeInfo* m_nsmmem
privateinherited

Definition at line 47 of file RFServerBase.h.

◆ m_pid_sampler

int m_pid_sampler
private

Definition at line 51 of file ERecoEventSampler.h.

◆ m_pid_server

int m_pid_server
private

Definition at line 52 of file ERecoEventSampler.h.

◆ m_proc

RFProcessManager* m_proc
private

Definition at line 47 of file ERecoEventSampler.h.

◆ m_rbufout

RingBuffer* m_rbufout
private

Definition at line 49 of file ERecoEventSampler.h.

◆ s_instance

RFServerBase* s_instance
staticinherited

Definition at line 44 of file RFServerBase.h.


The documentation for this class was generated from the following files: