MIDAS
Loading...
Searching...
No Matches
ebfe.cxx File Reference
#include <stdio.h>
#include <stdlib.h>
#include "midas.h"
#include "mcstd.h"
Include dependency graph for ebfe.cxx:

Go to the source code of this file.

Macros

#define N_ADC   8
 
#define N_TDC   8
 
#define N_SCLR   8
 
#define CRATE   0
 
#define SLOT_IO   23
 
#define SLOT_ADC   1
 
#define SLOT_TDC   2
 
#define SLOT_SCLR   3
 

Functions

INT frontend_init ()
 Frontend initialization.
 
INT frontend_exit ()
 Frontend exit.
 
INT begin_of_run (INT run_number, char *error)
 Begin of Run.
 
INT end_of_run (INT run_number, char *error)
 End of Run.
 
INT pause_run (INT run_number, char *error)
 Pause Run.
 
INT resume_run (INT run_number, char *error)
 Resume Run.
 
INT frontend_loop ()
 Frontend loop.
 
INT read_trigger_event (char *pevent, INT off)
 
INT read_scaler_event (char *pevent, INT off)
 Scaler event readout.
 
INT get_frontend_index ()
 
INT poll_event (INT source, INT count, BOOL test)
 
INT interrupt_configure (INT cmd, INT source, POINTER_T adr)
 

Variables

const charfrontend_name = "ebfe"
 
const charfrontend_file_name = __FILE__
 
BOOL frontend_call_loop = TRUE
 
INT display_period = 3000
 
INT max_event_size = 1000
 
INT max_event_size_frag = 0
 
INT event_buffer_size = 10 * 1000
 
char Adcx [5]
 
char Tdcx [5]
 
char Sclx [5]
 
BOOL equipment_common_overwrite = false
 
EQUIPMENT equipment []
 

Macro Definition Documentation

◆ CRATE

#define CRATE   0

Definition at line 59 of file ebfe.cxx.

◆ N_ADC

#define N_ADC   8

Definition at line 54 of file ebfe.cxx.

◆ N_SCLR

#define N_SCLR   8

Definition at line 56 of file ebfe.cxx.

◆ N_TDC

#define N_TDC   8

Definition at line 55 of file ebfe.cxx.

◆ SLOT_ADC

#define SLOT_ADC   1

Definition at line 61 of file ebfe.cxx.

◆ SLOT_IO

#define SLOT_IO   23

Definition at line 60 of file ebfe.cxx.

◆ SLOT_SCLR

#define SLOT_SCLR   3

Definition at line 63 of file ebfe.cxx.

◆ SLOT_TDC

#define SLOT_TDC   2

Definition at line 62 of file ebfe.cxx.

Function Documentation

◆ begin_of_run()

INT begin_of_run ( INT  run_number,
char error 
)

Begin of Run.

Called every run start transition. Set equipment status in ODB, start acquisition on the modules.

Parameters
[in]run_numberNumber of the run being started
[out]errorCan be used to write a message string to midas.log

Definition at line 168 of file ebfe.cxx.

169{
170 /* put here clear scalers etc. */
171
172 return SUCCESS;
173}
#define SUCCESS
Definition mcstd.h:54

◆ end_of_run()

INT end_of_run ( INT  run_number,
char error 
)

End of Run.

Called every stop run transition. Set equipment status in ODB, stop acquisition on the modules.

Parameters
[in]run_numberNumber of the run being ended
[out]errorCan be used to write a message string to midas.log

Definition at line 176 of file ebfe.cxx.

177{
178 return SUCCESS;
179}

◆ frontend_exit()

INT frontend_exit ( void  )

Frontend exit.

Runs at frontend shutdown. Disconnect hardware and set equipment status in ODB

Returns
Midas status code

Definition at line 162 of file ebfe.cxx.

163{
164 return SUCCESS;
165}

◆ 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 133 of file ebfe.cxx.

134{
135 /* Compose expected bank name under Ebuilder */
136 sprintf(Adcx, "AD%02d", get_frontend_index());
137 sprintf(Tdcx, "TC%02d", get_frontend_index());
138 sprintf(Sclx, "SC%02d", get_frontend_index());
139
140 /* hardware initialization */
141
142 cam_init();
145
146 /* enable LAM in IO unit */
147 camc(CRATE, SLOT_IO, 0, 26);
148
149 /* enable LAM in crate controller */
151
152 /* reset external LAM Flip-Flop */
153 camo(CRATE, SLOT_IO, 1, 16, 0xFF);
154 camo(CRATE, SLOT_IO, 1, 16, 0);
155
156 /* print message and return FE_ERR_HW if frontend should not be started */
157
158 return SUCCESS;
159}
INT get_frontend_index()
Definition mfe.cxx:2368
char Sclx[5]
Definition ebfe.cxx:51
char Tdcx[5]
Definition ebfe.cxx:51
#define SLOT_IO
Definition ebfe.cxx:60
#define CRATE
Definition ebfe.cxx:59
char Adcx[5]
Definition ebfe.cxx:51
EXTERNAL void EXPRT cam_lam_enable(const int c, const int n)
EXTERNAL int EXPRT cam_init(void)
EXTERNAL void EXPRT camo(const int c, const int n, const int a, const int f, WORD d)
EXTERNAL void EXPRT cam_crate_clear(const int c)
EXTERNAL void EXPRT camc(const int c, const int n, const int a, const int f)
EXTERNAL void EXPRT cam_crate_zinit(const int c)
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:

◆ frontend_loop()

INT frontend_loop ( void  )

Frontend loop.

If frontend_call_loop is true, this routine gets called when the frontend is idle or once between every event.

Returns
Midas status code

Definition at line 194 of file ebfe.cxx.

195{
196 /* if frontend_call_loop is true, this routine gets called when
197 the frontend is idle or once between every event */
198 cm_yield(100);
199 return SUCCESS;
200}
INT cm_yield(INT millisec)
Definition midas.cxx:5650
Here is the call graph for this function:

◆ get_frontend_index()

INT get_frontend_index ( )
extern

Definition at line 2368 of file mfe.cxx.

2368 {
2369 return frontend_index;
2370}
static INT frontend_index
Definition mfe.cxx:53
Here is the caller graph for this function:

◆ interrupt_configure()

INT interrupt_configure ( INT  cmd,
INT  source,
POINTER_T  adr 
)

Definition at line 232 of file ebfe.cxx.

233{
234 switch (cmd) {
236 break;
238 break;
240 break;
242 break;
243 }
244 return SUCCESS;
245}
#define CMD_INTERRUPT_ATTACH
Definition midas.h:822
#define CMD_INTERRUPT_DISABLE
Definition midas.h:821
#define CMD_INTERRUPT_ENABLE
Definition midas.h:820
#define CMD_INTERRUPT_DETACH
Definition midas.h:823

◆ pause_run()

INT pause_run ( INT  run_number,
char error 
)

Pause Run.

Called every pause run transition.

Parameters
[in]run_numberNumber of the run being ended
[out]errorCan be used to write a message string to midas.log
Returns
Midas status code

Definition at line 182 of file ebfe.cxx.

183{
184 return SUCCESS;
185}

◆ poll_event()

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

Definition at line 211 of file ebfe.cxx.

215{
216 int i;
217 DWORD lam;
218
219 for (i = 0; i < count; i++) {
221 cm_yield(10);
222 if (lam & LAM_SOURCE_STATION(source))
223 if (!test)
224 return lam;
225 }
226
227 return 0;
228}
EXTERNAL void cam_lam_read(const int c, DWORD *lam)
unsigned int DWORD
Definition mcstd.h:51
double count
Definition mdump.cxx:33
INT i
Definition mdump.cxx:32
#define LAM_SOURCE_STATION(s)
Definition midas.h:487
#define LAM_SOURCE_CRATE(c)
Definition midas.h:481
program test
Definition miniana.f:6
Here is the call graph for this function:

◆ read_scaler_event()

INT read_scaler_event ( char pevent,
INT  off 
)

Scaler event readout.

Placeholder.

Scaler event readout routine. Not used in this example.

Parameters
[in]peventPointer to event buffer
[in]offCaller info (unused here), see mfe.c
Returns
Size of the event

Definition at line 295 of file ebfe.cxx.

296{
297 DWORD *pdata, a;
298
299 /* init bank structure */
300 bk_init(pevent);
301
302 /* create SCLR bank */
303 bk_create(pevent, Sclx, TID_DWORD, (void**)&pdata);
304
305 /* read scaler bank */
306 for (a = 0; a < N_SCLR; a++)
307 cam24i(CRATE, SLOT_SCLR, a, 0, pdata++);
308
309 bk_close(pevent, pdata);
310
311 return bk_size(pevent);
312}
#define SLOT_SCLR
Definition ebfe.cxx:63
#define N_SCLR
Definition ebfe.cxx:56
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
EXTERNAL void EXPRT cam24i(const int c, const int n, const int a, const int f, DWORD *d)
#define TID_DWORD
Definition midas.h:336

◆ read_trigger_event()

INT read_trigger_event ( char pevent,
INT  off 
)

Definition at line 249 of file ebfe.cxx.

250{
251 WORD *pdata, a;
252
253 /* init bank structure */
254 bk_init(pevent);
255
256 /* create ADC bank */
257 bk_create(pevent, Adcx, TID_WORD, (void**)&pdata);
258
259 /* read ADC bank */
260 for (a = 0; a < N_ADC; a++)
261 *pdata++ = a + 10;
262
263 /* clear ADC */
264 camc(CRATE, SLOT_ADC, 0, 9);
265
266 bk_close(pevent, pdata);
267
268 /* create TDC bank */
269 bk_create(pevent, Tdcx, TID_WORD, (void**)&pdata);
270
271 /* read TDC bank */
272 for (a = 0; a < N_TDC; a++)
273 *pdata++ = a + 20;
274
275 /* clear TDC */
276 camc(CRATE, SLOT_TDC, 0, 9);
277
278 bk_close(pevent, pdata);
279
280 /* clear IO unit LAM */
281 camc(CRATE, SLOT_IO, 0, 10);
282
283 /* clear LAM in crate controller */
285
286 /* reset external LAM Flip-Flop */
287 camo(CRATE, SLOT_IO, 1, 16, 0xFF);
288 camo(CRATE, SLOT_IO, 1, 16, 0);
289
290 return bk_size(pevent);
291}
#define SLOT_ADC
Definition ebfe.cxx:61
#define N_TDC
Definition ebfe.cxx:55
#define SLOT_TDC
Definition ebfe.cxx:62
#define N_ADC
Definition ebfe.cxx:54
EXTERNAL void EXPRT cam_lam_clear(const int c, const int n)
unsigned short int WORD
Definition mcstd.h:49
#define TID_WORD
Definition midas.h:332
Here is the call graph for this function:

◆ resume_run()

INT resume_run ( INT  run_number,
char error 
)

Resume Run.

Called every resume run transition.

Parameters
[in]run_numberNumber of the run being ended
[out]errorCan be used to write a message string to midas.log
Returns
Midas status code

Definition at line 188 of file ebfe.cxx.

189{
190 return SUCCESS;
191}

Variable Documentation

◆ Adcx

char Adcx[5]

Definition at line 51 of file ebfe.cxx.

◆ display_period

INT display_period = 3000

Definition at line 41 of file ebfe.cxx.

◆ equipment

EQUIPMENT equipment[]
Initial value:
= {
{"Eqp%0d",
{2, 0,
"BUF%0d",
LAM_SOURCE(0, 0xFFFFFF),
"MIDAS",
TRUE,
500,
0,
0,
0,
"", "", "",},
},
{""}
}
INT read_trigger_event(char *pevent, INT off)
Definition ebfe.cxx:249
#define EQ_POLLED
Definition midas.h:415
#define EQ_EB
Definition midas.h:421
#define RO_ODB
Definition midas.h:438
#define RO_RUNNING
Definition midas.h:426
#define LAM_SOURCE(c, s)
Definition midas.h:469
#define TRUE
Definition midas.h:182

Definition at line 84 of file ebfe.cxx.

84 {
85
86 {"Eqp%0d", /* equipment name */
87 {2, 0, /* event ID, trigger mask */
88 "BUF%0d", /* event buffer */
89#ifdef USE_INT
90 EQ_INTERRUPT, /* equipment type */
91#else
92 EQ_POLLED | EQ_EB, /* equipment type */
93#endif
94 LAM_SOURCE(0, 0xFFFFFF), /* event source crate 0, all stations */
95 "MIDAS", /* format */
96 TRUE, /* enabled */
97 RO_RUNNING | /* read only when running */
98 RO_ODB, /* and update ODB */
99 500, /* poll for 500ms */
100 0, /* stop run after this event limit */
101 0, /* number of sub events */
102 0, /* don't log history */
103 "", "", "",},
104 read_trigger_event, /* readout routine */
105 },
106 {""}
107 };
#define EQ_INTERRUPT
Definition midas.h:416

◆ equipment_common_overwrite

BOOL equipment_common_overwrite = false

Definition at line 82 of file ebfe.cxx.

◆ event_buffer_size

INT event_buffer_size = 10 * 1000

Definition at line 48 of file ebfe.cxx.

◆ frontend_call_loop

BOOL frontend_call_loop = TRUE

Definition at line 38 of file ebfe.cxx.

◆ frontend_file_name

const char* frontend_file_name = __FILE__

Definition at line 35 of file ebfe.cxx.

◆ frontend_name

const char* frontend_name = "ebfe"

Definition at line 33 of file ebfe.cxx.

◆ max_event_size

INT max_event_size = 1000

Definition at line 44 of file ebfe.cxx.

◆ max_event_size_frag

INT max_event_size_frag = 0

Definition at line 45 of file ebfe.cxx.

◆ Sclx

char Sclx[5]

Definition at line 51 of file ebfe.cxx.

◆ Tdcx

char Tdcx[5]

Definition at line 51 of file ebfe.cxx.