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

Public Member Functions

 EqEverything (const char *eqname, const char *eqfilename)
 
 ~EqEverything ()
 
void HandleUsage ()
 
TMFeResult HandleInit (const std::vector< std::string > &args)
 
TMFeResult HandleRpc (const char *cmd, const char *args, std::string &response)
 
TMFeResult HandleBinaryRpc (const char *cmd, const char *args, std::vector< char > &response)
 
TMFeResult HandleBeginRun (int run_number)
 
TMFeResult HandleEndRun (int run_number)
 
TMFeResult HandlePauseRun (int run_number)
 
TMFeResult HandleResumeRun (int run_number)
 
TMFeResult HandleStartAbortRun (int run_number)
 
void SendData (double dvalue)
 
void HandlePeriodic ()
 
bool HandlePoll ()
 
void HandlePollRead ()
 
- 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.
 
void EqPollThread ()
 
void EqStartPollThread ()
 
void EqStopPollThread ()
 
TMFeResult ComposeEvent (char *pevent, size_t size) const
 
TMFeResult BkInit (char *pevent, size_t size) const
 
void * BkOpen (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)
 
void * BkOpen (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 ~TMFeRpcHandlerInterface ()
 
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)
 

Additional Inherited Members

- 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
 
MVOdb * fOdbEq = NULL
 ODB Equipment/EQNAME.
 
MVOdb * fOdbEqCommon = NULL
 ODB Equipment/EQNAME/Common.
 
MVOdb * fOdbEqSettings = NULL
 ODB Equipment/EQNAME/Settings.
 
MVOdb * fOdbEqVariables = NULL
 ODB Equipment/EQNAME/Variables.
 
MVOdb * fOdbEqStatistics = 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 17 of file tmfe_example_everything.cxx.

Constructor & Destructor Documentation

◆ EqEverything()

EqEverything::EqEverything ( const char *  eqname,
const char *  eqfilename 
)
inline

Definition at line 21 of file tmfe_example_everything.cxx.

22 : TMFeEquipment(eqname, eqfilename)
23 {
24 printf("EqEverything::ctor!\n");
25
26 // configure the equipment here:
27
28 //fEqConfReadConfigFromOdb = false;
33 fEqConfEnablePoll = true; // enable polled equipment
34 //fEqConfPollSleepSec = 0; // to create a "100% CPU busy" polling loop, set poll sleep time to zero
35 }
bool fEqConfWriteEventsToOdb
Definition tmfe.h:198
uint16_t fEqConfEventID
Definition tmfe.h:172
int fEqConfPeriodMilliSec
Definition tmfe.h:179
TMFeEquipment()
Definition tmfe.h:256
int fEqConfLogHistory
Definition tmfe.h:182
bool fEqConfEnablePoll
Definition tmfe.h:167

◆ ~EqEverything()

EqEverything::~EqEverything ( )
inline

Definition at line 37 of file tmfe_example_everything.cxx.

38 {
39 printf("EqEverything::dtor!\n");
40 }

Member Function Documentation

◆ HandleBeginRun()

TMFeResult EqEverything::HandleBeginRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 92 of file tmfe_example_everything.cxx.

