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 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
 
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)
 

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
 
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 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.

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:197
uint16_t fEqConfEventID
Definition tmfe.h:171
int fEqConfPeriodMilliSec
Definition tmfe.h:178
TMFeEquipment()
Definition tmfe.h:255
int fEqConfLogHistory
Definition tmfe.h:181
bool fEqConfEnablePoll
Definition tmfe.h:166
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~EqEverything()

EqEverything::~EqEverything ( )
inline

Definition at line 37 of file tmfe_example_everything.cxx.

38 {
39 printf("EqEverything::dtor!\n");
40 }
Here is the call graph for this function:

Member Function Documentation

◆ HandleBeginRun()

TMFeResult EqEverything::HandleBeginRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 73 of file tmfe_example_everything.cxx.

74 {
75 fMfe->Msg(MINFO, "HandleBeginRun", "Begin run %d!", run_number);
76 EqSetStatus("Running", "#00FF00");
77 return TMFeOk();
78 }
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:207
TMFeResult EqSetStatus(const char *status, const char *color)
Definition tmfe.cxx:2215
#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:

◆ HandleEndRun()

TMFeResult EqEverything::HandleEndRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 80 of file tmfe_example_everything.cxx.

81 {
82 fMfe->Msg(MINFO, "HandleEndRun", "End run %d!", run_number);
83 EqSetStatus("Stopped", "#FFFFFF");
84 return TMFeOk();
85 }
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:1507
bool fEqConfReadOnlyWhenRunning
Definition tmfe.h:196
Here is the call graph for this function:

◆ HandlePauseRun()

TMFeResult EqEverything::HandlePauseRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 87 of file tmfe_example_everything.cxx.

88 {
89 fMfe->Msg(MINFO, "HandlePauseRun", "Pause run %d!", run_number);
90 EqSetStatus("Paused", "#FFFF00");
91 return TMFeOk();
92 }
Here is the call graph for this function:

◆ HandlePeriodic()

void EqEverything::HandlePeriodic ( )
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 121 of file tmfe_example_everything.cxx.

122 {
123 printf("EqEverything::HandlePeriodic!\n");
124 double t = TMFE::GetTime();
125 double data = 100.0*sin(0*M_PI/2.0+M_PI*t/40);
126 SendData(data);
127 char status_buf[256];
128 snprintf(status_buf, sizeof(status_buf), "value %.1f", data);
129 EqSetStatus(status_buf, "#00FF00");
130 }
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 132 of file tmfe_example_everything.cxx.

133 {
134 //printf("EqEverything::HandlePoll!\n");
135
136 if (!fMfe->fStateRunning) // only poll when running
137 return false;
138
139 double r = drand48();
140 if (r > 0.999) {
141 // return successful poll rarely
142 printf("EqEverything::HandlePoll!\n");
143 return true;
144 }
145
146 return false;
147 }
bool fStateRunning
run state is running or paused
Definition tmfe.h:402
Here is the call graph for this function:

◆ HandlePollRead()

void EqEverything::HandlePollRead ( )
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 149 of file tmfe_example_everything.cxx.

150 {
151 printf("EqEverything::HandlePollRead!\n");
152
153 char buf[1024];
154
155 ComposeEvent(buf, sizeof(buf));
156 BkInit(buf, sizeof(buf));
157
158 uint32_t* ptr = (uint32_t*)BkOpen(buf, "poll", TID_UINT32);
159 for (int i=0; i<16; i++) {
160 *ptr++ = lrand48();
161 }
162 BkClose(buf, ptr);
163
164 EqSendEvent(buf, false); // do not write polled data to ODB and history
165 }
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_UINT32
Definition midas.h:337
INT i
Definition mdump.cxx:32
Here is the call graph for this function:

◆ HandleResumeRun()

TMFeResult EqEverything::HandleResumeRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 94 of file tmfe_example_everything.cxx.

95 {
96 fMfe->Msg(MINFO, "HandleResumeRun", "Resume run %d!", run_number);
97 EqSetStatus("Running", "#00FF00");
98 return TMFeOk();
99 }
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 }
char response[10000]
Definition melog.cxx:90
#define ctime
Definition msystem.h:264
Here is the call graph for this function:

◆ HandleStartAbortRun()

TMFeResult EqEverything::HandleStartAbortRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeEquipment.

Definition at line 101 of file tmfe_example_everything.cxx.

102 {
103 fMfe->Msg(MINFO, "HandleStartAbortRun", "Begin run %d aborted!", run_number);
104 EqSetStatus("Stopped", "#FFFFFF");
105 return TMFeOk();
106 }
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 }
Here is the call graph for this function:

◆ SendData()

void EqEverything::SendData ( double  dvalue)
inline

Definition at line 108 of file tmfe_example_everything.cxx.

109 {
110 char buf[1024];
111 ComposeEvent(buf, sizeof(buf));
112 BkInit(buf, sizeof(buf));
113
114 double* ptr = (double*)BkOpen(buf, "data", TID_DOUBLE);
115 *ptr++ = dvalue;
116 BkClose(buf, ptr);
117
118 EqSendEvent(buf);
119 }
#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: