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

Go to the source code of this file.

Macros

#define N_ADC   4
 
#define N_TDC   8
 
#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 ()
 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_mantrig_event (char *pevent, INT off)
 
 ADC0_BANK_STR (adc0_bank_str)
 
INT poll_event (INT source, INT count, BOOL test)
 
INT interrupt_configure (INT cmd, INT source, PTYPE adr)
 

Variables

charfrontend_name = "mantrigfe"
 
charfrontend_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 = 10 * 10000
 
BANK_LIST trigger_bank_list []
 
BANK_LIST scaler_bank_list []
 
EQUIPMENT equipment []
 

Macro Definition Documentation

◆ CRATE

#define CRATE   0

Definition at line 54 of file mantrigfe.c.

◆ N_ADC

#define N_ADC   4

Definition at line 49 of file mantrigfe.c.

◆ N_SCLR

#define N_SCLR   4

Definition at line 51 of file mantrigfe.c.

◆ N_TDC

#define N_TDC   8

Definition at line 50 of file mantrigfe.c.

◆ SLOT_ADC

#define SLOT_ADC   1

Definition at line 56 of file mantrigfe.c.

◆ SLOT_IO

#define SLOT_IO   23

Definition at line 55 of file mantrigfe.c.

◆ SLOT_SCLR

#define SLOT_SCLR   3

Definition at line 58 of file mantrigfe.c.

◆ SLOT_TDC

#define SLOT_TDC   2

Definition at line 57 of file mantrigfe.c.

Function Documentation

◆ ADC0_BANK_STR()

ADC0_BANK_STR ( adc0_bank_str  )

◆ 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 179 of file mantrigfe.c.

180{
181 /* put here clear scalers etc. */
182
183 return SUCCESS;
184}
#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 188 of file mantrigfe.c.

189{
190 return SUCCESS;
191}

◆ 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 172 of file mantrigfe.c.

173{
174 return SUCCESS;
175}

◆ 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 149 of file mantrigfe.c.

150{
151 /* hardware initialization */
152
153 cam_init();
156
157 /* enable LAM in IO unit */
158 camc(CRATE, SLOT_IO, 0, 26);
159
160 /* enable LAM in crate controller */
162
163 /* reset external LAM Flip-Flop */
164 camo(CRATE, SLOT_IO, 1, 16, 0xFF);
165 camo(CRATE, SLOT_IO, 1, 16, 0);
166
167 return SUCCESS;
168}
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)
#define SLOT_IO
Definition mantrigfe.c:55
#define CRATE
Definition mantrigfe.c:54
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 209 of file mantrigfe.c.

210{
211 /* if frontend_call_loop is true, this routine gets called when
212 the frontend is idle or once between every event */
213 return SUCCESS;
214}

◆ interrupt_configure()

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

Definition at line 247 of file mantrigfe.c.

248{
249 switch (cmd) {
251 break;
253 break;
255 break;
257 break;
258 }
259 return SUCCESS;
260}
#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 195 of file mantrigfe.c.

196{
197 return SUCCESS;
198}

◆ poll_event()

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

Definition at line 226 of file mantrigfe.c.

230{
231 int i;
232 DWORD lam;
233
234 for (i = 0; i < count; i++) {
236
237 if (lam & LAM_SOURCE_STATION(source))
238 if (!test)
239 return lam;
240 }
241
242 return 0;
243}
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
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:

◆ read_mantrig_event()

INT read_mantrig_event ( char pevent,
INT  off 
)

Definition at line 265 of file mantrigfe.c.

266{
267 DWORD *pdata, a;
268
269 /* init bank structure */
270 bk_init(pevent);
271
272 /* create SCLR bank */
273 bk_create(pevent, "SCLR", TID_DWORD, &pdata);
274
275 /* read scaler bank */
276 for (a = 0; a < N_SCLR; a++)
277 cam24i(CRATE, SLOT_SCLR, a, 0, pdata++);
278
279 bk_close(pevent, pdata);
280
281 return bk_size(pevent);
282}
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
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
#define SLOT_SCLR
Definition mantrigfe.c:58
#define N_SCLR
Definition mantrigfe.c:51
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 202 of file mantrigfe.c.

203{
204 return SUCCESS;
205}

Variable Documentation

◆ display_period

INT display_period = 3000

Definition at line 37 of file mantrigfe.c.

◆ equipment

EQUIPMENT equipment[]
Initial value:
= {
{"mantrig",
2, 0,
"SYSTEM",
0,
"MIDAS",
TRUE,
30000,
0,
0,
0,
"", "", "",
}
,
{""}
}
#define RO_ODB
Definition midas.h:438
#define EQ_PERIODIC
Definition midas.h:414
#define EQ_MANUAL_TRIG
Definition midas.h:419
#define RO_TRANSITIONS
Definition midas.h:434
#define RO_RUNNING
Definition midas.h:426
INT read_mantrig_event(char *pevent, INT off)
Definition mantrigfe.c:265
BANK_LIST scaler_bank_list[]
Definition mantrigfe.c:86
#define TRUE
Definition midas.h:182

Definition at line 97 of file mantrigfe.c.

97 {
98 {"mantrig", /* equipment name */
99 2, 0, /* event ID, trigger mask */
100 "SYSTEM", /* event buffer */
101 EQ_PERIODIC | EQ_MANUAL_TRIG, /* equipment type */
102 0, /* event source */
103 "MIDAS", /* format */
104 TRUE, /* enabled */
105 RO_RUNNING | RO_TRANSITIONS | /* read when running and on transitions */
106 RO_ODB, /* and update ODB */
107 30000, /* read every 30 sec */
108 0, /* stop run after this event limit */
109 0, /* number of sub events */
110 0, /* log history */
111 "", "", "",
112 read_mantrig_event, /* readout routine */
113 NULL, NULL,
114 scaler_bank_list, /* bank list */
115 }
116 ,
117
118 {""}
119 };

◆ event_buffer_size

INT event_buffer_size = 10 * 10000

Definition at line 46 of file mantrigfe.c.

◆ frontend_call_loop

BOOL frontend_call_loop = FALSE

Definition at line 34 of file mantrigfe.c.

◆ frontend_file_name

char* frontend_file_name = __FILE__

Definition at line 31 of file mantrigfe.c.

◆ frontend_name

char* frontend_name = "mantrigfe"

Definition at line 29 of file mantrigfe.c.

◆ max_event_size

INT max_event_size = 10000

Definition at line 40 of file mantrigfe.c.

◆ max_event_size_frag

INT max_event_size_frag = 5 * 1024 * 1024

Definition at line 43 of file mantrigfe.c.

◆ scaler_bank_list

BANK_LIST scaler_bank_list[]
Initial value:
= {
{"SCLR", TID_DWORD, N_ADC, NULL}
,
{""}
,
}
#define N_ADC
Definition mantrigfe.c:49

Definition at line 86 of file mantrigfe.c.

86 {
87 {"SCLR", TID_DWORD, N_ADC, NULL}
88 ,
89 {""}
90 ,
91 };

◆ trigger_bank_list

BANK_LIST trigger_bank_list[]
Initial value:
= {
{"ADC0", TID_STRUCT, sizeof(ADC0_BANK), adc0_bank_str}
,
{"TDC0", TID_WORD, N_TDC, NULL}
,
{""}
,
}
#define TID_WORD
Definition midas.h:332
#define TID_STRUCT
Definition midas.h:348
#define N_TDC
Definition mantrigfe.c:50

Definition at line 76 of file mantrigfe.c.

76 {
77 {"ADC0", TID_STRUCT, sizeof(ADC0_BANK), adc0_bank_str}
78 ,
79 {"TDC0", TID_WORD, N_TDC, NULL}
80 ,
81
82 {""}
83 ,
84 };