MIDAS
Loading...
Searching...
No Matches
EqBulk Class Reference
Inheritance diagram for EqBulk:
Collaboration diagram for EqBulk:

Public Member Functions

 EqBulk (const char *eqname, const char *eqfilename)
 
 ~EqBulk ()
 
TMFeResult HandleInit (const std::vector< std::string > &args)
 
void SendEvent ()
 
void Thread ()
 
- Public Member Functions inherited from TMFeEquipment
 TMFeEquipment (const char *eqname, const char *eqfilename)
 
virtual ~TMFeEquipment ()
 
TMFeResult EqInit (const std::vector< std::string > &args)
 Initialize equipment.
 
TMFeResult EqPreInit ()
 Initialize equipment, before EquipmentBase::Init()
 
TMFeResult EqPostInit ()
 Initialize equipment, after EquipmentBase::Init()
 
TMFeResult EqReadCommon ()
 Read TMFeEqInfo from ODB /Equipment/NAME/Common.
 
TMFeResult EqWriteCommon (bool create=false)
 Write TMFeEqInfo to ODB /Equipment/NAME/Common.
 
virtual void HandleUsage ()
 
virtual TMFeResult HandleBeginRun (int run_number)
 
virtual TMFeResult HandleEndRun (int run_number)
 
virtual TMFeResult HandlePauseRun (int run_number)
 
virtual TMFeResult HandleResumeRun (int run_number)
 
virtual TMFeResult HandleStartAbortRun (int run_number)
 
virtual TMFeResult HandleRpc (const char *cmd, const char *args, std::string &response)
 
virtual void HandlePeriodic ()
 
virtual bool HandlePoll ()
 
virtual void HandlePollRead ()
 
void EqPollThread ()
 
void EqStartPollThread ()
 
void EqStopPollThread ()
 
TMFeResult ComposeEvent (char *pevent, size_t size) const
 
TMFeResult BkInit (char *pevent, size_t size) const
 
voidBkOpen (char *pevent, const char *bank_name, int bank_type) const
 
TMFeResult BkClose (char *pevent, void *ptr) const
 
int BkSize (const char *pevent) const
 
TMFeResult EqSendEvent (const char *pevent, bool write_to_odb=true)
 
TMFeResult EqSendEvent (const std::vector< char > &event, bool write_to_odb=true)
 
TMFeResult EqSendEvent (const std::vector< std::vector< char > > &event, bool write_to_odb=true)
 
TMFeResult EqSendEvent (int sg_n, const char *sg_ptr[], const size_t sg_len[], bool write_to_odb=true)
 
TMFeResult EqWriteEventToOdb (const char *pevent)
 
TMFeResult EqZeroStatistics ()
 
TMFeResult EqWriteStatistics ()
 
TMFeResult EqSetStatus (const char *status, const char *color)
 
 TMFeEquipment (TMFE *mfe, const char *name, TMFeCommon *common)
 
TMFeError Init ()
 Initialize equipment.
 
TMFeError SendData (const char *data, int size)
 ...
 
TMFeError ComposeEvent (char *pevent, int size)
 
TMFeError BkInit (char *pevent, int size)
 
voidBkOpen (char *pevent, const char *bank_name, int bank_type)
 
TMFeError BkClose (char *pevent, void *ptr)
 
int BkSize (const char *pevent)
 
TMFeError SendEvent (const char *pevent)
 
TMFeError ZeroStatistics ()
 
TMFeError WriteStatistics ()
 
TMFeError SetStatus (const char *status, const char *color)
 
- Public Member Functions inherited from TMFeRpcHandlerInterface
virtual TMFeResult HandleBinaryRpc (const char *cmd, const char *args, std::vector< char > &result)
 
virtual void HandleBeginRun ()
 
virtual void HandleEndRun ()
 
virtual void HandlePauseRun ()
 
virtual void HandleResumeRun ()
 
virtual void HandleStartAbortRun ()
 
virtual std::string HandleRpc (const char *cmd, const char *args)
 

Public Attributes

int fEventSize = 0
 
double fEventSleep = 1.0
 
std::vector< charfEventBuffer
 
std::atomic_bool fThreadRunning {false}
 
std::thread * fThread = NULL
 
