MIDAS
Loading...
Searching...
No Matches
feslow.cxx File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <math.h>
#include <ctype.h>
#include <assert.h>
#include "midas.h"
Include dependency graph for feslow.cxx:

Go to the source code of this file.

Macros

#define FE_NAME   "feslow"
 
#define EQ_NAME   "Slow"
 
#define EQ_EVID   1
 

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_slow_event (char *pevent, int off)
 
static int configure ()
 
INT poll_event (INT source, INT count, BOOL test)
 
INT interrupt_configure (INT cmd, INT source, PTYPE adr)
 
double get_time ()
 

Variables

charfrontend_name = FE_NAME
 
charfrontend_file_name = __FILE__
 
BOOL frontend_call_loop = TRUE
 
INT display_period = 0
 
INT max_event_size = 2000
 
INT max_event_size_frag = 0
 
INT event_buffer_size = 10*2000
 
HNDLE hDB
 main ODB handle
 
INT gbl_run_number
 
EQUIPMENT equipment []
 
int count_slow = 0
 

Macro Definition Documentation

◆ EQ_EVID

#define EQ_EVID   1

Definition at line 27 of file feslow.cxx.

◆ EQ_NAME

#define EQ_NAME   "Slow"

Definition at line 26 of file feslow.cxx.

◆ FE_NAME

#define FE_NAME   "feslow"

Definition at line 25 of file feslow.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 158 of file feslow.cxx.

159{
160 printf("Begin run %d\n", run_number);
162
163 configure();
164
165 count_slow = 0;
166
167 return SUCCESS;
168}
#define SUCCESS
Definition mcstd.h:54
int count_slow
Definition feslow.cxx:125
INT gbl_run_number
Definition feslow.cxx:67
static int configure()
Definition feslow.cxx:127
INT run_number[2]
Definition mana.cxx:246
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:

◆ configure()

static int configure ( )
static

Definition at line 127 of file feslow.cxx.

128{
129 int size, status;
130
131 //size = sizeof(int);
132 //status = db_get_value(hDB, 0, "/Equipment/" EQ_NAME "/Settings/event_size", &event_size, &size, TID_INT, TRUE);
133 //printf("Event size set to %d bytes\n", event_size);
134
135 return SUCCESS;
136}
DWORD status
Definition odbhist.cxx:39
Here is the caller graph for this function:

◆ 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 172 of file feslow.cxx.

173{
174 printf("End run %d!\n", run_number);
175
176 cm_msg(MINFO, frontend_name, "read %d slow events", count_slow);
177
178 return SUCCESS;
179}
#define MINFO
Definition midas.h:560
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
char * frontend_name
Definition feslow.cxx:37
Here is the call graph for this function:

◆ 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 151 of file feslow.cxx.

152{
153 return SUCCESS;
154}

◆ 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 140 of file feslow.cxx.

141{
142 //cm_set_watchdog_params (FALSE, 0);
143
144 configure();
145
146 return SUCCESS;
147}
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 197 of file feslow.cxx.

198{
199 /* if frontend_call_loop is true, this routine gets called when
200 the frontend is idle or once between every event */
201 //printf("frontend_loop!\n");
202 ss_sleep(10);
203 return SUCCESS;
204}
INT ss_sleep(INT millisec)
Definition system.cxx:3628
Here is the call graph for this function:

◆ get_time()

double get_time ( )

Definition at line 245 of file feslow.cxx.

246{
247 struct timeval tv;
249 return tv.tv_sec + 0.000001*tv.tv_usec;
250}
int gettimeofday(struct timeval *tp, void *tzp)
timeval tv
Definition msysmon.cxx:1095
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interrupt_configure()

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

Definition at line 227 of file feslow.cxx.

228{
229 switch(cmd)
230 {
232 break;
234 break;
236 break;
238 break;
239 }
240 return SUCCESS;
241}
#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 183 of file feslow.cxx.

