MIDAS
Loading...
Searching...
No Matches
mfed.cxx
Go to the documentation of this file.
1/********************************************************************\
2
3 Name: mfed.c
4 Created by: Stefan Ritt
5
6 Contents: Dummy routines to simplify syntax for mfe based
7 frontends.
8
9 Users must #defien MFED before #include "mfe.h"
10 and link against mfed.cxx
11
12\********************************************************************/
13
14#include <cstdio>
15#include <cstring>
16#include <history.h>
17#include "midas.h"
18#include "mfe.h"
19#include "odbxx.h"
20
21/*-- Globals -------------------------------------------------------*/
22
23/* frontend_loop is called periodically if this variable is TRUE */
25
26/* a frontend status page is displayed with this frequency in ms */
28
29/* maximum event size produced by this frontend */
30INT max_event_size = 1024 * 1024;
31
32/* maximum event size for fragmented events (EQ_FRAGMENTED) */
33INT max_event_size_frag = 5 * 1024 * 1024;
34
35/* buffer size to hold events */
36INT event_buffer_size = 2 * 1024 * 1024;
37
38/*------------------------------------------------------------------*/
39
40void set_max_event_size(int size)
41{
42 max_event_size = size;
43 event_buffer_size = 2 * size;
44}
45
47{
48 event_buffer_size = size;
49}
50
51/*------------------------------------------------------------------*/
52
54
56{
57 p_poll_event = f;
58}
59
61{
62 if (p_poll_event)
63 return p_poll_event(source, count, test);
64 return 1;
65}
66
67INT interrupt_configure(__attribute__((unused)) INT cmd, __attribute__((unused)) INT source, __attribute__((unused)) PTYPE adr)
68{
69 return 1;
70}
71
72/*------------------------------------------------------------------*/
73
74INT set_cache_size(std::string buffer, int size)
75{
76 if (size < MIN_WRITE_CACHE_SIZE && size != 0) {
77 cm_msg(MERROR, "set_cache_size", "Requested write cache size %d too small, minimum is %d", size, MIN_WRITE_CACHE_SIZE);
78 return 0;
79 }
80
81 gWriteCacheSize = size;
82 for (int i=0 ; i<equipment[i].name[0] ; i++)
83 if (std::string(equipment[i].info.buffer) == buffer) {
84 bm_set_cache_size(equipment[i].buffer_handle, 0, size);
85 return 1;
86 }
87
88 return 0;
89}
90
91/*------------------------------------------------------------------*/
92
94
96{
98}
99
101{
102 if (p_frontend_exit)
103 return p_frontend_exit();
104 return CM_SUCCESS;
105}
106
107/*------------------------------------------------------------------*/
108
110
112{
113 p_begin_of_run = f;
114}
115
116INT begin_of_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
117{
118 if (p_begin_of_run)
119 return p_begin_of_run();
120 return CM_SUCCESS;
121}
122
123/*------------------------------------------------------------------*/
124
126
128{
129 p_end_of_run = f;
130}
131
132INT end_of_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
133{
134 if (p_end_of_run)
135 return p_end_of_run();
136 return CM_SUCCESS;
137}
138
139/*------------------------------------------------------------------*/
140
142
144{
145 p_pause_run = f;
146}
147
148INT pause_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
149{
150 if (p_pause_run)
151 return p_pause_run();
152 return CM_SUCCESS;
153}
154
155/*------------------------------------------------------------------*/
156
158
160{
161 p_resume_run = f;
162}
163
164INT resume_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
165{
166 if (p_resume_run)
167 return p_resume_run();
168 return CM_SUCCESS;
169}
170
171/*------------------------------------------------------------------*/
172
174
176{
177 p_frontend_loop = f;
178}
179
180/*------------------------------------------------------------------*/
181
183{
184 if (p_frontend_loop)
185 return p_frontend_loop();
186 else
187 ss_sleep(10); // don't eat all CPU
188 return CM_SUCCESS;
189}
INT bm_set_cache_size(INT buffer_handle, size_t read_size, size_t write_size)
Definition midas.cxx:8148
#define CM_SUCCESS
Definition midas.h:582
#define MERROR
Definition midas.h:559
INT ss_sleep(INT millisec)
Definition system.cxx:3628
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
void ** info
Definition fesimdaq.cxx:41
double count
Definition mdump.cxx:33
INT i
Definition mdump.cxx:32
int gWriteCacheSize
Definition mfe.cxx:41
BOOL frontend_call_loop
Definition mfed.cxx:24
INT begin_of_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
Definition mfed.cxx:116
void install_begin_of_run(INT(*f)())
Definition mfed.cxx:111
INT max_event_size
Definition mfed.cxx:30
INT frontend_exit()
Frontend exit.
Definition mfed.cxx:100
INT(* p_begin_of_run)()
Definition mfed.cxx:109
void set_max_event_size(int size)
Definition mfed.cxx:40
INT poll_event(__attribute__((unused)) INT source, __attribute__((unused)) INT count, __attribute__((unused)) BOOL test)
Definition mfed.cxx:60
INT(* p_frontend_loop)()
Definition mfed.cxx:173
INT event_buffer_size
Definition mfed.cxx:36
INT max_event_size_frag
Definition mfed.cxx:33
INT interrupt_configure(__attribute__((unused)) INT cmd, __attribute__((unused)) INT source, __attribute__((unused)) PTYPE adr)
Definition mfed.cxx:67
INT(* p_resume_run)()
Definition mfed.cxx:157
INT(* p_pause_run)()
Definition mfed.cxx:141
void set_event_buffer_size(int size)
Definition mfed.cxx:46
void install_resume_run(INT(*f)())
Definition mfed.cxx:159
void install_pause_run(INT(*f)())
Definition mfed.cxx:143
INT(* p_end_of_run)()
Definition mfed.cxx:125
INT(* p_poll_event)(INT, INT, BOOL)
Definition mfed.cxx:53
void install_frontend_exit(INT(*f)())
Definition mfed.cxx:95
INT display_period
Definition mfed.cxx:27
INT(* p_frontend_exit)()
Definition mfed.cxx:93
INT end_of_run(__attribute__((unused)) INT rn, __attribute__((unused)) char *error)
Definition mfed.cxx:132
void install_end_of_run(INT(*f)())
Definition mfed.cxx:127
INT frontend_loop()
Frontend loop.
Definition mfed.cxx:182
INT set_cache_size(std::string buffer, int size)
Definition mfed.cxx:74
void install_poll_event(INT(*f)(INT, INT, BOOL))
Definition mfed.cxx:55
void install_frontend_loop(INT(*f)())
Definition mfed.cxx:175
DWORD BOOL
Definition midas.h:105
int INT
Definition midas.h:129
#define MIN_WRITE_CACHE_SIZE
Definition midas.h:257
#define PTYPE
Definition midas.h:170
#define TRUE
Definition midas.h:182
#define resume_run
#define pause_run
#define equipment(name, id, type, source, readon, period, readout, cd, driver)
Definition midas_macro.h:60
program test
Definition miniana.f:6
INT rn
Definition mstat.cxx:30
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24