- Public Attributes inherited from TMFeEquipment
std::string fEqName
 
std::string fEqFilename
 
bool fEqConfEnableRpc = true
 
bool fEqConfEnablePeriodic = true
 
bool fEqConfEnablePoll = false
 
bool fEqConfReadConfigFromOdb = true
 
bool fEqConfEnabled = true
 
uint16_t fEqConfEventID = 1
 
uint16_t fEqConfTriggerMask = 0
 
std::string fEqConfBuffer = "SYSTEM"
 
int fEqConfType = 0
 
int fEqConfSource = 0
 
std::string fEqConfFormat = "MIDAS"
 
int fEqConfReadOn = 0
 
int fEqConfPeriodMilliSec = 1000
 
double fEqConfEventLimit = 0
 
uint32_t fEqConfNumSubEvents = 0
 
int fEqConfLogHistory = 0
 
bool fEqConfHidden = false
 
int fEqConfWriteCacheSize = 10000000
 
bool fEqConfReadOnlyWhenRunning = true
 
bool fEqConfWriteEventsToOdb = false
 
double fEqConfPeriodStatisticsSec = 1.0
 
double fEqConfPollSleepSec = 0.000100
 
size_t fEqConfMaxEventSize = 0
 
size_t fEqConfBufferSize = 0
 
std::mutex fEqMutex
 
TMFEfMfe = NULL
 
TMFrontendfFe = NULL
 
MVOdbfOdbEq = NULL
 ODB Equipment/EQNAME.
 
MVOdbfOdbEqCommon = NULL
 ODB Equipment/EQNAME/Common.
 
MVOdbfOdbEqSettings = NULL
 ODB Equipment/EQNAME/Settings.
 
MVOdbfOdbEqVariables = NULL
 ODB Equipment/EQNAME/Variables.
 
MVOdbfOdbEqStatistics = NULL
 ODB Equipment/EQNAME/Statistics.
 
TMEventBufferfEqEventBuffer = NULL
 
int fEqSerial = 0
 
double fEqStatEvents = 0
 
double fEqStatBytes = 0
 
double fEqStatEpS = 0
 
double fEqStatKBpS = 0
 
double fEqStatLastTime = 0
 
double fEqStatLastEvents = 0
 
double fEqStatLastBytes = 0
 
double fEqStatLastWrite = 0
 
double fEqStatNextWrite = 0
 
double fEqPeriodicLastCallTime = 0
 
double fEqPeriodicNextCallTime = 0
 
std::atomic_bool fEqPollThreadStarting {false}
 
std::atomic_bool fEqPollThreadRunning {false}
 
std::atomic_bool fEqPollThreadShutdownRequested {false}
 
std::thread * fEqPollThread = NULL
 
std::string fName
 
TMFeCommonfCommon
 
int fBufferHandle
 
int fSerial
 
double fStatEvents
 
double fStatBytes
 
double fStatEpS
 
double fStatKBpS
 
double fStatLastTime
 
double fStatLastEvents
 
double fStatLastBytes
 

Detailed Description

Definition at line 246 of file fetest.cxx.

Constructor & Destructor Documentation

◆ EqBulk()

EqBulk::EqBulk ( const char eqname,
const char eqfilename 
)
inline

Definition at line 259 of file fetest.cxx.

261 {
263 fEqConfEventID = 3;
265 }
uint16_t fEqConfEventID
Definition tmfe.h:171
int fEqConfPeriodMilliSec
Definition tmfe.h:178
TMFeEquipment()
Definition tmfe.h:255
bool fEqConfReadOnlyWhenRunning
Definition tmfe.h:196
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24

◆ ~EqBulk()

EqBulk::~EqBulk ( )
inline

Definition at line 267 of file fetest.cxx.

268 {
269 // wait for thread to finish
270 while (fThreadRunning) {
271 fMfe->Sleep(0.1);
272 }
273
274 if (fThread) {
275 fThread->join();
276 delete fThread;
277 fThread = NULL;
278 }
279 }
std::atomic_bool fThreadRunning
Definition fetest.cxx:255
std::thread * fThread
Definition fetest.cxx:256
static void Sleep(double sleep_time_sec)
sleep, with micro-second precision
Definition tmfe.cxx:1019
TMFE * fMfe
Definition tmfe.h:207
Here is the call graph for this function:

