MIDAS
Loading...
Searching...
No Matches
tmfe.h
Go to the documentation of this file.
1/********************************************************************\
2
3 Name: tmfe.h
4 Created by: Konstantin Olchanski - TRIUMF
5
6 Contents: C++ MIDAS frontend
7
8\********************************************************************/
9
10#ifndef TMFE_H
11#define TMFE_H
12
13#include <stdint.h>
14#include <string>
15#include <vector>
16#include <mutex> // std::mutex
17#include <thread> // std::thread
18#include <atomic> // std::atomic
19//#include "midas.h"
20#include "mvodb.h"
21
22// from midas.h
23
24#define TID_BYTE 1
25#define TID_UINT8 1
26#define TID_SBYTE 2
27#define TID_INT8 2
28#define TID_CHAR 3
29#define TID_WORD 4
30#define TID_UINT16 4
31#define TID_SHORT 5
32#define TID_INT16 5
33#define TID_DWORD 6
34#define TID_UINT32 6
35#define TID_INT 7
36#define TID_INT32 7
37#define TID_BOOL 8
38#define TID_FLOAT 9
39#define TID_FLOAT32 9
40#define TID_DOUBLE 10
41#define TID_FLOAT64 10
42#define TID_BITFIELD 11
43#define TID_STRING 12
44#define TID_ARRAY 13
45#define TID_STRUCT 14
46#define TID_KEY 15
47#define TID_LINK 16
48#define TID_INT64 17
49#define TID_UINT64 18
50#define TID_QWORD 18
51#define TID_LAST 19
55#define MT_ERROR (1<<0)
56#define MT_INFO (1<<1)
57#define MT_DEBUG (1<<2)
58#define MT_USER (1<<3)
59#define MT_LOG (1<<4)
60#define MT_TALK (1<<5)
61#define MT_CALL (1<<6)
62#define MT_ALL 0xFF
64#define MT_ERROR_STR "ERROR"
65#define MT_INFO_STR "INFO"
66#define MT_DEBUG_STR "DEBUG"
67#define MT_USER_STR "USER"
68#define MT_LOG_STR "LOG"
69#define MT_TALK_STR "TALK"
70#define MT_CALL_STR "CALL"
71
72#define MERROR MT_ERROR, __FILE__, __LINE__
73#define MINFO MT_INFO, __FILE__, __LINE__
74#define MDEBUG MT_DEBUG, __FILE__, __LINE__
75#define MUSER MT_USER, __FILE__, __LINE__
76#define MLOG MT_LOG, __FILE__, __LINE__
77#define MTALK MT_TALK, __FILE__, __LINE__
78#define MCALL MT_CALL, __FILE__, __LINE__
80#if defined __GNUC__
81#define MATTRPRINTF(a, b) __attribute__ ((format (printf, a, b)))
82#else
83#define MATTRPRINTF(a, b)
84#endif
85
87{
88 public:
89 bool error_flag = false;
90 int error_code = 0;
91 std::string error_message = "success";
92
93 public:
94 TMFeResult() { // default ctor for success
95 }
96
97 TMFeResult(int code, const std::string& str) { // ctor
98 error_flag = true;
99 error_code = code;
101 }
102};
103
104// special TMFeResult constructors
105
106inline TMFeResult TMFeOk() { return TMFeResult(); }
107TMFeResult TMFeErrorMessage(const std::string& message);
108TMFeResult TMFeMidasError(const std::string& message, const char* midas_function_name, int midas_status);
109
110class TMFE;
111class TMFrontend;
113class MVOdb;
114
116{
117public:
119 std::string fBufName;
120 size_t fBufSize = 0; // buffer size
121 size_t fBufMaxEventSize = 0; // buffer max event size
122
123public:
124 TMEventBuffer(TMFE* mfe); // ctor
125 ~TMEventBuffer(); // dtor
126 TMFeResult OpenBuffer(const char* bufname, size_t bufsize = 0);
128 TMFeResult SetCacheSize(size_t read_cache_size, size_t write_cache_size);
130 TMFeResult ReceiveEvent(std::vector<char> *e, int timeout_msec = 0); // thread-safe
131 TMFeResult SendEvent(const char *e);
132 TMFeResult SendEvent(const std::vector<char>& e);
133 TMFeResult SendEvent(const std::vector<std::vector<char>>& e);
134 TMFeResult SendEvent(int sg_n, const char* const sg_ptr[], const size_t sg_len[]);
135 TMFeResult FlushCache(bool wait = true);
136
137public: // internal state, user can read but should not write these variables
138 int fBufHandle = 0; // bm_open_buffer() handle
141 std::vector<int> fBufRequests;
142};
143
145{
146 public:
147 virtual TMFeResult HandleBeginRun(int run_number) { return TMFeOk(); };
148 virtual TMFeResult HandleEndRun(int run_number) { return TMFeOk(); };
149 virtual TMFeResult HandlePauseRun(int run_number) { return TMFeOk(); };
150 virtual TMFeResult HandleResumeRun(int run_number) { return TMFeOk(); };
152 virtual TMFeResult HandleRpc(const char* cmd, const char* args, std::string& result) { return TMFeOk(); };
153 virtual TMFeResult HandleBinaryRpc(const char* cmd, const char* args, std::vector<char>& result) { return TMFeOk(); };
154};
155
157{
158public: // general configuration, should not be changed by user
159 std::string fEqName;
160 std::string fEqFilename;
161
162public: // equipment configuration stored in ODB Common
163
164 bool fEqConfEnableRpc = true;
166 bool fEqConfEnablePoll = false;
167
168 bool fEqConfReadConfigFromOdb = true; // read equipment common from ODB
169
170 bool fEqConfEnabled = true;
173 std::string fEqConfBuffer = "SYSTEM";
174 int fEqConfType = 0; // not used
175 int fEqConfSource = 0; // not used
176 std::string fEqConfFormat = "MIDAS"; // TBI
182 bool fEqConfHidden = false;
183#ifdef MIN_WRITE_CACHE_SIZE
185#else
186 int fEqConfWriteCacheSize = 10000000;
187#endif
188 //std::string FrontendHost;
189 //std::string FrontendName;
190 //std::string FrontendFileName;
191 //std::string Status;
192 //std::string StatusColor;
193
194public: // equipment configuration not in ODB Common
195
196 bool fEqConfReadOnlyWhenRunning = true; // RO_RUNNING
197 bool fEqConfWriteEventsToOdb = false; // RO_ODB
198 double fEqConfPeriodStatisticsSec = 1.0; // period for updating ODB statistics
199 double fEqConfPollSleepSec = 0.000100; // shortest sleep for linux is 50-6-70 microseconds
200 size_t fEqConfMaxEventSize = 0; // requested maximum event size
201 size_t fEqConfBufferSize = 0; // requested event buffer size
202
203public: // multithread lock
204 std::mutex fEqMutex;
205
206public: // connection to MIDAS
209
210public: // connection to ODB
216
217public: // connection to event buffer
218 TMEventBuffer* fEqEventBuffer = NULL; // pointer to buffer entry inside TMFE
219 int fEqSerial = 0;
220
221public: // statistics
222 double fEqStatEvents = 0;
223 double fEqStatBytes = 0;
224 double fEqStatEpS = 0; // events/sec
225 double fEqStatKBpS = 0; // kbytes/sec (factor 1000, not 1024)
226
227 // statistics rate computations
228 double fEqStatLastTime = 0;
231
232 // statistics write to odb timer
235
236public: // periodic scheduler
239
240public: // poll scheduler
241 std::atomic_bool fEqPollThreadStarting{false};
242 std::atomic_bool fEqPollThreadRunning{false};
243 std::atomic_bool fEqPollThreadShutdownRequested{false};
244
245public: // contructors and initialization. not thread-safe.
246 TMFeEquipment(const char* eqname, const char* eqfilename); // ctor
247 virtual ~TMFeEquipment(); // dtor
248 TMFeResult EqInit(const std::vector<std::string>& args);
252 TMFeResult EqWriteCommon(bool create=false);
253
254private: // default ctor is not permitted
255 TMFeEquipment() {}; // ctor
256
257public: // handlers for initialization are called by the main thread
258 virtual TMFeResult HandleInit(const std::vector<std::string>& args) { return TMFeOk(); };
259 virtual void HandleUsage() {};
260
261public: // optional RPC handlers are called by the RPC thread
262 virtual TMFeResult HandleBeginRun(int run_number) { return TMFeOk(); };
263 virtual TMFeResult HandleEndRun(int run_number) { return TMFeOk(); };
264 virtual TMFeResult HandlePauseRun(int run_number) { return TMFeOk(); };
265 virtual TMFeResult HandleResumeRun(int run_number) { return TMFeOk(); };
267 virtual TMFeResult HandleRpc(const char* cmd, const char* args, std::string& response) { return TMFeOk(); };
268
269public: // optional periodic equipment handler is called by the periodic thread
270 virtual void HandlePeriodic() {};
271
272public: // optional polled equipment handler is called by the per-equipment poll thread
273 virtual bool HandlePoll() { return false; };
274 virtual void HandlePollRead() {};
275
276public: // per-equipment poll thread
277 std::thread* fEqPollThread = NULL;
278 void EqPollThread();
279 void EqStartPollThread();
280 void EqStopPollThread();
281
282 //public: // optional ODB watch handler runs from the midas poll thread
283 //virtual void HandleOdbWatch(const std::string& odbpath, int odbarrayindex) {};
284
285public: // temporary event composition methods, to bre replaced by the "event object"
286 TMFeResult ComposeEvent(char* pevent, size_t size) const;
287 TMFeResult BkInit(char* pevent, size_t size) const;
288 void* BkOpen(char* pevent, const char* bank_name, int bank_type) const;
289 TMFeResult BkClose(char* pevent, void* ptr) const;
290 int BkSize(const char* pevent) const;
291
292public: // thread-safe methods
293 TMFeResult EqSendEvent(const char* pevent, bool write_to_odb = true);
294 TMFeResult EqSendEvent(const std::vector<char>& event, bool write_to_odb = true);
295 TMFeResult EqSendEvent(const std::vector<std::vector<char>>& event, bool write_to_odb = true);
296 TMFeResult EqSendEvent(int sg_n, const char* sg_ptr[], const size_t sg_len[], bool write_to_odb = true);
297 TMFeResult EqWriteEventToOdb(const char* pevent);
300 TMFeResult EqSetStatus(const char* status, const char* color);
301
302private: // non-thread-safe methods
303 TMFeResult EqWriteEventToOdb_locked(const char* pevent);
304};
305
307{
308public: // configuration
311
312public: // configuration
313 int fFeIndex = 0; //< frontend index
314
317
318public: // multithreaded lock
319 std::mutex fFeMutex;
320
321public: // constructor
322 TMFrontend(); // ctor
323 virtual ~TMFrontend(); // dtor
324
325public: // main program, main event loop
326 int FeMain(int argc, char* argv[]);
327 int FeMain(const std::vector<std::string>& args);
328 void FeUsage(const char* argv0);
329
330public: // user provided handlers, see tmfe.md
331 virtual TMFeResult HandleArguments(const std::vector<std::string>& args) { return TMFeOk(); };
332 virtual void HandleUsage() { };
333 virtual TMFeResult HandleFrontendInit(const std::vector<std::string>& args) { return TMFeOk(); };
334 virtual TMFeResult HandleFrontendReady(const std::vector<std::string>& args) { return TMFeOk(); };
335 virtual void HandleFrontendExit() { };
336
337public: // frontend init functions
338 void FeSetName(const char* program_name);
340
341public: // equipment functions
342 // NOTE: fFeEquipments must be protected against multithreaded write access. K.O.
343 std::vector<TMFeEquipment*> fFeEquipments;
344
346
347 TMFeResult FeInitEquipments(const std::vector<std::string>& args);
348 void FeDeleteEquipments();
349
351
352 double FePeriodicTasks(); //< run periodic tasks: equipment periodic handlers, write statistics. returns next time it should be called
353 double FePollTasks(double next_periodic_time); //< run equipment poll. returns requested poll sleep time, value 0 for poll busy loop
354
355public: // main loop
356 TMFeResult FeInit(const std::vector<std::string>& args);
357 void FeMainLoop();
358 void FeShutdown();
359
360public: // scheduler
361 void FePollMidas(double sleep_sec);
362
363public: // periodic thread methods, thread-safe
364 void FePeriodicThread();
367
368public: // periodic thread internal data
369 std::thread* fFePeriodicThread = NULL;
370 std::atomic_bool fFePeriodicThreadStarting{false};
371 std::atomic_bool fFePeriodicThreadRunning{false};
372 std::atomic_bool fFePeriodicThreadShutdownRequested{false};
373
374public: // flush write cache
377
378};
379
380class TMFE
381{
382public: // configuration
383
384 std::string fExptname;
385 std::string fMserverHostname;
386
387 std::string fProgramName;
388 std::string fHostname;
389
390public: // multithreaded lock
391 std::mutex fMutex;
392
393public: // ODB access
394 int fDB = 0;
396
397public: // shutdown
398 std::atomic_bool fShutdownRequested{false};
399
400public: // run state
401 int fRunNumber = 0;
402 bool fStateRunning = false;
403
404public: // internal threads
405 std::thread* fRpcThread = NULL;
406 std::atomic_bool fRpcThreadStarting{false};
407 std::atomic_bool fRpcThreadRunning{false};
408 std::atomic_bool fRpcThreadShutdownRequested{false};
409
410 private:
413 static TMFE* gfMFE;
414
415 TMFE();
416 virtual ~TMFE();
417
418 public:
419
422 static TMFE* Instance();
423
424 static bool gfVerbose;
425
426 TMFeResult Connect(const char* progname = NULL, const char*hostname = NULL, const char*exptname = NULL);
428
429public: // RPC thread methods, thread-safe
430 void RpcThread();
431 void StartRpcThread();
432 void StopRpcThread();
433
434public: // event buffer data
436 std::vector<TMEventBuffer*> fEventBuffers;
437
438public: // event buffer methods, thread-safe
439 TMFeResult EventBufferOpen(TMEventBuffer** pbuf, const char* bufname, size_t bufsize = 0); // factory method
442
443public: // run control
444 bool fRunStopRequested = false;
445 double fRunStartTime = 0;
446
447 void StopRun();
448 void StartRun();
449
450public:
452
453 void Yield(double sleep_sec);
454 void MidasPeriodicTasks();
455
456 TMFeResult TriggerAlarm(const char* name, const char* message, const char* aclass);
457 TMFeResult ResetAlarm(const char* name);
458
459 void Msg(int message_type, const char *filename, int line, const char *routine, const char *format, ...) MATTRPRINTF(6,7);
460 //void Msg(int message_type, const char *filename, int line, const char *routine, const char *message); // ambigious with format Msg()
461 void Msg(int message_type, const char *filename, int line, const char *routine, const std::string& message);
462
463public: // run transitions and RPCs
465
468
481 void RegisterRPCs();
482
483public:
484 static double GetTime();
485 static void Sleep(double sleep_time_sec);
486 static std::string GetThreadId();
487};
488
489#endif
490/* emacs
491 * Local Variables:
492 * tab-width: 8
493 * c-basic-offset: 3
494 * indent-tabs-mode: nil
495 * End:
496 */
std::vector< int > fBufRequests
Definition tmfe.h:141
std::string fBufName
Definition tmfe.h:119
TMFeResult CloseBuffer()
Definition tmfe.cxx:235
int fBufHandle
Definition tmfe.h:138
size_t fBufReadCacheSize
Definition tmfe.h:139
TMFeResult SetCacheSize(size_t read_cache_size, size_t write_cache_size)
Definition tmfe.cxx:258
TMFeResult OpenBuffer(const char *bufname, size_t bufsize=0)
Definition tmfe.cxx:183
TMFeResult AddRequest(int event_id, int trigger_mask, const char *sampling_type_string)
Definition tmfe.cxx:272
TMFeResult ReceiveEvent(std::vector< char > *e, int timeout_msec=0)
Definition tmfe.cxx:303
TMFE * fMfe
Definition tmfe.h:118
TMFeResult FlushCache(bool wait=true)
Definition tmfe.cxx:374
size_t fBufWriteCacheSize
Definition tmfe.h:140
size_t fBufSize
Definition tmfe.h:120
TMFeResult SendEvent(const char *e)
Definition tmfe.cxx:326
size_t fBufMaxEventSize
Definition tmfe.h:121
Definition tmfe.h:381
TMFeResult TriggerAlarm(const char *name, const char *message, const char *aclass)
Definition tmfe.cxx:2228
TMFeResult EventBufferCloseAll()
Definition tmfe.cxx:484
bool fRunStopRequested
run stop was requested by equipment
Definition tmfe.h:444
std::thread * fRpcThread
Definition tmfe.h:405
void DeregisterTransitionStartAbort()
Definition tmfe.cxx:1502
std::vector< TMEventBuffer * > fEventBuffers
Definition tmfe.h:436
std::atomic_bool fRpcThreadStarting
Definition tmfe.h:406
static std::string GetThreadId()
return identification of this thread
Definition tmfe.cxx:1140
bool fStateRunning
run state is running or paused
Definition tmfe.h:402
void RegisterRPCs()
Definition tmfe.cxx:1512
void DeregisterTransitionResume()
Definition tmfe.cxx:1497
std::mutex fEventBuffersMutex
Definition tmfe.h:435
TMFE()
default constructor is private for singleton classes
Definition tmfe.cxx:44
static double GetTime()
return current time in seconds, with micro-second precision
Definition tmfe.cxx:1011
void MidasPeriodicTasks()
Definition tmfe.cxx:852
void AddRpcHandler(TMFeRpcHandlerInterface *)
Definition tmfe.cxx:1526
int fDB
ODB database handle.
Definition tmfe.h:394
virtual ~TMFE()
destructor is private for singleton classes
Definition tmfe.cxx:50
void DeregisterTransitionPause()
Definition tmfe.cxx:1492
void SetTransitionSequenceResume(int seqno)
Definition tmfe.cxx:1463
void RpcThread()
Definition tmfe.cxx:857
double fRunStartTime
start a new run at this time
Definition tmfe.h:445
static bool gfVerbose
Definition tmfe.h:424
std::string fMserverHostname
hostname where the mserver is running, blank if using shared memory
Definition tmfe.h:385
void SetTransitionSequenceStop(int seqno)
Definition tmfe.cxx:1453
void Yield(double sleep_sec)
Definition tmfe.cxx:821
void Msg(int message_type, const char *filename, int line, const char *routine, const char *format,...) MATTRPRINTF(6
Definition tmfe.cxx:991
void StartRpcThread()
Definition tmfe.cxx:903
void DeregisterTransitionStop()
Definition tmfe.cxx:1487
TMFeResult Connect(const char *progname=NULL, const char *hostname=NULL, const char *exptname=NULL)
Definition tmfe.cxx:65
std::atomic_bool fRpcThreadShutdownRequested
Definition tmfe.h:408
void StopRun()
Definition tmfe.cxx:687
void SetTransitionSequenceStartAbort(int seqno)
Definition tmfe.cxx:1468
static TMFE * Instance()
Definition tmfe.cxx:57
static void Sleep(double sleep_time_sec)
sleep, with micro-second precision
Definition tmfe.cxx:1019
static TMFE * gfMFE
Definition tmfe.h:413
void SetTransitionSequencePause(int seqno)
Definition tmfe.cxx:1458
void StartRun()
Definition tmfe.cxx:714
std::atomic_bool fShutdownRequested
shutdown was requested by Ctrl-C or by RPC command
Definition tmfe.h:398
std::atomic_bool fRpcThreadRunning
Definition tmfe.h:407
TMFeResult SetWatchdogSec(int sec)
Definition tmfe.cxx:144
void StopRpcThread()
Definition tmfe.cxx:935
void RegisterTransitionStartAbort()
Definition tmfe.cxx:1507
TMFeResult ResetAlarm(const char *name)
Definition tmfe.cxx:2239
TMFeResult EventBufferFlushCacheAll(bool wait=true)
Definition tmfe.cxx:448
std::string fHostname
hostname we are running on
Definition tmfe.h:388
MVOdb * fOdbRoot
ODB root.
Definition tmfe.h:395
TMFeResult Disconnect()
Definition tmfe.cxx:154
std::vector< TMFeRpcHandlerInterface * > fRpcHandlers
Definition tmfe.h:464
std::string fProgramName
frontend program name
Definition tmfe.h:387
std::mutex fMutex
Definition tmfe.h:391
void DeregisterTransitionStart()
Definition tmfe.cxx:1482
void RemoveRpcHandler(TMFeRpcHandlerInterface *)
Definition tmfe.cxx:1531
void DeregisterTransitions()
Definition tmfe.cxx:1473
int fRunNumber
current run number
Definition tmfe.h:401
void SetTransitionSequenceStart(int seqno)
Definition tmfe.cxx:1448
TMFeResult EventBufferOpen(TMEventBuffer **pbuf, const char *bufname, size_t bufsize=0)
Definition tmfe.cxx:413
std::string fExptname
experiment name, blank if only one experiment defined in exptab
Definition tmfe.h:384
bool fEqConfHidden
Definition tmfe.h:182
int fEqConfSource
Definition tmfe.h:175
std::mutex fEqMutex
Definition tmfe.h:204
virtual TMFeResult HandlePauseRun(int run_number)
Definition tmfe.h:264
double fEqStatKBpS
Definition tmfe.h:225
void * BkOpen(char *pevent, const char *bank_name, int bank_type) const
Definition tmfe.cxx:2201
TMFeResult EqWriteEventToOdb_locked(const char *pevent)
Definition tmfe.cxx:2169
TMFeResult BkInit(char *pevent, size_t size) const
Definition tmfe.cxx:2195
uint16_t fEqConfTriggerMask
Definition tmfe.h:172
virtual void HandlePollRead()
Definition tmfe.h:274
MVOdb * fOdbEqSettings
ODB Equipment/EQNAME/Settings.
Definition tmfe.h:213
std::atomic_bool fEqPollThreadShutdownRequested
Definition tmfe.h:243
bool fEqConfEnabled
Definition tmfe.h:170
TMFE * fMfe
Definition tmfe.h:207
int fEqConfReadOn
Definition tmfe.h:177
int fEqConfWriteCacheSize
Definition tmfe.h:186
virtual ~TMFeEquipment()
Definition tmfe.cxx:1667
TMFeResult EqSetStatus(const char *status, const char *color)
Definition tmfe.cxx:2215
double fEqStatLastTime
Definition tmfe.h:228
void EqPollThread()
Definition tmfe.cxx:621
TMFrontend * fFe
Definition tmfe.h:208
bool fEqConfWriteEventsToOdb
Definition tmfe.h:197
virtual bool HandlePoll()
Definition tmfe.h:273
TMFeResult EqWriteCommon(bool create=false)
Write TMFeEqInfo to ODB /Equipment/NAME/Common.
Definition tmfe.cxx:1762
virtual void HandlePeriodic()
Definition tmfe.h:270
uint16_t fEqConfEventID
Definition tmfe.h:171
TMFeResult EqReadCommon()
Read TMFeEqInfo from ODB /Equipment/NAME/Common.
Definition tmfe.cxx:1719
double fEqConfPollSleepSec
Definition tmfe.h:199
TMFeResult EqWriteStatistics()
Definition tmfe.cxx:1950
MVOdb * fOdbEqVariables
ODB Equipment/EQNAME/Variables.
Definition tmfe.h:214
virtual TMFeResult HandleRpc(const char *cmd, const char *args, std::string &response)
Definition tmfe.h:267
virtual TMFeResult HandleStartAbortRun(int run_number)
Definition tmfe.h:266
int fEqConfPeriodMilliSec
Definition tmfe.h:178
double fEqStatLastWrite
Definition tmfe.h:233
TMFeResult EqInit(const std::vector< std::string > &args)
Initialize equipment.
Definition tmfe.cxx:1700
virtual TMFeResult HandleBeginRun(int run_number)
Definition tmfe.h:262
double fEqPeriodicNextCallTime
Definition tmfe.h:238
double fEqConfPeriodStatisticsSec
Definition tmfe.h:198
double fEqStatEpS
Definition tmfe.h:224
virtual void HandleUsage()
Definition tmfe.h:259
TMEventBuffer * fEqEventBuffer
Definition tmfe.h:218
void EqStartPollThread()
Definition tmfe.cxx:648
virtual TMFeResult HandleInit(const std::vector< std::string > &args)
Definition tmfe.h:258
bool fEqConfEnableRpc
Definition tmfe.h:164
TMFeResult EqZeroStatistics()
Definition tmfe.cxx:1925
double fEqStatEvents
Definition tmfe.h:222
std::thread * fEqPollThread
Definition tmfe.h:277
void EqStopPollThread()
Definition tmfe.cxx:665
double fEqStatBytes
Definition tmfe.h:223
std::atomic_bool fEqPollThreadRunning
Definition tmfe.h:242
TMFeResult EqPreInit()
Initialize equipment, before EquipmentBase::Init()
Definition tmfe.cxx:1803
uint32_t fEqConfNumSubEvents
Definition tmfe.h:180
TMFeResult BkClose(char *pevent, void *ptr) const
Definition tmfe.cxx:2208
TMFeEquipment()
Definition tmfe.h:255
std::string fEqConfFormat
Definition tmfe.h:176
int fEqConfLogHistory
Definition tmfe.h:181
double fEqStatNextWrite
Definition tmfe.h:234
double fEqConfEventLimit
Definition tmfe.h:179
TMFeResult ComposeEvent(char *pevent, size_t size) const
Definition tmfe.cxx:1995
std::string fEqName
Definition tmfe.h:159
size_t fEqConfBufferSize
Definition tmfe.h:201
int fEqSerial
Definition tmfe.h:219
double fEqStatLastEvents
Definition tmfe.h:229
int fEqConfType
Definition tmfe.h:174
virtual TMFeResult HandleResumeRun(int run_number)
Definition tmfe.h:265
MVOdb * fOdbEqCommon
ODB Equipment/EQNAME/Common.
Definition tmfe.h:212
MVOdb * fOdbEq
ODB Equipment/EQNAME.
Definition tmfe.h:211
std::atomic_bool fEqPollThreadStarting
Definition tmfe.h:241
TMFeResult EqSendEvent(const char *pevent, bool write_to_odb=true)
Definition tmfe.cxx:2006
std::string fEqFilename
Definition tmfe.h:160
bool fEqConfReadConfigFromOdb
Definition tmfe.h:168
TMFeResult EqWriteEventToOdb(const char *pevent)
Definition tmfe.cxx:2163
bool fEqConfEnablePoll
Definition tmfe.h:166
int BkSize(const char *pevent) const
Definition tmfe.cxx:2190
std::string fEqConfBuffer
Definition tmfe.h:173
double fEqStatLastBytes
Definition tmfe.h:230
double fEqPeriodicLastCallTime
Definition tmfe.h:237
virtual TMFeResult HandleEndRun(int run_number)
Definition tmfe.h:263
bool fEqConfEnablePeriodic
Definition tmfe.h:165
size_t fEqConfMaxEventSize
Definition tmfe.h:200
MVOdb * fOdbEqStatistics
ODB Equipment/EQNAME/Statistics.
Definition tmfe.h:215
TMFeResult EqPostInit()
Initialize equipment, after EquipmentBase::Init()
Definition tmfe.cxx:1853
bool fEqConfReadOnlyWhenRunning
Definition tmfe.h:196
bool error_flag
Definition tmfe.h:89
std::string error_message
Definition tmfe.h:91
TMFeResult(int code, const std::string &str)
Definition tmfe.h:97
TMFeResult()
Definition tmfe.h:94
int error_code
Definition tmfe.h:90
virtual TMFeResult HandleEndRun(int run_number)
Definition tmfe.h:148
virtual TMFeResult HandleResumeRun(int run_number)
Definition tmfe.h:150
virtual TMFeResult HandlePauseRun(int run_number)
Definition tmfe.h:149
virtual TMFeResult HandleRpc(const char *cmd, const char *args, std::string &result)
Definition tmfe.h:152
virtual TMFeResult HandleBeginRun(int run_number)
Definition tmfe.h:147
virtual TMFeResult HandleStartAbortRun(int run_number)
Definition tmfe.h:151
virtual TMFeResult HandleBinaryRpc(const char *cmd, const char *args, std::vector< char > &result)
Definition tmfe.h:153
void FeShutdown()
Definition tmfe.cxx:2444
double fFeFlushWriteCacheNextCallTime
Definition tmfe.h:376
bool fFeIfRunningCallBeginRun
Definition tmfe.h:316
std::thread * fFePeriodicThread
Definition tmfe.h:369
std::atomic_bool fFePeriodicThreadRunning
Definition tmfe.h:371
double fFeFlushWriteCachePeriodSec
Definition tmfe.h:375
void FeDeleteEquipments()
Definition tmfe.cxx:1581
void FePollMidas(double sleep_sec)
Definition tmfe.cxx:745
double FePeriodicTasks()
Definition tmfe.cxx:507
TMFE * fMfe
Definition tmfe.h:309
void FePeriodicThread()
Definition tmfe.cxx:883
virtual ~TMFrontend()
Definition tmfe.cxx:1545
int fFeIndex
Definition tmfe.h:313
TMFeResult FeInitEquipments(const std::vector< std::string > &args)
Definition tmfe.cxx:1556
std::mutex fFeMutex
Definition tmfe.h:319
void FeMainLoop()
Definition tmfe.cxx:2437
virtual void HandleFrontendExit()
Definition tmfe.h:335
void FeSetName(const char *program_name)
Definition tmfe.cxx:1647
void FeStopEquipmentPollThreads()
Definition tmfe.cxx:1571
std::vector< TMFeEquipment * > fFeEquipments
Definition tmfe.h:343
void FeUsage(const char *argv0)
Definition tmfe.cxx:2250
TMFeResult FeInit(const std::vector< std::string > &args)
Definition tmfe.cxx:2289
TMFeResult FeAddEquipment(TMFeEquipment *eq)
Definition tmfe.cxx:1600
virtual TMFeResult HandleArguments(const std::vector< std::string > &args)
Definition tmfe.h:331
std::atomic_bool fFePeriodicThreadShutdownRequested
Definition tmfe.h:372
void FeStartPeriodicThread()
Definition tmfe.cxx:919
virtual TMFeResult HandleFrontendInit(const std::vector< std::string > &args)
Definition tmfe.h:333
bool fFeIfRunningCallExit
Definition tmfe.h:315
virtual TMFeResult HandleFrontendReady(const std::vector< std::string > &args)
Definition tmfe.h:334
double FePollTasks(double next_periodic_time)
Definition tmfe.cxx:583
TMFeResult FeRemoveEquipment(TMFeEquipment *eq)
Definition tmfe.cxx:1630
void FeStopPeriodicThread()
Definition tmfe.cxx:963
int FeMain(int argc, char *argv[])
Definition tmfe.cxx:2279
TMFrontendRpcHelper * fFeRpcHelper
Definition tmfe.h:310
std::atomic_bool fFePeriodicThreadStarting
Definition tmfe.h:370
virtual void HandleUsage()
Definition tmfe.h:332
INT run_number[2]
Definition mana.cxx:246
char color[][16]
Definition mchart.cxx:32
BOOL create
Definition mchart.cxx:39
char bank_name[4]
Definition mdump.cxx:26
std::vector< FMT_ID > eq
Definition mdump.cxx:55
char response[10000]
Definition melog.cxx:90
#define MIN_WRITE_CACHE_SIZE
Definition midas.h:257
#define trigger_mask
#define message(type, str)
#define event_id
#define name(x)
Definition midas_macro.h:24
char str[256]
Definition odbhist.cxx:33
DWORD status
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
static double e(void)
Definition tinyexpr.c:136
TMFeResult TMFeErrorMessage(const std::string &message)
Definition tmfe.cxx:29
TMFeResult TMFeOk()
Definition tmfe.h:106
TMFeResult TMFeMidasError(const std::string &message, const char *midas_function_name, int midas_status)
Definition tmfe.cxx:34
#define MATTRPRINTF(a, b)
Definition tmfe_rev0.h:81