MIDAS
Loading...
Searching...
No Matches
tmfe_rev0.cxx File Reference
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <sys/time.h>
#include "tmfe_rev0.h"
#include "midas.h"
#include "msystem.h"
#include "mrpc.h"
#include "mstrlcpy.h"
Include dependency graph for tmfe_rev0.cxx:

Go to the source code of this file.

Functions

static int tmfe_rpc_thread (void *param)
 
static int tmfe_periodic_thread (void *param)
 
static INT rpc_callback (INT index, void *prpc_param[])
 
static INT tr_start (INT runno, char *errstr)
 
static INT tr_stop (INT runno, char *errstr)
 
static INT tr_pause (INT runno, char *errstr)
 
static INT tr_resume (INT runno, char *errstr)
 
static INT tr_startabort (INT runno, char *errstr)
 

Function Documentation

◆ rpc_callback()

static INT rpc_callback ( INT  index,
void prpc_param[] 
)
static

Definition at line 389 of file tmfe_rev0.cxx.

390{
391 const char* cmd = CSTRING(0);
392 const char* args = CSTRING(1);
393 char* return_buf = CSTRING(2);
394 int return_max_length = CINT(3);
395
396 cm_msg(MINFO, "rpc_callback", "--------> rpc_callback: index %d, max_length %d, cmd [%s], args [%s]", index, return_max_length, cmd, args);
397
399
400 for (unsigned i=0; i<mfe->fRpcHandlers.size(); i++) {
401 std::string r = mfe->fRpcHandlers[i]->HandleRpc(cmd, args);
402 if (r.length() > 0) {
403 //printf("Handler reply [%s]\n", C(r));
405 return RPC_SUCCESS;
406 }
407 }
408
409 return_buf[0] = 0;
410 return RPC_SUCCESS;
411}
Definition tmfe.h:381
static TMFE * Instance()
Definition tmfe.cxx:57
#define RPC_SUCCESS
Definition midas.h:698
#define MINFO
Definition midas.h:560
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
INT index
Definition mana.cxx:271
INT i
Definition mdump.cxx:32
#define CINT(_i)
Definition midas.h:1622
#define CSTRING(_i)
Definition midas.h:1646
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ tmfe_periodic_thread()

static int tmfe_periodic_thread ( void param)
static

Definition at line 232 of file tmfe_rev0.cxx.

233{
234 fprintf(stderr, "tmfe_periodic_thread: periodic thread started\n");
236 mfe->fPeriodicThreadRunning = true;
237 while (!mfe->fShutdownRequested && !mfe->fPeriodicThreadShutdownRequested) {
238 mfe->EquipmentPeriodicTasks();
239 int status = ss_suspend(1000, 0);
240 if (status == RPC_SHUTDOWN || status == SS_ABORT || status == SS_EXIT) {
241 mfe->fShutdownRequested = true;
242 fprintf(stderr, "tmfe_periodic_thread: ss_susend() status %d, shutdown requested...\n", status);
243 }
244 }
246 fprintf(stderr, "tmfe_periodic_thread: periodic thread stopped\n");
247 mfe->fPeriodicThreadRunning = false;
248 return SUCCESS;
249}
#define SS_ABORT
Definition midas.h:677
#define SS_EXIT
Definition midas.h:678
#define RPC_SHUTDOWN
Definition midas.h:707
#define SUCCESS
Definition mcstd.h:54
INT ss_suspend(INT millisec, INT msg)
Definition system.cxx:4543
INT ss_suspend_exit()
Definition system.cxx:4226
DWORD status
Definition odbhist.cxx:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmfe_rpc_thread()

static int tmfe_rpc_thread ( void param)
static

Definition at line 209 of file tmfe_rev0.cxx.

210{
211 fprintf(stderr, "tmfe_rpc_thread: RPC thread started\n");
212
213 int msec = 1000;
215 mfe->fRpcThreadRunning = true;
217 while (!mfe->fShutdownRequested && !mfe->fRpcThreadShutdownRequested) {
218
219 int status = cm_yield(msec);
220
221 if (status == RPC_SHUTDOWN || status == SS_ABORT) {
222 mfe->fShutdownRequested = true;
223 fprintf(stderr, "tmfe_rpc_thread: cm_yield(%d) status %d, shutdown requested...\n", msec, status);
224 }
225 }
227 fprintf(stderr, "tmfe_rpc_thread: RPC thread stopped\n");
228 mfe->fRpcThreadRunning = false;
229 return SUCCESS;
230}
INT cm_yield(INT millisec)
Definition midas.cxx:5642
INT ss_suspend_set_rpc_thread(midas_thread_t thread_id)
Definition system.cxx:4002
midas_thread_t ss_gettid(void)
Definition system.cxx:1519
Here is the call graph for this function:

◆ tr_pause()

static INT tr_pause ( INT  runno,
char errstr 
)
static

Definition at line 448 of file tmfe_rev0.cxx.

449{
450 cm_msg(MINFO, "tr_pause", "tr_pause");
451
453 for (unsigned i=0; i<mfe->fRpcHandlers.size(); i++) {
454 mfe->fRpcHandlers[i]->HandlePauseRun();
455 }
456
457 return SUCCESS;
458}
Here is the call graph for this function:

◆ tr_resume()

static INT tr_resume ( INT  runno,
char errstr 
)
static

Definition at line 460 of file tmfe_rev0.cxx.

461{
462 cm_msg(MINFO, "tr_resume", "tr_resume");
463
465 for (unsigned i=0; i<mfe->fRpcHandlers.size(); i++) {
466 mfe->fRpcHandlers[i]->HandleResumeRun();
467 }
468
469 return SUCCESS;
470}
Here is the call graph for this function:

◆ tr_start()

static INT tr_start ( INT  runno,
char errstr 
)
static

Definition at line 413 of file tmfe_rev0.cxx.

414{
415 cm_msg(MINFO, "tr_start", "tr_start");
416
418
419 for (unsigned i=0; i<mfe->fEquipments.size(); i++) {
420 mfe->fEquipments[i]->ZeroStatistics();
421 mfe->fEquipments[i]->WriteStatistics();
422 }
423
424 for (unsigned i=0; i<mfe->fRpcHandlers.size(); i++) {
425 mfe->fRpcHandlers[i]->HandleBeginRun();
426 }
427
428 return SUCCESS;
429}
Here is the call graph for this function:

◆ tr_startabort()

static INT tr_startabort ( INT  runno,
char errstr 
)
static

Definition at line 472 of file tmfe_rev0.cxx.

473{
474 cm_msg(MINFO, "tr_startabort", "tr_startabort");
475
477 for (unsigned i=0; i<mfe->fRpcHandlers.size(); i++) {
478 mfe->fRpcHandlers[i]->HandleStartAbortRun();
479 }
480
481 return SUCCESS;
482}
Here is the call graph for this function:

◆ tr_stop()

static INT tr_stop ( INT  runno,
char errstr 
)
static

Definition at line 431 of file tmfe_rev0.cxx.

432{
433 cm_msg(MINFO, "tr_stop", "tr_stop");
434
436 for (unsigned i=0; i<mfe->fRpcHandlers.size(); i++) {
437 mfe->fRpcHandlers[i]->HandleEndRun();
438 }
439
440 for (unsigned i=0; i<mfe->fEquipments.size(); i++) {
441 mfe->fEquipments[i]->WriteStatistics();
442 }
443
444
445 return SUCCESS;
446}
Here is the call graph for this function: