MIDAS
Loading...
Searching...
No Matches
tmfe_example_indexed.cxx
Go to the documentation of this file.
1/*******************************************************************\
2
3 Name: tmfe_example_indexed.cxx
4 Created by: K.Olchanski
5
6 Contents: Example of indexed equipment
7
8\********************************************************************/
9
10#undef NDEBUG // midas required assert() to be always enabled
11
12#include <stdio.h>
13#include <math.h> // M_PI
14
15#include "tmfe.h"
16
17class EqPeriodic :
18 public TMFeEquipment
19{
20public:
21 EqPeriodic(const char* eqname, const char* eqfilename) // ctor
23 {
24 /* configure your equipment here */
25
28 fEqConfBuffer = "BUF%02d";
29 fEqConfPeriodMilliSec = 1000; // in milliseconds
32 }
33
35 {
36 char buf[1024];
37
38 ComposeEvent(buf, sizeof(buf));
39 BkInit(buf, sizeof(buf));
40
41 /* create SCLR bank */
42 uint32_t* pdata = (uint32_t*)BkOpen(buf, "PRDC", TID_UINT32);
43
44 /* following code "simulates" some values in sine wave form */
45 for (int a = 0; a < 16; a++)
46 *pdata++ = 100*sin(M_PI*time(NULL)/60+a/2.0)+100;
47
48 BkClose(buf, pdata);
49
50 EqSendEvent(buf);
51 }
52};
53
54class FeExample: public TMFrontend
55{
56public:
57 FeExample() // ctor
58 {
59 /* register with the framework */
60 FeSetName("example_%02d");
61 FeAddEquipment(new EqPeriodic("example_%02d", __FILE__));
62 }
63};
64
65int main(int argc, char* argv[])
66{
68 return fe_example.FeMain(argc, argv);
69}
70
71/* emacs
72 * Local Variables:
73 * tab-width: 8
74 * c-basic-offset: 3
75 * indent-tabs-mode: nil
76 * End:
77 */
EqPeriodic(const char *eqname, const char *eqfilename)
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
bool fEqConfWriteEventsToOdb
Definition tmfe.h:197
uint16_t fEqConfEventID
Definition tmfe.h:171
int fEqConfPeriodMilliSec
Definition tmfe.h:178
TMFeResult BkClose(char *pevent, void *ptr) const
Definition tmfe.cxx:2208
int fEqConfLogHistory
Definition tmfe.h:181
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
bool fEqConfReadConfigFromOdb
Definition tmfe.h:168
std::string fEqConfBuffer
Definition tmfe.h:173
void FeSetName(const char *program_name)
Definition tmfe.cxx:1647
TMFeResult FeAddEquipment(TMFeEquipment *eq)
Definition tmfe.cxx:1600
int FeMain(int argc, char *argv[])
Definition tmfe.cxx:2279
#define TID_UINT32
Definition midas.h:337
int main()
Definition hwtest.cxx:23
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24