184{
185 return SUCCESS;
186}

◆ poll_event()

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

Definition at line 214 of file feslow.cxx.

218{
219 if (test) {
220 ss_sleep (count);
221 }
222 return (0);
223}
double count
Definition mdump.cxx:33
program test
Definition miniana.f:6
Here is the call graph for this function:

◆ read_slow_event()

int read_slow_event ( char pevent,
int  off 
)

Definition at line 252 of file feslow.cxx.

253{
254 bk_init32(pevent);
255
256 count_slow++;
257
258 double* pdatad;
259 bk_create(pevent, "SLOW", TID_DOUBLE, &pdatad);
260
261 time_t t = time(NULL);
262 pdatad[0] = count_slow;
263 pdatad[1] = t;
264 pdatad[2] = 100.0*sin(M_PI*t/60);
265 printf("time %d, data %f\n", (int)t, pdatad[2]);
266
267 bk_close(pevent, pdatad + 3);
268
269 return bk_size(pevent);
270}
INT bk_close(void *event, void *pdata)
Definition midas.cxx:16780
void bk_init32(void *event)
Definition midas.cxx:16469
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_DOUBLE
Definition midas.h:343
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 190 of file feslow.cxx.

191{
192 return SUCCESS;
193}

Variable Documentation

◆ count_slow

int count_slow = 0

Definition at line 125 of file feslow.cxx.

◆ display_period

INT display_period = 0

Definition at line 47 of file feslow.cxx.

◆ equipment

EQUIPMENT equipment[]
Initial value:
= {
{ EQ_NAME,
{
EQ_EVID, (1<<EQ_EVID),
"SYSTEM",
0,
"MIDAS",
TRUE,
1000,
0,
0,
1,
"", "", ""
},
},
{ "" }
}
#define RO_STOPPED
Definition midas.h:427
#define RO_ODB
Definition midas.h:438
#define EQ_PERIODIC
Definition midas.h:414
#define RO_PAUSED
Definition midas.h:428
#define RO_RUNNING
Definition midas.h:426
#define EQ_NAME
Definition feslow.cxx:26
int read_slow_event(char *pevent, int off)
Definition feslow.cxx:252
#define EQ_EVID
Definition feslow.cxx:27
#define TRUE
Definition midas.h:182

Definition at line 73 of file feslow.cxx.

73 {
74
75 { EQ_NAME, /* equipment name */
76 {
77 EQ_EVID, (1<<EQ_EVID), /* event ID, trigger mask */
78 "SYSTEM", /* event buffer */
79 EQ_PERIODIC, /* equipment type */
80 0, /* event source */
81 "MIDAS", /* format */
82 TRUE, /* enabled */
83 RO_RUNNING|RO_STOPPED|RO_PAUSED|RO_ODB, /* When to read */
84 1000, /* poll every so milliseconds */
85 0, /* stop run after this event limit */
86 0, /* number of sub events */
87 1, /* history period*/
88 "", "", ""
89 },
90 read_slow_event, /* readout routine */
91 },
92 { "" }
93};

◆ event_buffer_size

INT event_buffer_size = 10*2000

Definition at line 54 of file feslow.cxx.

◆ frontend_call_loop

BOOL frontend_call_loop = TRUE

Definition at line 43 of file feslow.cxx.

◆ frontend_file_name

char* frontend_file_name = __FILE__

Definition at line 40 of file feslow.cxx.

◆ frontend_name

char* frontend_name = FE_NAME

Definition at line 37 of file feslow.cxx.

◆ gbl_run_number

INT gbl_run_number

Definition at line 67 of file feslow.cxx.

◆ hDB

HNDLE hDB

main ODB handle

Definition at line 66 of file feslow.cxx.

◆ max_event_size

INT max_event_size = 2000

Definition at line 50 of file feslow.cxx.

◆ max_event_size_frag

INT max_event_size_frag = 0

Definition at line 51 of file feslow.cxx.