MIDAS
Loading...
Searching...
No Matches
frontend.cxx File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include "midas.h"
#include "experim.h"
#include "mfe.h"
Include dependency graph for frontend.cxx:

Go to the source code of this file.

Functions

INT read_trigger_event (char *pevent, INT off)
 
INT read_periodic_event (char *pevent, INT off)
 
INT poll_trigger_event (INT source, INT count, BOOL test)
 
INT frontend_init ()
 Frontend initialization.
 

Variables

const charfrontend_name = "Sample Frontend"
 
const charfrontend_file_name = __FILE__
 
BOOL equipment_common_overwrite = TRUE
 
EQUIPMENT equipment []
 

Function Documentation

◆ frontend_init()

INT frontend_init ( void  )

Frontend initialization.

Runs once at application startup. We initialize the hardware and optical interfaces and set the equipment status in ODB. We also lock the frontend to once physical cpu core.

Returns
Midas status code

Definition at line 128 of file frontend.cxx.

129{
130 /* install polling routine */
132
133 /* set cache size */
134 set_cache_size("SYSTEM", 10000000);
135
136 /* put any hardware initialization here */
137
138 /* print message and return FE_ERR_HW if frontend should not be started */
139 return SUCCESS;
140}
INT poll_trigger_event(INT source, INT count, BOOL test)
Definition frontend.cxx:152
#define SUCCESS
Definition mcstd.h:54
INT set_cache_size(std::string buffer, int size)
Definition mfed.cxx:74
void install_poll_event(INT(*f)(INT, INT, BOOL))
Definition mfed.cxx:55
Here is the call graph for this function:

◆ poll_trigger_event()

INT poll_trigger_event ( INT  source,
INT  count,
BOOL  test 
)

Definition at line 152 of file frontend.cxx.

156{
157 int i;
158 DWORD flag;
159
160 for (i = 0; i < count; i++) {
161 /* poll hardware and set flag to TRUE if new event is available */
162 flag = TRUE;
163
164 if (flag)
165 if (!test)
166 return TRUE;
167 }
168
169 return 0;
170}
unsigned int DWORD
Definition mcstd.h:51
double count
Definition mdump.cxx:33
INT i
Definition mdump.cxx:32
#define TRUE
Definition midas.h:182
program test
Definition miniana.f:6
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:
Here is the caller graph for this function:

◆ read_periodic_event()

INT read_periodic_event ( char pevent,
INT  off 
)

Definition at line 211 of file frontend.cxx.

212{
213 UINT32 *pdata;
214
215 /* init bank structure */
216 bk_init(pevent);
217
218 /* create a bank called PRDC */
219 bk_create(pevent, "PRDC", TID_UINT32, (void **)&pdata);
220
221 /* following code "simulates" some values in sine wave form */
222 for (int i = 0; i < 16; i++)
223 *pdata++ = 100*sin(M_PI*time(NULL)/60+i/2.0)+100;
224
225 bk_close(pevent, pdata);
226
227 return bk_size(pevent);
228}
INT bk_close(void *event, void *pdata)
Definition midas.cxx:16788
void bk_init(void *event)
Definition midas.cxx:16414
void bk_create(void *event, const char *name, WORD type, void **pdata)
Definition midas.cxx:16569
INT bk_size(const void *event)
Definition midas.cxx:16503
#define TID_UINT32
Definition midas.h:337
unsigned int UINT32
Definition midas.h:140
Here is the call graph for this function:

◆ read_trigger_event()

INT read_trigger_event ( char pevent,
INT  off 
)

Definition at line 176 of file frontend.cxx.

177{
178 UINT32 *pdata;
179
180 /* init bank structure */
181 bk_init(pevent);
182
183 /* create a bank called ADC0 */
184 bk_create(pevent, "ADC0", TID_UINT32, (void **)&pdata);
185
186 /* following code "simulates" some ADC data */
187 for (int i = 0; i < 4; i++)
188 *pdata++ = rand()%1024 + rand()%1024 + rand()%1024 + rand()%1024;
189
190 bk_close(pevent, pdata);
191
192 /* create another bank called TDC0 */
193 bk_create(pevent, "TDC0", TID_UINT32, (void **)&pdata);
194
195 /* following code "simulates" some TDC data */
196 for (int i = 0; i < 4; i++)
197 *pdata++ = rand()%1024 + rand()%1024 + rand()%1024 + rand()%1024;
198
199 bk_close(pevent, pdata);
200
201 /* limit event rate to 100 Hz. In a real experiment remove this line */
202 ss_sleep(10);
203
204 return bk_size(pevent);
205}
INT ss_sleep(INT millisec)
Definition system.cxx:3628
Here is the call graph for this function:

Variable Documentation

◆ equipment

EQUIPMENT equipment[]

Definition at line 52 of file frontend.cxx.

52 {
53
54 {"Trigger", /* equipment name */
55 {1, 0, /* event ID, trigger mask */
56 "SYSTEM", /* event buffer */
57 EQ_POLLED, /* equipment type */
58 0, /* event source */
59 "MIDAS", /* format */
60 TRUE, /* enabled */
61 RO_RUNNING | /* read only when running */
62 RO_ODB, /* and update ODB */
63 100, /* poll for 100ms */
64 0, /* stop run after this event limit */
65 0, /* number of sub events */
66 0, /* don't log history */
67 "", "", "", "", "", 0},
68 read_trigger_event, /* readout routine */
69 },
70
71 {"Periodic", /* equipment name */
72 {2, 0, /* event ID, trigger mask */
73 "SYSTEM", /* event buffer */
74 EQ_PERIODIC, /* equipment type */
75 0, /* event source */
76 "MIDAS", /* format */
77 TRUE, /* enabled */
78 RO_RUNNING | RO_TRANSITIONS | /* read when running and on transitions */
79 RO_ODB, /* and update ODB */
80 1000, /* read every 1000 msec (1 sec) */
81 0, /* stop run after this event limit */
82 0, /* number of sub events */
83 10, /* log history every ten seconds*/
84 "", "", "", "", "", 0},
85 read_periodic_event, /* readout routine */
86 },
87
88 {""}
89};
INT read_periodic_event(char *pevent, INT off)
Definition frontend.cxx:211
INT read_trigger_event(char *pevent, INT off)
Definition frontend.cxx:176
#define EQ_POLLED
Definition midas.h:415
#define RO_ODB
Definition midas.h:438
#define EQ_PERIODIC
Definition midas.h:414
#define RO_TRANSITIONS
Definition midas.h:434
#define RO_RUNNING
Definition midas.h:426

◆ equipment_common_overwrite

BOOL equipment_common_overwrite = TRUE

Definition at line 50 of file frontend.cxx.

◆ frontend_file_name

const char* frontend_file_name = __FILE__

Definition at line 39 of file frontend.cxx.

◆ frontend_name

const char* frontend_name = "Sample Frontend"

Definition at line 37 of file frontend.cxx.