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:
118 TMFE* fMfe = NULL;
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);
129 TMFeResult AddRequest(int event_id, int trigger_mask, const char* sampling_type_string);
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 virtual ~TMFeRpcHandlerInterface() { }; // polymorphic destructor
155};
156
158{
159public: // general configuration, should not be changed by user
160 std::string fEqName;
161 std::string fEqFilename;
162
163public: // equipment configuration stored in ODB Common
164
165 bool fEqConfEnableRpc = true;
167 bool fEqConfEnablePoll = false;
168
169 bool fEqConfReadConfigFromOdb = true; // read equipment common from ODB
170
171 bool fEqConfEnabled = true;
172 uint16_t fEqConfEventID = 1;
173 uint16_t fEqConfTriggerMask = 0;
174 std::string fEqConfBuffer = "SYSTEM";
175 int fEqConfType = 0; // not used
176 int fEqConfSource = 0; // not used
177 std::string fEqConfFormat = "MIDAS"; // TBI
181 uint32_t fEqConfNumSubEvents = 0; // not used
183 bool fEqConfHidden = false;
184#ifdef MIN_WRITE_CACHE_SIZE
186#else
187 int fEqConfWriteCacheSize = 10000000;
188#endif
189 //std::string FrontendHost;
190 //std::string FrontendName;
191 //std::string FrontendFileName;
192 //std::string Status;
193 //std::string StatusColor;
194
195public: // equipment configuration not in ODB Common
196
197 bool fEqConfReadOnlyWhenRunning = true; // RO_RUNNING
198 bool fEqConfWriteEventsToOdb = false; // RO_ODB
199 double fEqConfPeriodStatisticsSec = 1.0; // period for updating ODB statistics
200 double fEqConfPollSleepSec = 0.000100; // shortest sleep for linux is 50-6-70 microseconds
201 size_t fEqConfMaxEventSize = 0; // requested maximum event size
202 size_t fEqConfBufferSize = 0; // requested event buffer size
203
204public: // multithread lock
205 std::mutex fEqMutex;
206
207public: // connection to MIDAS
208 TMFE* fMfe = NULL;
210
211public: // connection to ODB
212 MVOdb* fOdbEq = NULL;
213 MVOdb* fOdbEqCommon = NULL;
214 MVOdb* fOdbEqSettings = NULL;
215 MVOdb* fOdbEqVariables = NULL;
216 MVOdb* fOdbEqStatistics = NULL;
217
218public: // connection to event buffer
219 TMEventBuffer* fEqEventBuffer = NULL; // pointer to buffer entry inside TMFE
220 int fEqSerial = 0;
221
222public: // statistics
223 double fEqStatEvents = 0;
224 double fEqStatBytes = 0;
225 double fEqStatEpS = 0; // events/sec
226 double fEqStatKBpS = 0; // kbytes/sec (factor 1000, not 1024)
227
228 // statistics rate computations
229 double fEqStatLastTime = 0;
232
233 // statistics write to odb timer
236
237public: // periodic scheduler
240
241public: // poll scheduler
242 std::atomic_bool fEqPollThreadStarting{false};
243 std::atomic_bool fEqPollThreadRunning{false};
244 std::atomic_bool fEqPollThreadShutdownRequested{false};
245
246public: // contructors and initialization. not thread-safe.
247 TMFeEquipment(const char* eqname, const char* eqfilename); // ctor
248 virtual ~TMFeEquipment(); // dtor
249 TMFeResult EqInit(const std::vector<std::string>& args);
253 TMFeResult EqWriteCommon(bool create=false);
254
255private: // default ctor is not permitted
256 TMFeEquipment() {}; // ctor
257
258public: // handlers for initialization are called by the main thread
259 virtual TMFeResult HandleInit(const std::vector<std::string>& args) { return TMFeOk(); };
260 virtual void HandleUsage() {};
261
262public: // optional RPC handlers are called by the RPC thread
263 virtual TMFeResult HandleBeginRun(int run_number) { return TMFeOk(); };
264 virtual TMFeResult HandleEndRun(int run_number) { return TMFeOk(); };
265 virtual TMFeResult HandlePauseRun(int run_number) { return TMFeOk(); };
266 virtual TMFeResult HandleResumeRun(int run_number) { return TMFeOk(); };
268 virtual TMFeResult HandleRpc(const char* cmd, const char* args, std::string& response) { return TMFeOk(); };
269 virtual TMFeResult HandleBinaryRpc(const char* cmd, const char* args, std::vector<char>& result) { return TMFeOk(); };
270
271public: // optional periodic equipment handler is called by the periodic thread
272 virtual void HandlePeriodic() {};
273
274public: // optional polled equipment handler is called by the per-equipment poll thread
275 virtual bool HandlePoll() { return false; };
276 virtual void HandlePollRead() {};
277
278public: // per-equipment poll thread
279 std::thread* fEqPollThread = NULL;
280 void EqPollThread();
281 void EqStartPollThread();
282 void EqStopPollThread();
283
284 //public: // optional ODB watch handler runs from the midas poll thread
285 //virtual void HandleOdbWatch(const std::string& odbpath, int odbarrayindex) {};
286
287public: // temporary event composition methods, to bre replaced by the "event object"
288 TMFeResult ComposeEvent(char* pevent, size_t size) const;
289 TMFeResult BkInit(char* pevent, size_t size) const;
290 void* BkOpen(char* pevent, const char* bank_name, int bank_type) const;
291 TMFeResult BkClose(char* pevent, void* ptr) const;
292 int BkSize(const char* pevent) const;
293
294public: // thread-safe methods
295 TMFeResult EqSendEvent(const char* pevent, bool write_to_odb = true);
296 TMFeResult EqSendEvent(const std::vector<char>& event, bool write_to_odb = true);
297 TMFeResult EqSendEvent(const std::vector<std::vector<char>>& event, bool write_to_odb = true);
298 TMFeResult EqSendEvent(int sg_n, const char* sg_ptr[], const size_t sg_len[], bool write_to_odb = true);
299 TMFeResult EqWriteEventToOdb(const char* pevent);
302 TMFeResult EqSetStatus(const char* status, const char* color);
303
304private: // non-thread-safe methods
305 TMFeResult EqWriteEventToOdb_locked(const char* pevent);
306};
307
309{
310public: // configuration
311 TMFE* fMfe = NULL;
313
314public: // configuration
315 int fFeIndex = 0; //< frontend index
316
319
320public: // multithreaded lock
321 std::mutex fFeMutex;
322
323public: // constructor
324 TMFrontend(); // ctor
325 virtual ~TMFrontend(); // dtor
326
327public: // main program, main event loop
328 int FeMain(int argc, char* argv[]);
329 int FeMain(const std::vector<std::string>& args);
330 void FeUsage(const char* argv0);
331
332public: // user provided handlers, see tmfe.md
333 virtual TMFeResult HandleArguments(const std::vector<std::string>& args) { return TMFeOk(); };
334 virtual void HandleUsage() { };
335 virtual TMFeResult HandleFrontendInit(const std::vector<std::string>& args) { return TMFeOk(); };
336 virtual TMFeResult HandleFrontendReady(const std::vector<std::string>& args) { return TMFeOk(); };
337 virtual void HandleFrontendExit() { };
338
339public: // frontend init functions
340 void FeSetName(const char* program_name);
342
343public: // equipment functions
344 // NOTE: fFeEquipments must be protected against multithreaded write access. K.O.
345 std::vector<TMFeEquipment*> fFeEquipments;
346
348
349 TMFeResult FeInitEquipments(const std::vector<std::string>& args);
350 void FeDeleteEquipments();
351
353
354 double FePeriodicTasks(); //< run periodic tasks: equipment periodic handlers, write statistics. returns next time it should be called
355 double FePollTasks(double next_periodic_time); //< run equipment poll. returns requested poll sleep time, value 0 for poll busy loop
356
357public: // main loop
358 TMFeResult FeInit(const std::vector<std::string>& args);
359 void FeMainLoop();
360 void FeShutdown();
361
362public: // scheduler
363 void FePollMidas(double sleep_sec);
364
365public: // periodic thread methods, thread-safe
366 void FePeriodicThread();
369
370public: // periodic thread internal data
371 std::thread* fFePeriodicThread = NULL;
372 std::atomic_bool fFePeriodicThreadStarting{false};
373 std::atomic_bool fFePeriodicThreadRunning{false};
374 std::atomic_bool fFePeriodicThreadShutdownRequested{false};
375
376public: // flush write cache
379
380};
381
382class TMFE
383{
384public: // configuration
385
386 std::string fExptname;
387 std::string fMserverHostname;
388
389 std::string fProgramName;
390 std::string fHostname;
391
392public: // multithreaded lock
393 std::mutex fMutex;
394
395public: // ODB access
396 int fDB = 0;
397 MVOdb* fOdbRoot = NULL;
398
399public: // shutdown
400 std::atomic_bool fShutdownRequested{false};
401
402public: // run state
403 int fRunNumber = 0;
404 bool fStateRunning = false;
405
406public: // internal threads
407 std::thread* fRpcThread = NULL;
408 std::atomic_bool fRpcThreadStarting{false};
409 std::atomic_bool fRpcThreadRunning{false};
410 std::atomic_bool fRpcThreadShutdownRequested{false};
411
412 private:
415 static TMFE* gfMFE;
416
417 TMFE();
418 virtual ~TMFE();
419
420 public:
421
424 static TMFE* Instance();
425
426 static bool gfVerbose;
427
428 TMFeResult Connect(const char* progname = NULL, const char*hostname = NULL, const char*exptname = NULL);
430
431public: // RPC thread methods, thread-safe
432 void RpcThread();
433 void StartRpcThread();
434 void StopRpcThread();
435
436public: // event buffer data
438 std::vector<TMEventBuffer*> fEventBuffers;
439
440public: // event buffer methods, thread-safe
441 TMFeResult EventBufferOpen(TMEventBuffer** pbuf, const char* bufname, size_t bufsize = 0); // factory method
442 TMFeResult EventBufferFlushCacheAll(bool wait = true);
444
445public: // run control
446 bool fRunStopRequested = false;
447 double fRunStartTime = 0;
448
449 void StopRun();
450 void StartRun();
451
452public:
453 TMFeResult SetWatchdogSec(int sec);
454
455 void Yield(double sleep_sec);
456 void MidasPeriodicTasks();
457
458 TMFeResult TriggerAlarm(const char* name, const char* message, const char* aclass);
459 TMFeResult ResetAlarm(const char* name);
460
461 void Msg(int message_type, const char *filename, int line, const char *routine, const char *format, ...) MATTRPRINTF(6,7);
462 //void Msg(int message_type, const char *filename, int line, const char *routine, const char *message); // ambigious with format Msg()
463 void Msg(int message_type, const char *filename, int line, const char *routine, const std::string& message);
464
465public: // run transitions and RPCs
467
470
471 void SetTransitionSequenceStart(int seqno);
472 void SetTransitionSequenceStop(int seqno);
473 void SetTransitionSequencePause(int seqno);
474 void SetTransitionSequenceResume(int seqno);
475 void SetTransitionSequenceStartAbort(int seqno);
483 void RegisterRPCs();
484
485public:
486 static double GetTime();
487 static void Sleep(double sleep_time_sec);
488 static std::string GetThreadId();
489};
490
491#endif
492/* emacs
493 * Local Variables:
494 * tab-width: 8
495 * c-basic-offset: 3
496 * indent-tabs-mode: nil
497 * End:
498 */
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:383
TMFeResult TriggerAlarm(const char *name, const char *message, const char *aclass)
Definition tmfe.cxx:2285
TMFeResult EventBufferCloseAll()
Definition tmfe.cxx:484
bool fRunStopRequested
run stop was requested by equipment
Definition tmfe.h:446
std::thread * fRpcThread
Definition tmfe.h:407
void DeregisterTransitionStartAbort()
Definition tmfe.cxx:1557
std::vector< TMEventBuffer * > fEventBuffers
Definition tmfe.h:438
std::atomic_bool fRpcThreadStarting
Definition tmfe.h:408
static std::string GetThreadId()
return identification of this thread
Definition tmfe.cxx:1140
bool fStateRunning
run state is running or paused
Definition tmfe.h:404
void RegisterRPCs()
Definition tmfe.cxx:1567
void DeregisterTransitionResume()
Definition tmfe.cxx:1552
std::mutex fEventBuffersMutex
Definition tmfe.h:437
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:1583
int fDB
ODB database handle.
Definition tmfe.h:396
virtual ~TMFE()
destructor is private for singleton classes
Definition tmfe.cxx:50
void DeregisterTransitionPause()
Definition tmfe.cxx:1547
void SetTransitionSequenceResume(int seqno)
Definition tmfe.cxx:1518
void RpcThread()
Definition tmfe.cxx:857
double fRunStartTime
start a new run at this time
Definition tmfe.h:447
static bool gfVerbose
Definition tmfe.h:426
std::string fMserverHostname
hostname where the mserver is running, blank if using shared memory
Definition tmfe.h:387
void SetTransitionSequenceStop(int seqno)
Definition tmfe.cxx:1508
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:1542
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:410
void StopRun()
Definition tmfe.cxx:687
void SetTransitionSequenceStartAbort(int seqno)
Definition tmfe.cxx:1523
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:415
void SetTransitionSequencePause(int seqno)
Definition tmfe.cxx:1513
void StartRun()
Definition tmfe.cxx:714
std::atomic_bool fShutdownRequested
shutdown was requested by Ctrl-C or by RPC command
Definition tmfe.h:400
std::atomic_bool fRpcThreadRunning
Definition tmfe.h:409
TMFeResult SetWatchdogSec(int sec)
Definition tmfe.cxx:144
void StopRpcThread()
Definition tmfe.cxx:935
void RegisterTransitionStartAbort()
Definition tmfe.cxx:1562
TMFeResult ResetAlarm(const char *name)
Definition tmfe.cxx:2296
TMFeResult EventBufferFlushCacheAll(bool wait=true)
Definition tmfe.cxx:448
std::string fHostname
hostname we are running on
Definition tmfe.h:390
MVOdb * fOdbRoot
ODB root.
Definition tmfe.h:397
TMFeResult Disconnect()
Definition tmfe.cxx:154
std::vector< TMFeRpcHandlerInterface * > fRpcHandlers
Definition tmfe.h:466
std::string fProgramName
frontend program name
Definition tmfe.h:389
std::mutex fMutex
Definition tmfe.h:393
void DeregisterTransitionStart()
Definition tmfe.cxx:1537
void RemoveRpcHandler(TMFeRpcHandlerInterface *)
Definition tmfe.cxx:1588
void DeregisterTransitions()
Definition tmfe.cxx:1528
int fRunNumber
current run number
Definition tmfe.h:403
void SetTransitionSequenceStart(int seqno)
Definition tmfe.cxx:1503
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:386
bool fEqConfHidden
Definition tmfe.h:183
int fEqConfSource
Definition tmfe.h:176
std::mutex fEqMutex
Definition tmfe.h:205
virtual TMFeResult HandlePauseRun(int run_number)
Definition tmfe.h:265
double fEqStatKBpS
Definition tmfe.h:226
void * BkOpen(char *pevent, const char *bank_name, int bank_type) const
Definition tmfe.cxx:2258
TMFeResult EqWriteEventToOdb_locked(const char *pevent)
Definition tmfe.cxx:2226
TMFeResult BkInit(char *pevent, size_t size) const
Definition tmfe.cxx:2252
uint16_t fEqConfTriggerMask
Definition tmfe.h:173
virtual void HandlePollRead()
Definition tmfe.h:276
MVOdb * fOdbEqSettings
ODB Equipment/EQNAME/Settings.
Definition tmfe.h:214
std::atomic_bool fEqPollThreadShutdownRequested
Definition tmfe.h:244
bool fEqConfEnabled
Definition tmfe.h:171
TMFE * fMfe
Definition tmfe.h:208
int fEqConfReadOn
Definition tmfe.h:178
int fEqConfWriteCacheSize
Definition tmfe.h:187
virtual ~TMFeEquipment()
Definition tmfe.cxx:1724
TMFeResult EqSetStatus(const char *status, const char *color)
Definition tmfe.cxx:2272
double fEqStatLastTime
Definition tmfe.h:229
void EqPollThread()
Definition tmfe.cxx:621
TMFrontend * fFe
Definition tmfe.h:209
bool fEqConfWriteEventsToOdb
Definition tmfe.h:198
virtual bool HandlePoll()
Definition tmfe.h:275
TMFeResult EqWriteCommon(bool create=false)
Write TMFeEqInfo to ODB /Equipment/NAME/Common.
Definition tmfe.cxx:1819
virtual void HandlePeriodic()
Definition tmfe.h:272
uint16_t fEqConfEventID
Definition tmfe.h:172
TMFeResult EqReadCommon()
Read TMFeEqInfo from ODB /Equipment/NAME/Common.
Definition tmfe.cxx:1776
double fEqConfPollSleepSec
Definition tmfe.h:200
TMFeResult EqWriteStatistics()
Definition tmfe.cxx:2007
MVOdb * fOdbEqVariables
ODB Equipment/EQNAME/Variables.
Definition tmfe.h:215
virtual TMFeResult HandleRpc(const char *cmd, const char *args, std::string &response)
Definition tmfe.h:268
virtual TMFeResult HandleStartAbortRun(int run_number)
Definition tmfe.h:267
int fEqConfPeriodMilliSec
Definition tmfe.h:179
double fEqStatLastWrite
Definition tmfe.h:234
TMFeResult EqInit(const std::vector< std::string > &args)
Initialize equipment.
Definition tmfe.cxx:1757
virtual TMFeResult HandleBeginRun(int run_number)
Definition tmfe.h:263
double fEqPeriodicNextCallTime
Definition tmfe.h:239
double fEqConfPeriodStatisticsSec
Definition tmfe.h:199
double fEqStatEpS
Definition tmfe.h:225
virtual void HandleUsage()
Definition tmfe.h:260
TMEventBuffer * fEqEventBuffer
Definition tmfe.h:219
void EqStartPollThread()
Definition tmfe.cxx:648
virtual TMFeResult HandleInit(const std::vector< std::string > &args)
Definition tmfe.h:259
bool fEqConfEnableRpc
Definition tmfe.h:165
TMFeResult EqZeroStatistics()
Definition tmfe.cxx:1982
double fEqStatEvents
Definition tmfe.h:223
std::thread * fEqPollThread
Definition tmfe.h:279
void EqStopPollThread()
Definition tmfe.cxx:665
double fEqStatBytes
Definition tmfe.h:224
std::atomic_bool fEqPollThreadRunning
Definition tmfe.h:243
TMFeResult EqPreInit()
Initialize equipment, before EquipmentBase::Init()
Definition tmfe.cxx:1860
uint32_t fEqConfNumSubEvents
Definition tmfe.h:181
TMFeResult BkClose(char *pevent, void *ptr) const
Definition tmfe.cxx:2265
TMFeEquipment()
Definition tmfe.h:256
std::string fEqConfFormat
Definition tmfe.h:177
int fEqConfLogHistory
Definition tmfe.h:182
virtual TMFeResult HandleBinaryRpc(const char *cmd, const char *args, std::vector< char > &result)
Definition tmfe.h:269
double fEqStatNextWrite
Definition tmfe.h:235
double fEqConfEventLimit
Definition tmfe.h:180
TMFeResult ComposeEvent(char *pevent, size_t size) const
Definition tmfe.cxx:2052
std::string fEqName
Definition tmfe.h:160
size_t fEqConfBufferSize
Definition tmfe.h:202
int fEqSerial
Definition tmfe.h:220
double fEqStatLastEvents
Definition tmfe.h:230
int fEqConfType
Definition tmfe.h:175
virtual TMFeResult HandleResumeRun(int run_number)
Definition tmfe.h:266
MVOdb * fOdbEqCommon
ODB Equipment/EQNAME/Common.
Definition tmfe.h:213
MVOdb * fOdbEq
ODB Equipment/EQNAME.
Definition tmfe.h:212
std::atomic_bool fEqPollThreadStarting
Definition tmfe.h:242
TMFeResult EqSendEvent(const char *pevent, bool write_to_odb=true)
Definition tmfe.cxx:2063
std::string fEqFilename
Definition tmfe.h:161
bool fEqConfReadConfigFromOdb
Definition tmfe.h:169
TMFeResult EqWriteEventToOdb(const char *pevent)
Definition tmfe.cxx:2220
bool fEqConfEnablePoll
Definition tmfe.h:167
int BkSize(const char *pevent) const
Definition tmfe.cxx:2247
std::string fEqConfBuffer
Definition tmfe.h:174
double fEqStatLastBytes
Definition tmfe.h:231
double fEqPeriodicLastCallTime
Definition tmfe.h:238
virtual TMFeResult HandleEndRun(int run_number)
Definition tmfe.h:264
bool fEqConfEnablePeriodic
Definition tmfe.h:166
size_t fEqConfMaxEventSize
Definition tmfe.h:201
MVOdb * fOdbEqStatistics
ODB Equipment/EQNAME/Statistics.
Definition tmfe.h:216
TMFeResult EqPostInit()
Initialize equipment, after EquipmentBase::Init()
Definition tmfe.cxx:1910
bool fEqConfReadOnlyWhenRunning
Definition tmfe.h:197
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
virtual ~TMFeRpcHandlerInterface()
Definition tmfe.h:154
void FeShutdown()
Definition tmfe.cxx:2501
double fFeFlushWriteCacheNextCallTime
Definition tmfe.h:378
bool fFeIfRunningCallBeginRun
Definition tmfe.h:318
std::thread * fFePeriodicThread
Definition tmfe.h:371
std::atomic_bool fFePeriodicThreadRunning
Definition tmfe.h:373
double fFeFlushWriteCachePeriodSec
Definition tmfe.h:377
void FeDeleteEquipments()
Definition tmfe.cxx:1638
void FePollMidas(double sleep_sec)
Definition tmfe.cxx:745
double FePeriodicTasks()
Definition tmfe.cxx:507
TMFE * fMfe
Definition tmfe.h:311
void FePeriodicThread()
Definition tmfe.cxx:883
virtual ~TMFrontend()
Definition tmfe.cxx:1602
int fFeIndex
Definition tmfe.h:315
TMFeResult FeInitEquipments(const std::vector< std::string > &args)
Definition tmfe.cxx:1613
std::mutex fFeMutex
Definition tmfe.h:321
void FeMainLoop()
Definition tmfe.cxx:2494
virtual void HandleFrontendExit()
Definition tmfe.h:337
void FeSetName(const char *program_name)
Definition tmfe.cxx:1704
void FeStopEquipmentPollThreads()
Definition tmfe.cxx:1628
std::vector< TMFeEquipment * > fFeEquipments
Definition tmfe.h:345
void FeUsage(const char *argv0)
Definition tmfe.cxx:2307
TMFeResult FeInit(const std::vector< std::string > &args)
Definition tmfe.cxx:2346
TMFeResult FeAddEquipment(TMFeEquipment *eq)
Definition tmfe.cxx:1657
virtual TMFeResult HandleArguments(const std::vector< std::string > &args)
Definition tmfe.h:333
std::atomic_bool fFePeriodicThreadShutdownRequested
Definition tmfe.h:374
void FeStartPeriodicThread()
Definition tmfe.cxx:919
virtual TMFeResult HandleFrontendInit(const std::vector< std::string > &args)
Definition tmfe.h:335
bool fFeIfRunningCallExit
Definition tmfe.h:317
virtual TMFeResult HandleFrontendReady(const std::vector< std::string > &args)
Definition tmfe.h:336
double FePollTasks(double next_periodic_time)
Definition tmfe.cxx:583
TMFeResult FeRemoveEquipment(TMFeEquipment *eq)
Definition tmfe.cxx:1687
void FeStopPeriodicThread()
Definition tmfe.cxx:963
int FeMain(int argc, char *argv[])
Definition tmfe.cxx:2336
TMFrontendRpcHelper * fFeRpcHelper
Definition tmfe.h:312
std::atomic_bool fFePeriodicThreadStarting
Definition tmfe.h:372
virtual void HandleUsage()
Definition tmfe.h:334
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
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