40 static char*
sLastFilled =
"/Equipment/Germanium/Settings/AlarmCheck/LastFilled";
41 static char*
sJustFilled =
"/Equipment/Germanium/Settings/AlarmCheck/JustFilled";
42 static char*
sTimeLimit =
"/Equipment/Germanium/Settings/AlarmCheck/TimeLimit";
52 {
"LN2F", TID_DWORD, 1, NULL },
112 BOOL default_justfilled =
FALSE;
113 DWORD default_lastfilled = 0;
114 DWORD default_timelimit = 28000;
117 status = cm_get_experiment_database(&
hDB, NULL);
118 if (status != CM_SUCCESS) {
119 printf(
"Warning: Could not connect to ODB database!\n");
124 if (status == DB_NO_KEY) {
127 status = db_set_value(
hDB, 0,
sLastFilled, &default_lastfilled,
sizeof(default_lastfilled), 1, TID_DWORD);
129 if (status != DB_SUCCESS) {
135 if (status == DB_NO_KEY) {
138 status = db_set_value(
hDB, 0,
sJustFilled, &default_justfilled,
sizeof(default_justfilled), 1, TID_BOOL);
140 if (status != DB_SUCCESS) {
146 if (status == DB_NO_KEY) {
149 status = db_set_value(
hDB, 0,
sTimeLimit, &default_timelimit,
sizeof(default_timelimit), 1, TID_DWORD);
151 if (status != DB_SUCCESS) {
233 static DWORD lastfilled, now, timelimit;
234 static BOOL justfilled;
235 static DWORD *timesincefill;
238 timesincefill = NULL;
241 size =
sizeof(lastfilled);
243 if (status != DB_SUCCESS) {
244 cm_msg(MERROR,
"ge_ln2_read",
"Error getting last filled time");
248 size =
sizeof(justfilled);
250 if (status != DB_SUCCESS) {
251 cm_msg(MERROR,
"ge_ln2_read",
"Error getting just filled status");
255 size =
sizeof(timelimit);
257 if (status != DB_SUCCESS) {
258 cm_msg(MERROR,
"ge_ln2_read",
"Error getting time limit between fills");
263 if (justfilled ==
TRUE) {
265 status = db_set_value(
hDB, 0,
sLastFilled, &lastfilled,
sizeof(lastfilled), 1, TID_DWORD);
266 if (status != DB_SUCCESS) {
267 cm_msg(MERROR,
"gn_ln2_read",
"Error setting last filled time");
271 status = db_set_value(
hDB, 0,
sJustFilled, &justfilled,
sizeof(justfilled), 1, TID_BOOL);
272 if (status != DB_SUCCESS) {
273 cm_msg(MERROR,
"gn_ln2_read",
"Error setting just filled status");
279 bk_create(pevent,
"LN2F", TID_DWORD, ×incefill);
281 bk_close(pevent, ++timesincefill);
283 return bk_size(pevent);
287 bk_create(pevent,
"LN2F", TID_DWORD, ×incefill);
289 *timesincefill = now - lastfilled;
290 if (*timesincefill > timelimit) {
291 al_trigger_alarm(
sAlarmName,
"Germanium must be filled!",
"Alarm",
"", AT_INTERNAL);
294 bk_close(pevent, ++timesincefill);
296 return bk_size(pevent);