Member Function Documentation

◆ HandleInit()

TMFeResult EqBulk::HandleInit ( const std::vector< std::string > &  args)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 281 of file fetest.cxx.

282 {
283 EqSetStatus("Starting...", "white");
284
287
288 fOdbEqSettings->RI("event_size", &fEventSize, true);
289 fOdbEqSettings->RD("event_sleep_sec", &fEventSleep, true);
290
291 printf("Event size set to %d bytes\n", fEventSize);
292
293 fEventBuffer.resize(16+8+16+fEventSize+100);
294
295 //size = sizeof(test_rb_wait_sleep);
296 //status = db_get_value(hDB, hSet, "rb_wait_sleep", &test_rb_wait_sleep, &size, TID_DWORD, TRUE);
297 //assert(status == DB_SUCCESS);
298 //printf("Ring buffer wait sleep %d ms\n", test_rb_wait_sleep);
299
300 fThread = new std::thread(&EqBulk::Thread, this);
301
302 return TMFeOk();
303 }
std::vector< char > fEventBuffer
Definition fetest.cxx:252
void Thread()
Definition fetest.cxx:319
int fEventSize
Definition fetest.cxx:250
double fEventSleep
Definition fetest.cxx:251
MVOdb * fOdbEqSettings
ODB Equipment/EQNAME/Settings.
Definition tmfe.h:213
TMFeResult EqSetStatus(const char *status, const char *color)
Definition tmfe.cxx:2215
bool fEqConfWriteEventsToOdb
Definition tmfe.h:197
TMFeResult TMFeOk()
Definition tmfe.h:106
Here is the call graph for this function:

◆ SendEvent()

void EqBulk::SendEvent ( )
inline

Definition at line 305 of file fetest.cxx.

306 {
307 char* buf = fEventBuffer.data();
308 size_t bufsize = fEventBuffer.size();
309 ComposeEvent(buf, bufsize);
310 BkInit(buf, bufsize);
311
312 char* ptr = (char*)BkOpen(buf, "bulk", TID_BYTE);
313 ptr += fEventSize;
314 BkClose(buf, ptr);
315
316 EqSendEvent(buf);
317 }
void * BkOpen(char *pevent, const char *bank_name, int bank_type) const
Definition tmfe.cxx:2201
TMFeResult BkInit(char *pevent, size_t size) const
Definition tmfe.cxx:2195
TMFeResult BkClose(char *pevent, void *ptr) const
Definition tmfe.cxx:2208
TMFeResult ComposeEvent(char *pevent, size_t size) const
Definition tmfe.cxx:1995
TMFeResult EqSendEvent(const char *pevent, bool write_to_odb=true)
Definition tmfe.cxx:2006
#define TID_BYTE
Definition midas.h:327
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Thread()

void EqBulk::Thread ( )
inline

Definition at line 319 of file fetest.cxx.

320 {
321 printf("FeBulk::Thread: thread started\n");
322
323 EqSetStatus("Thread running", "#00FF00");
324
325 fThreadRunning = true;
326 while (!fMfe->fShutdownRequested) {
329 SendEvent();
330 } else {
331 fMfe->Sleep(1.0);
332 }
333 }
334
335 printf("FeBulk::Thread: thread finished\n");
336 fThreadRunning = false;
337 }
void SendEvent()
Definition fetest.cxx:305
bool fStateRunning
run state is running or paused
Definition tmfe.h:402
std::atomic_bool fShutdownRequested
shutdown was requested by Ctrl-C or by RPC command
Definition tmfe.h:398
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fEventBuffer

std::vector<char> EqBulk::fEventBuffer

Definition at line 252 of file fetest.cxx.

◆ fEventSize

int EqBulk::fEventSize = 0

Definition at line 250 of file fetest.cxx.

◆ fEventSleep

double EqBulk::fEventSleep = 1.0

Definition at line 251 of file fetest.cxx.

◆ fThread

std::thread* EqBulk::fThread = NULL

Definition at line 256 of file fetest.cxx.

◆ fThreadRunning

std::atomic_bool EqBulk::fThreadRunning {false}

Definition at line 255 of file fetest.cxx.

255{false};

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