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 /* put any hardware initialization here */
134
135 /* print message and return FE_ERR_HW if frontend should not be started */
136 return SUCCESS;
137}
INT poll_trigger_event(INT source, INT count, BOOL test)
Definition frontend.cxx:149
#define SUCCESS
Definition mcstd.h:54
void install_poll_event(INT(*f)(INT, INT, BOOL))
Definition mfed.cxx:54
Here is the call graph for this function:

◆ poll_trigger_event()

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

Definition at line 149 of file frontend.cxx.

153{
154 int i;
155 DWORD flag;
156
157 for (i = 0; i < count; i++) {
158 /* poll hardware and set flag to TRUE if new event is available */
159 flag = TRUE;
160
161 if (flag)
162 if (!test)
163 return TRUE;
164 }
165
166 return 0;
167}
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 208 of file frontend.cxx.

209{
210 UINT32 *pdata;
211
212 /* init bank structure */
213 bk_init(pevent);
214
215 /* create a bank called PRDC */
216 bk_create(pevent, "PRDC", TID_UINT32, (void **)&pdata);
217
218 /* following code "simulates" some values in sine wave form */
219 for (int i = 0; i < 16; i++)
220 *pdata++ = 100*sin(M_PI*time(NULL)/60+i/2.0)+100;
221
222 bk_close(pevent, pdata);
223
224 return bk_size(pevent);
225}
INT bk_close(void *event, void *pdata)
Definition midas.cxx:16780
void bk_init(void *event)
Definition midas.cxx:16406
void bk_create(void *event, const char *name, WORD type, void **pdata)
Definition midas.cxx:16561
INT bk_size(const void *event)
Definition midas.cxx:16495
#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 173 of file frontend.cxx.

174{
175 UINT32 *pdata;
176
177 /* init bank structure */
178 bk_init(pevent);
179
180 /* create a bank called ADC0 */
181 bk_create(pevent, "ADC0", TID_UINT32, (void **)&pdata);
182
183 /* following code "simulates" some ADC data */
184 for (int i = 0; i < 4; i++)
185 *pdata++ = rand()%1024 + rand()%1024 + rand()%1024 + rand()%1024;
186
187 bk_close(pevent, pdata);
188
189 /* create another bank called TDC0 */
190 bk_create(pevent, "TDC0", TID_UINT32, (void **)&pdata);
191
192 /* following code "simulates" some TDC data */
193 for (int i = 0; i < 4; i++)
194 *pdata++ = rand()%1024 + rand()%1024 + rand()%1024 + rand()%1024;
195
196 bk_close(pevent, pdata);
197
198 /* limit event rate to 100 Hz. In a real experiment remove this line */
199 ss_sleep(10);
200
201 return bk_size(pevent);
202}
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, 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, 0},
85 read_periodic_event, /* readout routine */
86 },
87
88 {""}
89};
INT read_periodic_event(char *pevent, INT off)
Definition frontend.cxx:208
INT read_trigger_event(char *pevent, INT off)
Definition frontend.cxx:173
#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.