93 {
94 fMfe->Msg(MINFO, "HandleBeginRun", "Begin run %d!", run_number);
95 EqSetStatus("Running", "#00FF00");
96 return TMFeOk();
97 }
void Msg(int message_type, const char *filename, int line, const char *routine, const char *format,...) MATTRPRINTF(6
Definition tmfe.cxx:991
TMFE * fMfe
Definition tmfe.h:208
TMFeResult EqSetStatus(const char *status, const char *color)
Definition tmfe.cxx:2272
#define MINFO
Definition midas.h:560
INT run_number[2]
Definition mana.cxx:246
TMFeResult TMFeOk()
Definition tmfe.h:106
Here is the call graph for this function:

◆ HandleBinaryRpc()

TMFeResult EqEverything::HandleBinaryRpc ( const char *  cmd,
const char *  args,
std::vector< char > &  response 
)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 73 of file tmfe_example_everything.cxx.

74 {
75 fMfe->Msg(MINFO, "HandleBinaryRpc", "Binary RPC cmd [%s], args [%s]", cmd, args);
76
77 // RPC handler
78
79 response.resize(8*64);
80
81 uint64_t* p64 = (uint64_t*)response.data();
82 uint64_t one = 1;
83
84 for (size_t i=0; i<response.size()/sizeof(p64[0]); i++) {
85 *p64++ = (one<<i);
86 }
87
88 return TMFeOk();
89 }
INT i
Definition mdump.cxx:32
char response[10000]
Definition melog.cxx:90
Here is the call graph for this function:

◆ HandleEndRun()

TMFeResult EqEverything::HandleEndRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 99 of file tmfe_example_everything.cxx.

100 {
101 fMfe->Msg(MINFO, "HandleEndRun", "End run %d!", run_number);
102 EqSetStatus("Stopped", "#FFFFFF");
103 return TMFeOk();
104 }
Here is the call graph for this function:

◆ HandleInit()

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

Reimplemented from TMFeEquipment.

Definition at line 47 of file tmfe_example_everything.cxx.

48 {
49 printf("EqEverything::HandleInit!\n");
51 fEqConfReadOnlyWhenRunning = false; // overwrite ODB Common RO_RUNNING to false
52 fEqConfWriteEventsToOdb = true; // overwrite ODB Common RO_ODB to true
53 EqSetStatus("Started...", "white");
54 //EqStartPollThread();
55 return TMFeOk();
56 }
void RegisterTransitionStartAbort()
Definition tmfe.cxx:1562
bool fEqConfReadOnlyWhenRunning
Definition tmfe.h:197
Here is the call graph for this function:

◆ HandlePauseRun()

TMFeResult EqEverything::HandlePauseRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 106 of file tmfe_example_everything.cxx.

107 {
108 fMfe->Msg(MINFO, "HandlePauseRun", "Pause run %d!", run_number);
109 EqSetStatus("Paused", "#FFFF00");
110 return TMFeOk();
111 }
Here is the call graph for this function:

◆ HandlePeriodic()

void EqEverything::HandlePeriodic ( )
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 140 of file tmfe_example_everything.cxx.

141 {
142 printf("EqEverything::HandlePeriodic!\n");
143 double t = TMFE::GetTime();
144 double data = 100.0*sin(0*M_PI/2.0+M_PI*t/40);
145 SendData(data);
146 char status_buf[256];
147 snprintf(status_buf, sizeof(status_buf), "value %.1f", data);
148 EqSetStatus(status_buf, "#00FF00");
149 }
void SendData(double dvalue)
static double GetTime()
return current time in seconds, with micro-second precision
Definition tmfe.cxx:1011
void * data
Definition mana.cxx:268
Here is the call graph for this function:

◆ HandlePoll()

bool EqEverything::HandlePoll ( )
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 151 of file tmfe_example_everything.cxx.

152 {
153 //printf("EqEverything::HandlePoll!\n");
154
155 if (!fMfe->fStateRunning) // only poll when running
156 return false;
157
158 double r = drand48();
159 if (r > 0.999) {
160 // return successful poll rarely
161 printf("EqEverything::HandlePoll!\n");
162 return true;
163 }
164
165 return false;
166 }
bool fStateRunning
run state is running or paused
Definition tmfe.h:404

◆ HandlePollRead()

void EqEverything::HandlePollRead ( )
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 168 of file tmfe_example_everything.cxx.

169 {
170 printf("EqEverything::HandlePollRead!\n");
171
172 char buf[1024];
173
174 ComposeEvent(buf, sizeof(buf));
175 BkInit(buf, sizeof(buf));
176
177 uint32_t* ptr = (uint32_t*)BkOpen(buf, "poll", TID_UINT32);
178 for (int i=0; i<16; i++) {
179 *ptr++ = lrand48();
180 }
181 BkClose(buf, ptr);
182
183 EqSendEvent(buf, false); // do not write polled data to ODB and history
184 }
void * BkOpen(char *pevent, const char *bank_name, int bank_type) const
Definition tmfe.cxx:2258
TMFeResult BkInit(char *pevent, size_t size) const
Definition tmfe.cxx:2252
TMFeResult BkClose(char *pevent, void *ptr) const
Definition tmfe.cxx:2265
TMFeResult ComposeEvent(char *pevent, size_t size) const
Definition tmfe.cxx:2052
TMFeResult EqSendEvent(const char *pevent, bool write_to_odb=true)
Definition tmfe.cxx:2063
#define TID_UINT32
Definition midas.h:337
Here is the call graph for this function:

◆ HandleResumeRun()

TMFeResult EqEverything::HandleResumeRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 113 of file tmfe_example_everything.cxx.

114 {
115 fMfe->Msg(MINFO, "HandleResumeRun", "Resume run %d!", run_number);
116 EqSetStatus("Running", "#00FF00");
117 return TMFeOk();
118 }
Here is the call graph for this function:

◆ HandleRpc()

TMFeResult EqEverything::HandleRpc ( const char *  cmd,
const char *  args,
std::string &  response 
)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 58 of file tmfe_example_everything.cxx.

59 {
60 fMfe->Msg(MINFO, "HandleRpc", "RPC cmd [%s], args [%s]", cmd, args);
61
62 // RPC handler
63
64 char tmp[256];
65 time_t now = time(NULL);
66 snprintf(tmp, sizeof(tmp), "{ \"current_time\" : [ %d, \"%s\"] }", (int)now, ctime(&now));
67
68 response = tmp;
69
70 return TMFeOk();
71 }
#define ctime
Definition msystem.h:271
Here is the call graph for this function:

◆ HandleStartAbortRun()

TMFeResult EqEverything::HandleStartAbortRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 120 of file tmfe_example_everything.cxx.

121 {
122 fMfe->Msg(MINFO, "HandleStartAbortRun", "Begin run %d aborted!", run_number);
123 EqSetStatus("Stopped", "#FFFFFF");
124 return TMFeOk();
125 }
Here is the call graph for this function:

◆ HandleUsage()

void EqEverything::HandleUsage ( )
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 42 of file tmfe_example_everything.cxx.

43 {
44 printf("EqEverything::HandleUsage!\n");
45 }

◆ SendData()

void EqEverything::SendData ( double  dvalue)
inline

Definition at line 127 of file tmfe_example_everything.cxx.

128 {
129 char buf[1024];
130 ComposeEvent(buf, sizeof(buf));
131 BkInit(buf, sizeof(buf));
132
133 double* ptr = (double*)BkOpen(buf, "data", TID_DOUBLE);
134 *ptr++ = dvalue;
135 BkClose(buf, ptr);
136
137 EqSendEvent(buf);
138 }
#define TID_DOUBLE
Definition midas.h:343
Here is the call graph for this function:
Here is the caller graph for this function:

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