AlcapDAQ
1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
slowcontrol
temperature_probe
frontend.c
Go to the documentation of this file.
1
/********************************************************************\
2
3
Name: frontend.c
4
Created by: Stefan Ritt
5
6
Contents: Example Slow Control Frontend program. Defines two
7
slow control equipments, one for a HV device and one
8
for a multimeter (usually a general purpose PC plug-in
9
card with A/D inputs/outputs. As a device driver,
10
the "null" driver is used which simulates a device
11
without accessing any hardware. The used class drivers
12
cd_hv and cd_multi act as a link between the ODB and
13
the equipment and contain some functionality like
14
ramping etc. To form a fully functional frontend,
15
the device driver "null" has to be replaces with
16
real device drivers.
17
18
19
$Log: frontend.c,v $
20
Revision 1.1.1.1 2004/10/20 18:41:18 admin
21
Trying again to import midas-1.9.5. There are NT executables, but I'm importing them as well (w/o -kb switch so watch out!)
22
23
Revision 1.11 2004/01/08 08:40:09 midas
24
Implemented standard indentation
25
26
Revision 1.10 2002/06/10 07:15:17 midas
27
Use new DF_xxx flags
28
29
Revision 1.9 2002/05/29 13:35:47 midas
30
Added max_event_size_frag
31
32
Revision 1.8 2002/05/13 22:21:08 midas
33
Fixed typo
34
35
Revision 1.7 2002/03/13 08:39:28 midas
36
Use bus drivers in examples
37
38
Revision 1.6 2000/08/21 10:49:11 midas
39
Added max_event_size
40
41
Revision 1.5 2000/03/02 22:00:47 midas
42
Added number of subevents in equipment list
43
44
Revision 1.4 1999/12/21 09:38:23 midas
45
Use new driver names
46
47
Revision 1.3 1998/10/23 08:46:26 midas
48
Added #include "null.h"
49
50
Revision 1.2 1998/10/12 12:18:59 midas
51
Added Log tag in header
52
53
54
\********************************************************************/
55
56
#include <stdio.h>
57
#include "midas.h"
58
//#include "class/hv.h"
59
//#include "class/multi.h"
60
//#include "device/nulldev.h"
61
//#include "bus/null.h"
62
63
/* make frontend functions callable from the C framework */
64
#ifdef __cplusplus
65
extern
"C"
{
66
#endif
67
68
INT
crate_number
=0;
69
70
HNDLE
hDB
;
71
HNDLE
hKey
;
72
int
size
;
73
int
sepDemand
;
74
char
Alarm
[128] =
"/Equipment/TemperatureMonitor/Variables/Alarm_Triggered"
;
75
76
INT
read_temperature_probe
(
char
*pevent, INT off);
77
INT
pre_begin_of_run
();
78
INT
frontend_early_init
();
79
80
/*-- Globals -------------------------------------------------------*/
81
82
/* The frontend name (client name) as seen by other MIDAS clients */
83
char
*
frontend_name
=
"TemperatureMonitor"
;
84
/* The frontend file name, don't change it */
85
char
*
frontend_file_name
= __FILE__;
86
87
/* frontend_loop is called periodically if this variable is TRUE */
88
BOOL
frontend_call_loop
=
TRUE
;
89
90
/* a frontend status page is displayed with this frequency in ms */
91
INT
display_period
= 1000;
92
93
/* maximum event size produced by this frontend */
94
INT
max_event_size
= 10000;
95
96
/* maximum event size for fragmented events (EQ_FRAGMENTED) */
97
INT
max_event_size_frag
= 5 * 1024 * 1024;
98
99
/* buffer size to hold events */
100
INT
event_buffer_size
= 10 * 10000;
101
102
/*-- Equipment list ------------------------------------------------*/
103
104
BANK_LIST
temperature_bank_list
[] = {
105
{
"TMP1"
, TID_FLOAT, 1, NULL },
106
{
""
},
107
};
108
109
#undef USE_INT
110
111
EQUIPMENT
equipment
[] = {
112
{
"TemperatureMonitor"
,
/* equipment name */
113
{ 23, 0,
/* event ID, trigger mask */
114
"SYSTEM"
,
/* event buffer */
115
EQ_PERIODIC,
/* equipment type */
116
0,
/* event source */
117
"MIDAS"
,
/* format */
118
TRUE
,
/* enabled */
119
RO_ALWAYS|RO_ODB,
/* read all the time */
120
10000,
/* reads spaced by this many ms */
121
0,
/* stop run after this event limit */
122
0,
/* number of sub events */
123
0,
/* log history every event */
124
""
,
""
,
""
, },
125
read_temperature_probe
,
/* readout routine */
126
NULL, NULL,
127
temperature_bank_list
,
128
},
129
130
{
""
}
131
};
132
133
134
#ifdef __cplusplus
135
}
136
#endif
137
138
/*-- Dummy routines ------------------------------------------------*/
139
140
INT
frontend_early_init
()
141
{
142
return
CM_SUCCESS;
143
}
144
145
INT
pre_begin_of_run
()
146
{
147
return
CM_SUCCESS;
148
}
149
150
INT
poll_event
(INT source[], INT
count
, BOOL test)
151
{
152
return
1;
153
};
154
INT
interrupt_configure
(INT cmd, INT source[], PTYPE adr)
155
{
156
return
1;
157
};
158
159
/*-- Frontend Init -------------------------------------------------*/
160
161
INT
frontend_init
()
162
{
163
164
// get the LabView filename
165
cm_get_experiment_database(&
hDB
, NULL);
166
167
if
(db_find_key(
hDB
, 0,
Alarm
, &
hKey
) !=
SUCCESS
){
168
db_create_key(
hDB
,0,
Alarm
,TID_INT);
169
}
170
171
return
CM_SUCCESS;
172
}
173
174
/*-- Frontend Exit -------------------------------------------------*/
175
176
INT
frontend_exit
()
177
{
178
return
CM_SUCCESS;
179
}
180
181
/*-- Frontend Loop -------------------------------------------------*/
182
183
INT
frontend_loop
()
184
{
185
ss_sleep(100);
186
return
CM_SUCCESS;
187
}
188
189
/*-- Begin of Run --------------------------------------------------*/
190
191
INT
begin_of_run
(INT
run_number
,
char
*error)
192
{
193
return
CM_SUCCESS;
194
}
195
196
/*-- End of Run ----------------------------------------------------*/
197
198
INT
end_of_run
(INT
run_number
,
char
*error)
199
{
200
return
CM_SUCCESS;
201
}
202
203
/*-- Pause Run -----------------------------------------------------*/
204
205
INT
pause_run
(INT
run_number
,
char
*error)
206
{
207
return
CM_SUCCESS;
208
}
209
210
/*-- Resuem Run ----------------------------------------------------*/
211
212
INT
resume_run
(INT
run_number
,
char
*error)
213
{
214
return
CM_SUCCESS;
215
}
216
217
/*------------------------------------------------------------------*/
218
219
INT
read_temperature_probe
(
char
*pevent, INT off){
220
//
221
// static char oldtimestamp[80];
222
// char timestamp[80];
223
// char timestring[80];
224
// FILE *infile=NULL;
225
float
*pdata;
226
// static float lastHVs[4] = {-1., -1., -1., -1.};
227
// static int initDone = 0;
228
// int i;
229
//
230
// size = sizeof(sepDemand);
231
// db_get_value(hDB,0, "/Experiment/Edit on start/Temperature HV",
232
// &sepDemand, &size, TID_INT, 1);
233
//
234
// timestamp[0]='\0';
235
//
236
// infile=fopen("/tmp/temperature.txt","r");
237
// if (infile==NULL){
238
// cm_msg(MERROR,frontend_name,
239
// "Could not open tempfile. temperature_daemon.pl not running?");
240
// temperature_data.hv =-1;
241
// temperature_data.vac =-1;
242
// temperature_data.sep_stat =-1;
243
// }
244
// else{
245
// fscanf(infile,"%s\n%f\n%f\n%f\n%f",timestamp,&temperature_data.hv,
246
// &temperature_data.current,&temperature_data.vac,
247
// &temperature_data.sep_stat);
248
// fclose(infile);
249
//
250
// if(!strcmp(oldtimestamp, timestamp)){
251
// temperature_data.hv=-1;
252
// temperature_data.vac=-1;
253
// temperature_data.sep_stat=-1;
254
// }
255
// }
256
//
257
// if(initDone == 0){
258
// for(i=0; i<4; i++) lastHVs[i] = temperature_data.hv;
259
// initDone = 1;
260
// }
261
// else{
262
// for(i=0; i<3; i++) lastHVs[i] = lastHVs[i+1];
263
// lastHVs[3] = temperature_data.hv;
264
// }
265
//
266
// //for(i=0; i<4; i++) printf("HV[%d]=%d\n",i,(int)lastHVs[i]);
267
// //printf("Demand = %d\n", sepDemand);
268
//
269
//Send to midas:
270
bk_init(pevent);
271
//bk_create(pevent,"SEPA",TID_FLOAT,&pdata);
272
//pdata[0] = 1;
273
// pdata[1] = temperature_data.current;
274
// pdata[2] = temperature_data.vac;
275
// pdata[3] = temperature_data.sep_stat;
276
//bk_close(pevent,pdata+0);
277
//
278
// int sepError = 1;
279
//
280
// for(i=0; i<4; i++){
281
// if((int)lastHVs[i] == sepDemand) sepError = 0;
282
// }
283
//
284
// if(sepError==1){
285
// if(strcmp(oldtimestamp, timestamp)){
286
// cm_msg(MERROR,frontend_name,"Temperature high voltage not same as demand!");
287
// printf("Demand = %d", sepDemand);
288
// }
289
// else{
290
// cm_msg(MERROR,frontend_name,"Old and new timestamps identical."
291
// " Refresh too high or temperature_daemon.pl not running.");
292
// }
293
// int on = 1;
294
// db_set_value(hDB, 0, Alarm, &on, sizeof(on), 1, TID_INT);
295
// }
296
// else{
297
// int off = 0;
298
// db_set_value(hDB, 0, Alarm, &off, sizeof(off), 1, TID_INT);
299
// }
300
//
301
// strcpy(oldtimestamp,timestamp);
302
//
303
// return bk_size(pevent);
304
//
305
static
int
count
=0;
306
printf
(
"hello from temperature probe %d\n"
, count++);
307
return
1;
308
}
Generated by
1.8.4