MIDAS
Loading...
Searching...
No Matches
fetest_tmfe_thread.cxx File Reference
#include <stdio.h>
#include <signal.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include "midas.h"
#include "tmfe.h"
Include dependency graph for fetest_tmfe_thread.cxx:

Go to the source code of this file.

Classes

class  Myfe
 

Functions

static void usage ()
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 99 of file fetest_tmfe_thread.cxx.

100{
101 setbuf(stdout, NULL);
102 setbuf(stderr, NULL);
103
104 signal(SIGPIPE, SIG_IGN);
105
106 std::string name = "";
107
108 if (argc == 2) {
109 name = argv[1];
110 } else {
111 usage(); // DOES NOT RETURN
112 }
113
114 TMFE* mfe = TMFE::Instance();
115
116 TMFeError err = mfe->Connect("fetest_tmfe_thread", __FILE__);
117 if (err.error) {
118 printf("Cannot connect, bye.\n");
119 return 1;
120 }
121
122 //mfe->SetWatchdogSec(0);
123
124 TMFeCommon *common = new TMFeCommon();
125 common->EventID = 1;
126 common->LogHistory = 1;
127 //common->Buffer = "SYSTEM";
128
129 TMFeEquipment* eq = new TMFeEquipment(mfe, "tmfe", common);
130 eq->Init();
131 eq->SetStatus("Starting...", "white");
132 eq->ZeroStatistics();
133 eq->WriteStatistics();
134
135 mfe->RegisterEquipment(eq);
136
137 Myfe* myfe = new Myfe(mfe, eq);
138
139 mfe->RegisterRpcHandler(myfe);
140
141 //mfe->SetTransitionSequenceStart(910);
142 //mfe->SetTransitionSequenceStop(90);
143 //mfe->DeregisterTransitionPause();
144 //mfe->DeregisterTransitionResume();
145
146 myfe->Init();
147
148 mfe->RegisterPeriodicHandler(eq, myfe);
149
150 printf("Main thread is %s\n", TMFE::GetThreadId().c_str());
151
152 mfe->StartRpcThread();
153 mfe->StartPeriodicThread();
154
155 eq->SetStatus("Started...", "white");
156
157 while (!mfe->fShutdownRequested) {
158 ::sleep(1);
159 }
160
161 mfe->Disconnect();
162
163 return 0;
164}
void Init()
Definition tmfe.h:381
void RegisterRpcHandler(TMFeRpcHandlerInterface *handler)
RPC handlers are executed from the RPC thread, if started.
static std::string GetThreadId()
return identification of this thread
Definition tmfe.cxx:1140
void StartPeriodicThread()
void StartRpcThread()
Definition tmfe.cxx:903
TMFeResult Connect(const char *progname=NULL, const char *hostname=NULL, const char *exptname=NULL)
Definition tmfe.cxx:65
static TMFE * Instance()
Definition tmfe.cxx:57
std::atomic_bool fShutdownRequested
shutdown was requested by Ctrl-C or by RPC command
Definition tmfe.h:398
void RegisterPeriodicHandler(TMFeEquipment *eq, TMFePeriodicHandlerInterface *handler)
periodic handlers are executed from the periodic thread, if started
TMFeResult Disconnect()
Definition tmfe.cxx:154
TMFeError RegisterEquipment(TMFeEquipment *eq)
uint16_t EventID
Definition tmfe_rev0.h:105
int LogHistory
Definition tmfe_rev0.h:116
int error
Definition tmfe_rev0.h:87
static void usage()
std::vector< FMT_ID > eq
Definition mdump.cxx:55
#define sleep(ms)
#define name(x)
Definition midas_macro.h:24
Here is the call graph for this function:

◆ usage()

static void usage ( )
static

Definition at line 93 of file fetest_tmfe_thread.cxx.

94{
95 fprintf(stderr, "Usage: fetest_tmfe_thread ...\n");
96 exit(1);
97}
Here is the caller graph for this function: