frontend.c File Reference

Go to the source code of this file.

Defines

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

Functions

INT frontend_init ()
INT frontend_exit ()
INT begin_of_run (INT run_number, char *error)
INT end_of_run (INT run_number, char *error)
INT pause_run (INT run_number, char *error)
INT resume_run (INT run_number, char *error)
INT frontend_loop ()
INT read_trigger_event (char *pevent, INT off)
INT read_scaler_event (char *pevent, INT off)
void register_cnaf_callback (int debug)
INT poll_event (INT source, INT count, BOOL test)
INT interrupt_configure (INT cmd, INT source, POINTER_T adr)

Variables

char * frontend_name = "Sample Frontend"
char * frontend_file_name = __FILE__
BOOL frontend_call_loop = FALSE
INT display_period = 3000
INT max_event_size = 10000
INT max_event_size_frag = 5 * 1024 * 1024
INT event_buffer_size = 100 * 10000
EQUIPMENT equipment []


Define Documentation

#define CRATE   0

Definition at line 56 of file frontend.c.

Referenced by read_scaler_event(), and read_trigger_event().

#define N_ADC   4

Definition at line 51 of file frontend.c.

Referenced by adc_calib(), adc_calib_init(), and read_trigger_event().

#define N_SCLR   4

Definition at line 53 of file frontend.c.

Referenced by read_scaler_event().

#define N_TDC   4

Definition at line 52 of file frontend.c.

Referenced by read_trigger_event().

#define SLOT_ADC   1

Definition at line 58 of file frontend.c.

Referenced by read_trigger_event().

#define SLOT_IO   23

Definition at line 57 of file frontend.c.

Referenced by read_trigger_event().

#define SLOT_SCLR   3

Definition at line 60 of file frontend.c.

Referenced by read_scaler_event().

#define SLOT_TDC   2

Definition at line 59 of file frontend.c.

Referenced by read_trigger_event().


Function Documentation

INT begin_of_run ( INT  run_number,
char *  error 
)

INT end_of_run ( INT  run_number,
char *  error 
)

INT frontend_exit (  ) 

INT frontend_init (  ) 

INT frontend_loop (  ) 

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

Definition at line 252 of file frontend.c.

00253 {
00254    switch (cmd) {
00255    case CMD_INTERRUPT_ENABLE:
00256       break;
00257    case CMD_INTERRUPT_DISABLE:
00258       break;
00259    case CMD_INTERRUPT_ATTACH:
00260       break;
00261    case CMD_INTERRUPT_DETACH:
00262       break;
00263    }
00264    return SUCCESS;
00265 }

INT pause_run ( INT  run_number,
char *  error 
)

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

Definition at line 231 of file frontend.c.

00235 {
00236    int i;
00237    DWORD lam;
00238 
00239    for (i = 0; i < count; i++) {
00240       cam_lam_read(LAM_SOURCE_CRATE(source), &lam);
00241 
00242       if (lam & LAM_SOURCE_STATION(source))
00243          if (!test)
00244             return lam;
00245    }
00246 
00247    return 0;
00248 }

INT read_scaler_event ( char *  pevent,
INT  off 
)

INT read_trigger_event ( char *  pevent,
INT  off 
)

Definition at line 269 of file frontend.c.

00270 {
00271    WORD *pdata, a;
00272    INT q, timeout;
00273 
00274    /* init bank structure */
00275    bk_init(pevent);
00276 
00277    /* create structured ADC0 bank */
00278    bk_create(pevent, "ADC0", TID_WORD, &pdata);
00279 
00280    /* wait for ADC conversion */
00281    for (timeout = 100; timeout > 0; timeout--) {
00282       camc_q(CRATE, SLOT_ADC, 0, 8, &q);
00283       if (q)
00284          break;
00285    }
00286    if (timeout == 0)
00287       ss_printf(0, 10, "No ADC gate!");
00288 
00289    /* use following code to read out real CAMAC ADC */
00290    /*
00291       for (a=0 ; a<N_ADC ; a++)
00292       cami(CRATE, SLOT_ADC, a, 0, pdata++);
00293     */
00294 
00295    /* Use following code to "simulate" data */
00296    for (a = 0; a < N_ADC; a++)
00297       *pdata++ = rand() % 1024;
00298 
00299    /* clear ADC */
00300    camc(CRATE, SLOT_ADC, 0, 9);
00301 
00302    bk_close(pevent, pdata);
00303 
00304    /* create variable length TDC bank */
00305    bk_create(pevent, "TDC0", TID_WORD, &pdata);
00306 
00307    /* use following code to read out real CAMAC TDC */
00308    /*
00309       for (a=0 ; a<N_TDC ; a++)
00310       cami(CRATE, SLOT_TDC, a, 0, pdata++);
00311     */
00312 
00313    /* Use following code to "simulate" data */
00314    for (a = 0; a < N_TDC; a++)
00315       *pdata++ = rand() % 1024;
00316 
00317    /* clear TDC */
00318    camc(CRATE, SLOT_TDC, 0, 9);
00319 
00320    bk_close(pevent, pdata);
00321 
00322    /* clear IO unit LAM */
00323    camc(CRATE, SLOT_IO, 0, 10);
00324 
00325    /* clear LAM in crate controller */
00326    cam_lam_clear(CRATE, SLOT_IO);
00327 
00328    /* reset external LAM Flip-Flop */
00329    camo(CRATE, SLOT_IO, 1, 16, 0xFF);
00330    camo(CRATE, SLOT_IO, 1, 16, 0);
00331 
00332    ss_sleep(10);
00333 
00334    return bk_size(pevent);
00335 }

void register_cnaf_callback ( int  debug  ) 

Definition at line 124 of file cnaf_callback.c.

00125 {
00126    cnaf_debug = debug;
00127    /* register CNAF callback */
00128    cm_register_function(RPC_CNAF16, cnaf_callback);
00129    cm_register_function(RPC_CNAF24, cnaf_callback);
00130 }

INT resume_run ( INT  run_number,
char *  error 
)


Variable Documentation

INT display_period = 3000

Definition at line 39 of file frontend.c.

EQUIPMENT equipment[]

Definition at line 79 of file frontend.c.

INT event_buffer_size = 100 * 10000

Definition at line 48 of file frontend.c.

BOOL frontend_call_loop = FALSE

Definition at line 36 of file frontend.c.

char* frontend_file_name = __FILE__

Definition at line 33 of file frontend.c.

char* frontend_name = "Sample Frontend"

Definition at line 31 of file frontend.c.

INT max_event_size = 10000

Definition at line 42 of file frontend.c.

INT max_event_size_frag = 5 * 1024 * 1024

Definition at line 45 of file frontend.c.


Midas DOC Version 3.0.0 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk