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

Go to the source code of this file.

Macros

#define NWORDS   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_tiny_event (char *pevent, INT off)
 
INT poll_event (INT source, INT count, BOOL test)
 
INT interrupt_configure (INT cmd, INT source, PTYPE adr)
 

Variables

charfrontend_name = "tinyfe"
 
charfrontend_file_name = __FILE__
 
BOOL frontend_call_loop = TRUE
 
INT display_period = 0000
 
INT max_event_size = 10000
 
INT max_event_size_frag = 5 * 1024 * 1024
 
INT event_buffer_size = 10 * 10000
 
HNDLE hDB
 main ODB handle
 
HNDLE hKey
 
EQUIPMENT equipment []
 

Macro Definition Documentation

◆ NWORDS

#define NWORDS   3

Definition at line 212 of file tinyfe.c.

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 130 of file tinyfe.c.

131{
132 return SUCCESS;
133}
#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 137 of file tinyfe.c.

138{
139 return SUCCESS;
140}

◆ 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 123 of file tinyfe.c.

124{
125 return SUCCESS;
126}

◆ 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 116 of file tinyfe.c.

117{
118 return SUCCESS;
119}

◆ 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 157 of file tinyfe.c.

158{
159 return SUCCESS;
160}

◆ interrupt_configure()

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

Definition at line 195 of file tinyfe.c.

196{
197 switch (cmd) {
199 break;
201 break;
203 break;
205 break;
206 }
207 return SUCCESS;
208}
#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 144 of file tinyfe.c.

145{
146 return SUCCESS;
147}

◆ poll_event()

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

Definition at line 172 of file tinyfe.c.

176{
177 int i;
178 DWORD lam;
179
180 for (i = 0; i < count; i++) {
182
183// To force a LAM independently of the driver.
184 lam = 1;
185 if (lam & LAM_SOURCE_STATION(source))
186 if (!test)
187 return lam;
188 }
189
190 return 0;
191}
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_tiny_event()

INT read_tiny_event ( char pevent,
INT  off 
)

Definition at line 214 of file tinyfe.c.

215{
216 static WORD *pdata = NULL;
217 static WORD sub_counter = 0;
218 // Super event structure
219 if (offset == 0) { // FIRST event of the Super event
220 bk_init(pevent);
221 bk_create(pevent, "SUPR", TID_WORD, &pdata);
222 sub_counter = 1;
223 } else if (offset == -1) { // CLOSE Super event
224 bk_close(pevent, pdata);
225 return bk_size(pevent);
226 }
227 // READ event
228 *pdata++ = 0xB0E;
229 *pdata++ = sub_counter++;
230 *pdata++ = 0xE0E;
231
232 if (offset == 0) {
233 // Compute the proper event length on the FIRST event in the Super Event
234 // NWORDS correspond to the !! NWORDS WORD above !!
235 // sizeof(BANK_HEADER) + sizeof(BANK) will make the 16 bytes header
236 // sizeof(WORD) is defined by the TID_WORD in bk_create()
237 return NWORDS * sizeof(WORD) + sizeof(BANK_HEADER) + sizeof(BANK);
238 } else {
239 // Return the data section size only
240 // sizeof(WORD) is defined by the TID_WORD in bk_create()
241 return NWORDS * sizeof(WORD);
242 }
243}
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
unsigned short int WORD
Definition mcstd.h:49
#define TID_WORD
Definition midas.h:332
static int offset
Definition mgd.cxx:1500
Definition midas.h:1215
#define NWORDS
Definition tinyfe.c:212
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 151 of file tinyfe.c.

152{
153 return SUCCESS;
154}

Variable Documentation

◆ display_period

INT display_period = 0000

Definition at line 36 of file tinyfe.c.

◆ equipment

EQUIPMENT equipment[]
Initial value:
= {
{"Tiny",
3, 0,
"SYSTEM",
1,
"MIDAS",
TRUE,
500,
0,
10,
0,
"", "", "",
NULL,
},
{""}
}
#define EQ_POLLED
Definition midas.h:415
#define RO_RUNNING
Definition midas.h:426
#define TRUE
Definition midas.h:182
INT read_tiny_event(char *pevent, INT off)
Definition tinyfe.c:214

Definition at line 65 of file tinyfe.c.

65 {
66
67 {"Tiny", /* equipment name */
68 3, 0, /* event ID, trigger mask */
69 "SYSTEM", /* event buffer */
70 EQ_POLLED, /* equipment type */
71 1, /* event source */
72 "MIDAS", /* format */
73 TRUE, /* enabled */
74 RO_RUNNING, /* read when running and on transitions */
75 500, /* poll 500ms */
76 0, /* stop run after this event limit */
77 10, /* number of sub events */
78 0, /* log history */
79 "", "", "",
80 read_tiny_event, /* readout routine */
81 NULL, NULL, /* keep null */
82 NULL, /* init string */
83 },
84
85 {""}
86 };

◆ event_buffer_size

INT event_buffer_size = 10 * 10000

Definition at line 45 of file tinyfe.c.

◆ frontend_call_loop

BOOL frontend_call_loop = TRUE

Definition at line 33 of file tinyfe.c.

◆ frontend_file_name

char* frontend_file_name = __FILE__

Definition at line 30 of file tinyfe.c.

◆ frontend_name

char* frontend_name = "tinyfe"

Definition at line 27 of file tinyfe.c.

◆ hDB

HNDLE hDB

main ODB handle

Definition at line 49 of file tinyfe.c.

◆ hKey

HNDLE hKey

Definition at line 49 of file tinyfe.c.

◆ max_event_size

INT max_event_size = 10000

Definition at line 39 of file tinyfe.c.

◆ max_event_size_frag

INT max_event_size_frag = 5 * 1024 * 1024

Definition at line 42 of file tinyfe.c.