Low-Energy Muon (LEM) Experiment  0.5.1
sep61vac.c
Go to the documentation of this file.
1 /*---------------------------------------------------------------------
2 
3  Name: sep61vac.c
4  Created by: Andreas Suter 2008/03/07
5 
6  Contents: sep61 vacuum controller; ps63 is the pumping station of
7  the sep61
8 
9 ---------------------------------------------------------------------*/
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <stdarg.h>
15 #include <math.h>
16 
17 #include "sep61vac.h"
18 
19 #define SEP61VAC_READ_TIME_CONST 7
20 #define SEP61VAC_TIMEOUT_ERROR 3600
21 #define SEP61VAC_REQ_SIZE 16
22 #define SEP61VAC_SPS_MAX_BYTES 840
23 #define SEP61VAC_SPS_MAX_OBJ 25
24 
25 typedef struct {
29 
31 #define SEP61VAC_INTERN_STR "\
32 Detailed Messages = INT : 0\n\
33 "
34 typedef struct {
36  char name[SEP61VAC_VARS][NAME_LENGTH];
38 
40 #define SEP61VAC_NAMES_STR "\
41 Input Names = STRING[11] : \n\
42 [32] SEP61VAC Life Sign\n\
43 [32] SEP61VAC GP Pirani\n\
44 [32] SEP61VAC GS63\n\
45 [32] SEP61VAC GFE\n\
46 [32] SEP61VAC GFA\n\
47 [32] SEP61VAC Status Word 1\n\
48 [32] SEP61VAC Status Word 2\n\
49 [32] SEP61VAC VSDE Status Word\n\
50 [32] SEP61VAC VSDA Status Word\n\
51 [32] SEP61VAC GTS63 Status Word\n\
52 [32] SEP61VAC GIS63 Status Word\n\
53 "
54 
56 typedef struct {
57  char obj[10];
58  short subtype;
59  short offset;
61 
63 typedef struct {
64  short testnumber;
65  char teststring[4];
67  short generaltype;
68  short lifesign;
69  short res_12;
70  short res_14;
71  short res_16;
72  short res_18;
73  short no_of_objects;
74  SEP61VAC_Vac_Labels label[25];
75  char unused_1[128];
76  short ps60_statusword[4];
77  short ps60_gp;
78  short ps60_aw2;
79  short ps60_aw3;
80  short ps60_aw4;
81  short ps60_cmdword;
82  short unused_2;
83  short ps61_statusword[4];
84  short ps61_gp;
85  short ps61_aw2;
86  short ps61_aw3;
87  short ps61_aw4;
88  short ps61_cmdword;
89  short unused_3;
90  short ps62_statusword[4];
91  short ps62_gp;
92  short ps62_aw2;
93  short ps62_aw3;
94  short ps62_aw4;
95  short ps62_cmdword;
96  short unused_4;
97  short ps63_statusword[4];
98  short ps63_gp;
99  short ps63_gfe;
100  short ps63_gfa;
101  short ps63_aw4;
102  short ps63_cmdword;
103  short unused_5;
104  short ps64_statusword[4];
105  short ps64_gp;
106  short ps64_aw2;
107  short ps64_aw3;
108  short ps64_aw4;
109  short ps64_cmdword;
110  short unused_6;
111  short ps65_statusword[4];
112  short ps65_gp;
113  short ps65_aw2;
114  short ps65_aw3;
115  short ps65_aw4;
116  short ps65_cmdword;
117  short unused_7;
118  short ps66_statusword[4];
119  short ps66_gp;
120  short ps66_aw2;
121  short ps66_aw3;
122  short ps66_aw4;
123  short ps66_cmdword;
124  short unused_8;
125  short ps67_statusword[4];
126  short ps67_gp;
127  short ps67_aw2;
128  short ps67_aw3;
129  short ps67_aw4;
130  short ps67_cmdword;
131  short unused_9;
132  short psz_statusword[4];
133  short psz_gv1;
134  short psz_gv2;
135  short psz_aw3;
136  short psz_aw4;
137  short psz_cmdword;
138  short unused_10;
141  short gts60_value;
142  short gis60_value;
143  short unused_11;
146  short gts61_value;
147  short gis61_value;
148  short unused_12;
151  short gts62_value;
152  short gis62_value;
153  short unused_13;
156  short gts63_value;
157  short gis63_value;
158  short unused_14;
161  short gts64_value;
162  short gis64_value;
163  short unused_15;
166  short gts65_value;
167  short gis65_value;
168  short unused_16;
171  short gts66_value;
172  short gis66_value;
173  short unused_17;
176  short gts67_value;
177  short gis67_value;
178  short unused_18;
179  short vsd60_statusword[2];
181  DWORD unused_19;
182  short vsd61_statusword[2];
184  DWORD unused_20;
185  short vsd62_statusword[2];
187  DWORD unused_21;
188  short vsd63_statusword[2];
190  DWORD unused_22;
191  short vsd64_statusword[2];
193  DWORD unused_23;
194  short vsd65_statusword[2];
196  DWORD unused_24;
197  short vsd66_statusword[2];
199  DWORD unused_25;
200  short vsd67_statusword[2];
202  DWORD unused_26;
203 } SEP61VAC_DB50;
204 
206 #define SEP61VAC_DB50_STR "\
207 testnumber = SHORT : 0\n\
208 teststring = CHAR[4] : \n\
209 "" \n\
210 telegramlength = SHORT : 0\n\
211 generaltype = SHORT : 0\n\
212 lifesign = SHORT : 0\n\
213 res_12 = SHORT : 0\n\
214 res_14 = SHORT : 0\n\
215 res_16 = SHORT : 0\n\
216 res_18 = SHORT : 0\n\
217 no_of_objects = SHORT : 0\n\
218 obj1 = CHAR[10] : \n\
219 ""\n\
220 subtype1 = SHORT : 0\n\
221 offset1 = SHORT : 0\n\
222 obj2 = CHAR[10] : \n\
223 ""\n\
224 subtype2 = SHORT : 0\n\
225 offset2 = SHORT : 0\n\
226 obj3 = CHAR[10] : \n\
227 ""\n\
228 subtype3 = SHORT : 0\n\
229 offset3 = SHORT : 0\n\
230 obj4 = CHAR[10] : \n\
231 ""\n\
232 subtype4 = SHORT : 0\n\
233 offset4 = SHORT : 0\n\
234 obj5 = CHAR[10] : \n\
235 ""\n\
236 subtype5 = SHORT : 0\n\
237 offset5 = SHORT : 0\n\
238 obj6 = CHAR[10] : \n\
239 ""\n\
240 subtype6 = SHORT : 0\n\
241 offset6 = SHORT : 0\n\
242 obj7 = CHAR[10] : \n\
243 ""\n\
244 subtype7 = SHORT : 0\n\
245 offset7 = SHORT : 0\n\
246 obj8 = CHAR[10] : \n\
247 ""\n\
248 subtype8 = SHORT : 0\n\
249 offset8 = SHORT : 0\n\
250 obj9 = CHAR[10] : \n\
251 ""\n\
252 subtype9 = SHORT : 0\n\
253 offset9 = SHORT : 0\n\
254 obj10 = CHAR[10] : \n\
255 ""\n\
256 subtype10 = SHORT : 0\n\
257 offset10 = SHORT : 0\n\
258 obj11 = CHAR[10] : \n\
259 ""\n\
260 subtype11 = SHORT : 0\n\
261 offset11 = SHORT : 0\n\
262 obj12 = CHAR[10] : \n\
263 ""\n\
264 subtype12 = SHORT : 0\n\
265 offset12 = SHORT : 0\n\
266 obj13 = CHAR[10] : \n\
267 ""\n\
268 subtype13 = SHORT : 0\n\
269 offset13 = SHORT : 0\n\
270 obj14 = CHAR[10] : \n\
271 ""\n\
272 subtype14 = SHORT : 0\n\
273 offset14 = SHORT : 0\n\
274 obj15 = CHAR[10] : \n\
275 ""\n\
276 subtype15 = SHORT : 0\n\
277 offset15 = SHORT : 0\n\
278 obj16 = CHAR[10] : \n\
279 ""\n\
280 subtype16 = SHORT : 0\n\
281 offset16 = SHORT : 0\n\
282 obj17 = CHAR[10] : \n\
283 ""\n\
284 subtype17 = SHORT : 0\n\
285 offset17 = SHORT : 0\n\
286 obj18 = CHAR[10] : \n\
287 ""\n\
288 subtype18 = SHORT : 0\n\
289 offset18 = SHORT : 0\n\
290 obj19 = CHAR[10] : \n\
291 ""\n\
292 subtype19 = SHORT : 0\n\
293 offset19 = SHORT : 0\n\
294 obj20 = CHAR[10] : \n\
295 ""\n\
296 subtype20 = SHORT : 0\n\
297 offset20 = SHORT : 0\n\
298 obj21 = CHAR[10] : \n\
299 ""\n\
300 subtype21 = SHORT : 0\n\
301 offset21 = SHORT : 0\n\
302 obj22 = CHAR[10] : \n\
303 ""\n\
304 subtype22 = SHORT : 0\n\
305 offset22 = SHORT : 0\n\
306 obj23 = CHAR[10] : \n\
307 ""\n\
308 subtype23 = SHORT : 0\n\
309 offset23 = SHORT : 0\n\
310 obj24 = CHAR[10] : \n\
311 ""\n\
312 subtype24 = SHORT : 0\n\
313 offset24 = SHORT : 0\n\
314 obj25 = CHAR[10] : \n\
315 ""\n\
316 subtype25 = SHORT : 0\n\
317 offset25 = SHORT : 0\n\
318 unused_1 = CHAR[128] : \n\
319 ""\n\
320 ps60_statusword = SHORT[4] :\n\
321 0\n\
322 0\n\
323 0\n\
324 0\n\
325 ps60_gp = SHORT : 0\n\
326 ps60_aw2 = SHORT : 0\n\
327 ps60_aw3 = SHORT : 0\n\
328 ps60_aw4 = SHORT : 0\n\
329 ps60_cmdword = SHORT : 0\n\
330 unused_2 = SHORT : 0\n\
331 ps61_statusword = SHORT[4] :\n\
332 0\n\
333 0\n\
334 0\n\
335 0\n\
336 ps61_gp = SHORT : 0\n\
337 ps61_aw2 = SHORT : 0\n\
338 ps61_aw3 = SHORT : 0\n\
339 ps61_aw4 = SHORT : 0\n\
340 ps61_cmdword = SHORT : 0\n\
341 unused_3 = SHORT : 0\n\
342 ps62_statusword = SHORT[4] :\n\
343 0\n\
344 0\n\
345 0\n\
346 0\n\
347 ps62_gp = SHORT : 0\n\
348 ps62_aw2 = SHORT : 0\n\
349 ps62_aw3 = SHORT : 0\n\
350 ps62_aw4 = SHORT : 0\n\
351 ps62_cmdword = SHORT : 0\n\
352 unused_4 = SHORT : 0\n\
353 ps63_statusword = SHORT[4] :\n\
354 0\n\
355 0\n\
356 0\n\
357 0\n\
358 ps63_gp = SHORT : 0\n\
359 ps63_gfe = SHORT : 0\n\
360 ps63_gfa = SHORT : 0\n\
361 ps63_aw4 = SHORT : 0\n\
362 ps63_cmdword = SHORT : 0\n\
363 unused_5 = SHORT : 0\n\
364 ps64_statusword = SHORT[4] :\n\
365 0\n\
366 0\n\
367 0\n\
368 0\n\
369 ps64_gp = SHORT : 0\n\
370 ps64_aw2 = SHORT : 0\n\
371 ps64_aw3 = SHORT : 0\n\
372 ps64_aw4 = SHORT : 0\n\
373 ps64_cmdword = SHORT : 0\n\
374 unused_6 = SHORT : 0\n\
375 ps65_statusword = SHORT[4] :\n\
376 0\n\
377 0\n\
378 0\n\
379 0\n\
380 ps65_gp = SHORT : 0\n\
381 ps65_aw2 = SHORT : 0\n\
382 ps65_aw3 = SHORT : 0\n\
383 ps65_aw4 = SHORT : 0\n\
384 ps65_cmdword = SHORT : 0\n\
385 unused_7 = SHORT : 0\n\
386 ps66_statusword = SHORT[4] :\n\
387 0\n\
388 0\n\
389 0\n\
390 0\n\
391 ps66_gp = SHORT : 0\n\
392 ps66_aw2 = SHORT : 0\n\
393 ps66_aw3 = SHORT : 0\n\
394 ps66_aw4 = SHORT : 0\n\
395 ps66_cmdword = SHORT : 0\n\
396 unused_8 = SHORT : 0\n\
397 ps67_statusword = SHORT[4] :\n\
398 0\n\
399 0\n\
400 0\n\
401 0\n\
402 ps67_gp = SHORT : 0\n\
403 ps67_aw2 = SHORT : 0\n\
404 ps67_aw3 = SHORT : 0\n\
405 ps67_aw4 = SHORT : 0\n\
406 ps67_cmdword = SHORT : 0\n\
407 unused_9 = SHORT : 0\n\
408 pz_statusword = SHORT[4] :\n\
409 0\n\
410 0\n\
411 0\n\
412 0\n\
413 pz_gv1 = SHORT : 0\n\
414 pz_gv2 = SHORT : 0\n\
415 pz_aw3 = SHORT : 0\n\
416 pz_aw4 = SHORT : 0\n\
417 pz_cmdword = SHORT : 0\n\
418 unused_10 = SHORT : 0\n\
419 gts60_statusword = SHORT : 0\n\
420 gis60_statusword = SHORT : 0\n\
421 gts60_value = SHORT : 0\n\
422 gis60_value = SHORT : 0\n\
423 unused_11 = SHORT : 0\n\
424 gts61_statusword = SHORT : 0\n\
425 gis61_statusword = SHORT : 0\n\
426 gts61_value = SHORT : 0\n\
427 gis61_value = SHORT : 0\n\
428 unused_12 = SHORT : 0\n\
429 gts62_statusword = SHORT : 0\n\
430 gis62_statusword = SHORT : 0\n\
431 gts62_value = SHORT : 0\n\
432 gis62_value = SHORT : 0\n\
433 unused_13 = SHORT : 0\n\
434 gts63_statusword = SHORT : 0\n\
435 gis63_statusword = SHORT : 0\n\
436 gts63_value = SHORT : 0\n\
437 gis63_value = SHORT : 0\n\
438 unused_14 = SHORT : 0\n\
439 gts64_statusword = SHORT : 0\n\
440 gis64_statusword = SHORT : 0\n\
441 gts64_value = SHORT : 0\n\
442 gis64_value = SHORT : 0\n\
443 unused_15 = SHORT : 0\n\
444 gts65_statusword = SHORT : 0\n\
445 gis65_statusword = SHORT : 0\n\
446 gts65_value = SHORT : 0\n\
447 gis65_value = SHORT : 0\n\
448 unused_16 = SHORT : 0\n\
449 gts66_statusword = SHORT : 0\n\
450 gis66_statusword = SHORT : 0\n\
451 gts66_value = SHORT : 0\n\
452 gis66_value = SHORT : 0\n\
453 unused_17 = SHORT : 0\n\
454 gts67_statusword = SHORT : 0\n\
455 gis67_statusword = SHORT : 0\n\
456 gts67_value = SHORT : 0\n\
457 gis67_value = SHORT : 0\n\
458 unused_18 = SHORT : 0\n\
459 vsd60_statusword = SHORT[2] :\n\
460 0\n\
461 0\n\
462 vsd60_cmdword = SHORT : 0\n\
463 unused_19 = DWORD : 0\n\
464 vsd61_statusword = SHORT[2] :\n\
465 0\n\
466 0\n\
467 vsd61_cmdword = SHORT : 0\n\
468 unused_20 = DWORD : 0\n\
469 vsd62_statusword = SHORT[2] :\n\
470 0\n\
471 0\n\
472 vsd62_cmdword = SHORT : 0\n\
473 unused_21 = DWORD : 0\n\
474 vsd63_statusword = SHORT[2] :\n\
475 0\n\
476 0\n\
477 vsd63_cmdword = SHORT : 0\n\
478 unused_22 = DWORD : 0\n\
479 vsd64_statusword = SHORT[2] :\n\
480 0\n\
481 0\n\
482 vsd64_cmdword = SHORT : 0\n\
483 unused_23 = DWORD : 0\n\
484 vsd65_statusword = SHORT[2] :\n\
485 0\n\
486 0\n\
487 vsd65_cmdword = SHORT : 0\n\
488 unused_24 = DWORD : 0\n\
489 vsd66_statusword = SHORT[2] :\n\
490 0\n\
491 0\n\
492 vsd66_cmdword = SHORT : 0\n\
493 unused_25 = DWORD : 0\n\
494 vsd67_statusword = SHORT[2] :\n\
495 0\n\
496 0\n\
497 vsd67_cmdword = SHORT : 0\n\
498 unused_26 = DWORD : 0\n\
499 "
500 
502 typedef struct {
506  char sep61vac_db50_buffer[SEP61VAC_SPS_MAX_BYTES];
507  float sep61vac_data[SEP61VAC_VARS];
508  HNDLE hDB;
509  HNDLE hKeyDD;
510  HNDLE hKeyDB50;
512  INT (*bd)(INT cmd, ...);
513  void *bd_info;
514  DWORD read_timer;
515  DWORD errTime;
519 } SEP61VAC_INFO;
520 
522 
523 /*---- support routines ------------------------------------------------*/
524 
525 /*----------------------------------------------------------------------------*/
535 double sep61vac_pkr251(int analog)
536 {
537  return pow(10.0, 1.667 * (double)analog/100.0 - 11.33);
538 }
539 
540 /*----------------------------------------------------------------------------*/
549 double sep61vac_pirani_tpr280(int analog)
550 {
551  return pow(10.0, (double)analog/100.0 - 5.5);
552 }
553 
554 /*----------------------------------------------------------------------------*/
562 short sep61vac_spsToNumber(unsigned char *buffer)
563 {
564  int val = 0;
565 
566  if (buffer[0] & 0x80)
567  val = (buffer[0] &0x7f) << 8;
568  else
569  val = buffer[0] << 8;
570 
571  if (buffer[1] & 0x80) // sign bit set
572  val += (buffer[1] &0x7f) + 128;
573  else
574  val += buffer[1];
575 
576  return val;
577 }
578 
579 /*----------------------------------------------------------------------------*/
587 int sep61vac_spsToWord(unsigned char *buffer)
588 {
589  short val = buffer[0];
590  val = val << 8;
591  val += buffer[1];
592  return val;
593 }
594 
595 /*----------------------------------------------------------------------------*/
605 {
606  int i, j;
607 
608  // testnumber
609  info->sep61vac_db50.testnumber = sep61vac_spsToNumber((unsigned char*)&buffer[0]);
610  // teststring
611  memset(info->sep61vac_db50.teststring, 0, sizeof(info->sep61vac_db50.teststring));
612  sprintf(info->sep61vac_db50.teststring, "%c%c", buffer[4], buffer[5]);
613  if (strcmp(info->sep61vac_db50.teststring, "AB")) {
614  return 1; // error
615  }
616  // telegram length
617  info->sep61vac_db50.telegramlength = sep61vac_spsToNumber((unsigned char*)&buffer[6]);
619  return 1; // error
620  }
621  // general type
622  info->sep61vac_db50.generaltype = sep61vac_spsToNumber((unsigned char*)&buffer[8]);
623  // life sign tag
624  info->sep61vac_db50.lifesign = sep61vac_spsToNumber((unsigned char*)&buffer[10]);
625  // some for the future reserved stuff
626  info->sep61vac_db50.res_12 = sep61vac_spsToNumber((unsigned char*)&buffer[12]);
627  info->sep61vac_db50.res_14 = sep61vac_spsToNumber((unsigned char*)&buffer[14]);
628  info->sep61vac_db50.res_16 = sep61vac_spsToNumber((unsigned char*)&buffer[16]);
629  info->sep61vac_db50.res_18 = sep61vac_spsToNumber((unsigned char*)&buffer[18]);
630  // number of objects
631  info->sep61vac_db50.no_of_objects = sep61vac_spsToNumber((unsigned char*)&buffer[20]);
632  if (info->sep61vac_db50.no_of_objects != SEP61VAC_SPS_MAX_OBJ) { // error check
633  return 1; // error
634  }
635  // get object identifications
636  for (j=0; j<info->sep61vac_db50.no_of_objects; j++) {
637  for (i=0; i<8; i++)
638  info->sep61vac_db50.label[j].obj[i] = buffer[j*14+22+i];
639  info->sep61vac_db50.label[j].obj[8] = '\0';
640  // get object 1 subtype
641  info->sep61vac_db50.label[j].subtype = sep61vac_spsToNumber((unsigned char*)&buffer[j*14+32]);
642  // get object 1 offset
643  info->sep61vac_db50.label[j].offset = sep61vac_spsToNumber((unsigned char*)&buffer[j*14+34]);
644  }
645 
646  // unused_1
647  strncpy(info->sep61vac_db50.unused_1, &buffer[372], 126);
648 
649  // get ps60 status words-----------------------------------------------------------
650  for (i=0; i<4; i++) {
651  info->sep61vac_db50.ps60_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+500]);
652  }
653  // analog value Piranni buffer volume
654  info->sep61vac_db50.ps60_gp = sep61vac_spsToNumber((unsigned char*)&buffer[508]);
655  // analog value reserve
656  info->sep61vac_db50.ps60_aw2 = sep61vac_spsToNumber((unsigned char*)&buffer[510]);
657  // analog value reserve
658  info->sep61vac_db50.ps60_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[512]);
659  // analog value reserve
660  info->sep61vac_db50.ps60_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[514]);
661  // command word ps60
662  info->sep61vac_db50.ps60_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[516]);
663  // unused_2
664  info->sep61vac_db50.unused_2 = sep61vac_spsToWord((unsigned char*)&buffer[518]);
665 
666  // get ps61 status words-----------------------------------------------------------
667  for (i=0; i<4; i++) {
668  info->sep61vac_db50.ps61_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+520]);
669  }
670  // analog value Piranni buffer volume
671  info->sep61vac_db50.ps61_gp = sep61vac_spsToNumber((unsigned char*)&buffer[528]);
672  // analog value reserve
673  info->sep61vac_db50.ps61_aw2 = sep61vac_spsToNumber((unsigned char*)&buffer[530]);
674  // analog value reserve
675  info->sep61vac_db50.ps61_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[532]);
676  // analog value reserve
677  info->sep61vac_db50.ps61_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[534]);
678  // command word ps61
679  info->sep61vac_db50.ps61_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[536]);
680  // unused_3
681  info->sep61vac_db50.unused_3 = sep61vac_spsToWord((unsigned char*)&buffer[538]);
682 
683  // get ps62 status words-----------------------------------------------------------
684  for (i=0; i<4; i++) {
685  info->sep61vac_db50.ps62_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+540]);
686  }
687  // analog value Piranni buffer volume
688  info->sep61vac_db50.ps62_gp = sep61vac_spsToNumber((unsigned char*)&buffer[548]);
689  // analog value reserve
690  info->sep61vac_db50.ps62_aw2 = sep61vac_spsToNumber((unsigned char*)&buffer[550]);
691  // analog value reserve
692  info->sep61vac_db50.ps62_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[552]);
693  // analog value reserve
694  info->sep61vac_db50.ps62_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[554]);
695  // command word ps62
696  info->sep61vac_db50.ps62_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[556]);
697  // unused_4
698  info->sep61vac_db50.unused_4 = sep61vac_spsToWord((unsigned char*)&buffer[558]);
699 
700  // get ps63 status words-----------------------------------------------------------
701  for (i=0; i<4; i++) {
702  info->sep61vac_db50.ps63_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+560]);
703  }
704  // analog value Piranni buffer volume
705  info->sep61vac_db50.ps63_gp = sep61vac_spsToNumber((unsigned char*)&buffer[568]);
706  // analog value Piranni GFE
707  info->sep61vac_db50.ps63_gfe = sep61vac_spsToNumber((unsigned char*)&buffer[570]);
708  // analog value Piranni GFA
709  info->sep61vac_db50.ps63_gfa = sep61vac_spsToNumber((unsigned char*)&buffer[572]);
710  // analog value reserve
711  info->sep61vac_db50.ps63_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[574]);
712  // command word ps63
713  info->sep61vac_db50.ps63_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[576]);
714  // unused_5
715  info->sep61vac_db50.unused_5 = sep61vac_spsToWord((unsigned char*)&buffer[578]);
716 
717  // get ps64 status words-----------------------------------------------------------
718  for (i=0; i<4; i++) {
719  info->sep61vac_db50.ps64_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+580]);
720  }
721  // analog value Piranni buffer volume
722  info->sep61vac_db50.ps64_gp = sep61vac_spsToNumber((unsigned char*)&buffer[588]);
723  // analog value reserve
724  info->sep61vac_db50.ps64_aw2 = sep61vac_spsToNumber((unsigned char*)&buffer[590]);
725  // analog value reserve
726  info->sep61vac_db50.ps64_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[592]);
727  // analog value reserve
728  info->sep61vac_db50.ps64_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[594]);
729  // command word ps64
730  info->sep61vac_db50.ps64_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[596]);
731  // unused_6
732  info->sep61vac_db50.unused_6 = sep61vac_spsToWord((unsigned char*)&buffer[598]);
733 
734  // get ps65 status words-----------------------------------------------------------
735  for (i=0; i<4; i++) {
736  info->sep61vac_db50.ps65_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+600]);
737  }
738  // analog value Piranni buffer volume
739  info->sep61vac_db50.ps65_gp = sep61vac_spsToNumber((unsigned char*)&buffer[608]);
740  // analog value reserve
741  info->sep61vac_db50.ps65_aw2 = sep61vac_spsToNumber((unsigned char*)&buffer[610]);
742  // analog value reserve
743  info->sep61vac_db50.ps65_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[612]);
744  // analog value reserve
745  info->sep61vac_db50.ps65_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[614]);
746  // command word ps65
747  info->sep61vac_db50.ps65_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[616]);
748  // unused_7
749  info->sep61vac_db50.unused_7 = sep61vac_spsToWord((unsigned char*)&buffer[618]);
750 
751  // get ps66 status words-----------------------------------------------------------
752  for (i=0; i<4; i++) {
753  info->sep61vac_db50.ps66_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+620]);
754  }
755  // analog value Piranni buffer volume
756  info->sep61vac_db50.ps66_gp = sep61vac_spsToNumber((unsigned char*)&buffer[628]);
757  // analog value reserve
758  info->sep61vac_db50.ps66_aw2 = sep61vac_spsToNumber((unsigned char*)&buffer[630]);
759  // analog value reserve
760  info->sep61vac_db50.ps66_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[632]);
761  // analog value reserve
762  info->sep61vac_db50.ps66_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[634]);
763  // command word ps66
764  info->sep61vac_db50.ps66_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[636]);
765  // unused_8
766  info->sep61vac_db50.unused_8 = sep61vac_spsToWord((unsigned char*)&buffer[638]);
767 
768  // get ps67 status words-----------------------------------------------------------
769  for (i=0; i<4; i++) {
770  info->sep61vac_db50.ps67_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+640]);
771  }
772  // analog value Piranni buffer volume
773  info->sep61vac_db50.ps67_gp = sep61vac_spsToNumber((unsigned char*)&buffer[648]);
774  // analog value reserve
775  info->sep61vac_db50.ps67_aw2 = sep61vac_spsToNumber((unsigned char*)&buffer[650]);
776  // analog value reserve
777  info->sep61vac_db50.ps67_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[652]);
778  // analog value reserve
779  info->sep61vac_db50.ps67_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[654]);
780  // command word ps67
781  info->sep61vac_db50.ps67_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[656]);
782  // unused_9
783  info->sep61vac_db50.unused_9 = sep61vac_spsToWord((unsigned char*)&buffer[658]);
784 
785  // get psz status words-----------------------------------------------------------
786  for (i=0; i<4; i++) {
787  info->sep61vac_db50.psz_statusword[i] = sep61vac_spsToWord((unsigned char*)&buffer[i*2+660]);
788  }
789  // analog value Piranni buffer volume
790  info->sep61vac_db50.psz_gv1 = sep61vac_spsToNumber((unsigned char*)&buffer[668]);
791  // analog value reserve
792  info->sep61vac_db50.psz_gv2 = sep61vac_spsToNumber((unsigned char*)&buffer[670]);
793  // analog value reserve
794  info->sep61vac_db50.psz_aw3 = sep61vac_spsToNumber((unsigned char*)&buffer[672]);
795  // analog value reserve
796  info->sep61vac_db50.psz_aw4 = sep61vac_spsToNumber((unsigned char*)&buffer[674]);
797  // command word psz
798  info->sep61vac_db50.psz_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[676]);
799  // unused_10
800  info->sep61vac_db50.unused_10 = sep61vac_spsToWord((unsigned char*)&buffer[678]);
801 
802  // get status word from the thermal vacuum gauge of the ps60
803  info->sep61vac_db50.gts60_statusword = sep61vac_spsToWord((unsigned char*)&buffer[680]);
804  // get status word from the ionization vacuum gauge of the ps60
805  info->sep61vac_db50.gis60_statusword = sep61vac_spsToWord((unsigned char*)&buffer[682]);
806  // analog value Piranni of the ps60
807  info->sep61vac_db50.gts60_value = sep61vac_spsToNumber((unsigned char*)&buffer[684]);
808  // analog value Penning of the ps60
809  info->sep61vac_db50.gis60_value = sep61vac_spsToNumber((unsigned char*)&buffer[686]);
810  // unused_11
811  info->sep61vac_db50.unused_11 = sep61vac_spsToWord((unsigned char*)&buffer[688]);
812 
813  // get status word from the thermal vacuum gauge of the ps61
814  info->sep61vac_db50.gts61_statusword = sep61vac_spsToWord((unsigned char*)&buffer[690]);
815  // get status word from the ionization vacuum gauge of the ps61
816  info->sep61vac_db50.gis61_statusword = sep61vac_spsToWord((unsigned char*)&buffer[692]);
817  // analog value Piranni of the ps61
818  info->sep61vac_db50.gts61_value = sep61vac_spsToNumber((unsigned char*)&buffer[694]);
819  // analog value Penning of the ps61
820  info->sep61vac_db50.gis61_value = sep61vac_spsToNumber((unsigned char*)&buffer[696]);
821  // unused_12
822  info->sep61vac_db50.unused_12 = sep61vac_spsToWord((unsigned char*)&buffer[698]);
823 
824  // get status word from the thermal vacuum gauge of the ps62
825  info->sep61vac_db50.gts62_statusword = sep61vac_spsToWord((unsigned char*)&buffer[700]);
826  // get status word from the ionization vacuum gauge of the ps62
827  info->sep61vac_db50.gis62_statusword = sep61vac_spsToWord((unsigned char*)&buffer[702]);
828  // analog value Piranni of the ps62
829  info->sep61vac_db50.gts62_value = sep61vac_spsToNumber((unsigned char*)&buffer[704]);
830  // analog value Penning of the ps62
831  info->sep61vac_db50.gis62_value = sep61vac_spsToNumber((unsigned char*)&buffer[706]);
832  // unused_13
833  info->sep61vac_db50.unused_13 = sep61vac_spsToWord((unsigned char*)&buffer[708]);
834 
835  // get status word from the thermal vacuum gauge of the ps63
836  info->sep61vac_db50.gts63_statusword = sep61vac_spsToWord((unsigned char*)&buffer[710]);
837  // get status word from the ionization vacuum gauge of the ps63
838  info->sep61vac_db50.gis63_statusword = sep61vac_spsToWord((unsigned char*)&buffer[712]);
839  // analog value Piranni of the ps63
840  info->sep61vac_db50.gts63_value = sep61vac_spsToNumber((unsigned char*)&buffer[714]);
841  // analog value Penning of the ps63
842  info->sep61vac_db50.gis63_value = sep61vac_spsToNumber((unsigned char*)&buffer[716]);
843  // unused_14
844  info->sep61vac_db50.unused_14 = sep61vac_spsToWord((unsigned char*)&buffer[718]);
845 
846  // get status word from the thermal vacuum gauge of the ps64
847  info->sep61vac_db50.gts64_statusword = sep61vac_spsToWord((unsigned char*)&buffer[720]);
848  // get status word from the ionization vacuum gauge of the ps64
849  info->sep61vac_db50.gis64_statusword = sep61vac_spsToWord((unsigned char*)&buffer[722]);
850  // analog value Piranni of the ps64
851  info->sep61vac_db50.gts64_value = sep61vac_spsToNumber((unsigned char*)&buffer[724]);
852  // analog value Penning of the ps64
853  info->sep61vac_db50.gis64_value = sep61vac_spsToNumber((unsigned char*)&buffer[726]);
854  // unused_15
855  info->sep61vac_db50.unused_15 = sep61vac_spsToWord((unsigned char*)&buffer[728]);
856 
857  // get status word from the thermal vacuum gauge of the ps65
858  info->sep61vac_db50.gts65_statusword = sep61vac_spsToWord((unsigned char*)&buffer[730]);
859  // get status word from the ionization vacuum gauge of the ps65
860  info->sep61vac_db50.gis65_statusword = sep61vac_spsToWord((unsigned char*)&buffer[732]);
861  // analog value Piranni of the ps65
862  info->sep61vac_db50.gts65_value = sep61vac_spsToNumber((unsigned char*)&buffer[734]);
863  // analog value Penning of the ps65
864  info->sep61vac_db50.gis65_value = sep61vac_spsToNumber((unsigned char*)&buffer[736]);
865  // unused_16
866  info->sep61vac_db50.unused_16 = sep61vac_spsToWord((unsigned char*)&buffer[738]);
867 
868  // get status word from the thermal vacuum gauge of the ps66
869  info->sep61vac_db50.gts66_statusword = sep61vac_spsToWord((unsigned char*)&buffer[740]);
870  // get status word from the ionization vacuum gauge of the ps66
871  info->sep61vac_db50.gis66_statusword = sep61vac_spsToWord((unsigned char*)&buffer[742]);
872  // analog value Piranni of the ps66
873  info->sep61vac_db50.gts66_value = sep61vac_spsToNumber((unsigned char*)&buffer[744]);
874  // analog value Penning of the ps66
875  info->sep61vac_db50.gis66_value = sep61vac_spsToNumber((unsigned char*)&buffer[746]);
876  // unused_17
877  info->sep61vac_db50.unused_17 = sep61vac_spsToWord((unsigned char*)&buffer[748]);
878 
879  // get status word from the thermal vacuum gauge of the ps67
880  info->sep61vac_db50.gts67_statusword = sep61vac_spsToWord((unsigned char*)&buffer[750]);
881  // get status word from the ionization vacuum gauge of the ps67
882  info->sep61vac_db50.gis67_statusword = sep61vac_spsToWord((unsigned char*)&buffer[752]);
883  // analog value Piranni of the ps67
884  info->sep61vac_db50.gts67_value = sep61vac_spsToNumber((unsigned char*)&buffer[754]);
885  // analog value Penning of the ps67
886  info->sep61vac_db50.gis67_value = sep61vac_spsToNumber((unsigned char*)&buffer[756]);
887  // unused_18
888  info->sep61vac_db50.unused_18 = sep61vac_spsToWord((unsigned char*)&buffer[758]);
889 
890  // vsd60
891  info->sep61vac_db50.vsd60_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[760]);
892  info->sep61vac_db50.vsd60_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[762]);
893  info->sep61vac_db50.vsd60_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[764]);
894 
895  // vsd61
896  info->sep61vac_db50.vsd61_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[770]);
897  info->sep61vac_db50.vsd61_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[772]);
898  info->sep61vac_db50.vsd61_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[774]);
899 
900  // vsd62
901  info->sep61vac_db50.vsd62_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[780]);
902  info->sep61vac_db50.vsd62_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[782]);
903  info->sep61vac_db50.vsd62_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[784]);
904 
905  // vsd63
906  info->sep61vac_db50.vsd63_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[790]);
907  info->sep61vac_db50.vsd63_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[792]);
908  info->sep61vac_db50.vsd63_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[794]);
909 
910  // vsd64
911  info->sep61vac_db50.vsd64_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[800]);
912  info->sep61vac_db50.vsd64_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[802]);
913  info->sep61vac_db50.vsd64_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[804]);
914 
915  // vsd65
916  info->sep61vac_db50.vsd65_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[810]);
917  info->sep61vac_db50.vsd65_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[812]);
918  info->sep61vac_db50.vsd65_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[814]);
919 
920  // vsd66
921  info->sep61vac_db50.vsd66_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[820]);
922  info->sep61vac_db50.vsd66_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[822]);
923  info->sep61vac_db50.vsd66_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[824]);
924 
925  // vsd67
926  info->sep61vac_db50.vsd67_statusword[0] = sep61vac_spsToWord((unsigned char*)&buffer[830]);
927  info->sep61vac_db50.vsd67_statusword[1] = sep61vac_spsToWord((unsigned char*)&buffer[832]);
928  info->sep61vac_db50.vsd67_cmdword = sep61vac_spsToWord((unsigned char*)&buffer[834]);
929 
930  return 0;
931 }
932 
933 /*----------------------------------------------------------------------------*/
943 {
944  info->sep61vac_data[0] = info->sep61vac_db50.lifesign;
949  info->sep61vac_data[5] = info->sep61vac_db50.ps63_statusword[0];
950  info->sep61vac_data[6] = info->sep61vac_db50.ps63_statusword[1];
951  info->sep61vac_data[7] = info->sep61vac_db50.vsd62_statusword[0]; // VSDE+VFE
952  info->sep61vac_data[8] = info->sep61vac_db50.vsd63_statusword[0]; // VSDA+VFA
954  info->sep61vac_data[10] = info->sep61vac_db50.gis63_statusword;
955 }
956 
957 /*---- device driver routines ------------------------------------------------*/
958 
959 /*----------------------------------------------------------------------------*/
973 INT sep61vac_init(HNDLE hKey, void **pinfo, INT channels, INT (*bd)(INT cmd, ...))
974 {
975  INT status, size;
976  HNDLE hDB, hkeydd;
977  char str[1024];
978 
979  // allocate info structure
980  gInfo = (SEP61VAC_INFO *)calloc(1, sizeof(SEP61VAC_INFO));
981  *pinfo = gInfo;
982 
983  // get ODB handle
984  cm_get_experiment_database(&hDB, NULL);
985  // store handles (ODB and DD key) in local structure to keep it for latter use
986  gInfo->hDB = hDB;
987  gInfo->hKeyDD = hKey;
988 
989  // create ps64 DD intern record
990  status = db_create_record(hDB, hKey, "DD/Intern", SEP61VAC_INTERN_STR);
991  if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
992  cm_msg(MERROR, "sep61vac_init", "sep61vac_init: Error creating sep61vac Intern record in ODB, status=%d", status);
993  cm_yield(0);
994  return FE_ERR_ODB;
995  }
996 
997  db_find_key(hDB, hKey, "DD/Intern", &hkeydd);
998  size = sizeof(gInfo->intern);
999  db_get_record(hDB, hkeydd, &gInfo->intern, &size, 0);
1000 
1001  // create ps64 DD names record
1002  status = db_create_record(hDB, hKey, "DD/Names", SEP61VAC_NAMES_STR);
1003  if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
1004  cm_msg(MERROR, "sep61vac_init", "sep61vac_init: Error creating sep61vac Names record in ODB, status=%d", status);
1005  cm_yield(0);
1006  return FE_ERR_ODB;
1007  }
1008 
1009  db_find_key(hDB, hKey, "DD/Names", &hkeydd);
1010  size = sizeof(gInfo->sep61vac_names);
1011  db_get_record(hDB, hkeydd, &gInfo->sep61vac_names, &size, 0);
1012 
1013  // check if ps64 DD DB50 record already exists
1014  status = db_find_key(hDB, hKey, "DD/DB50", &hkeydd);
1015  if (status != DB_SUCCESS) { // key doesn't exist yet
1016  // create ps64 DD DB50 record
1017  status = db_create_record(hDB, hKey, "DD/DB50", SEP61VAC_DB50_STR);
1018  if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
1019  cm_msg(MERROR, "sep61vac_init", "sep61vac_init: Error creating sep61vac DB50 record in ODB, status=%d", status);
1020  cm_yield(0);
1021  return FE_ERR_ODB;
1022  }
1023  }
1024 
1025  db_find_key(hDB, hKey, "DD/DB50", &hkeydd);
1026  size = sizeof(gInfo->sep61vac_db50);
1027  status = db_get_record(hDB, hkeydd, &gInfo->sep61vac_db50, &size, 0);
1028  // open hotlink
1029  db_open_record(hDB, hkeydd, &gInfo->sep61vac_db50, size, MODE_WRITE, NULL, NULL);
1030  gInfo->hKeyDB50 = hkeydd;
1031 
1032  // check if ps64 DD DB50 buffer record already exists
1033  status = db_find_key(hDB, hKey, "DD/DB50Buffer", &hkeydd);
1034  if (status != DB_SUCCESS) { // key doesn't exist yet
1035  // create ps64 DD DB50 buffer
1036  strcpy(str, "DB50Buffer = BYTE[840] : \n");
1037  strcat(str, " \n");
1038  status = db_create_record(hDB, hKey, "DD/DB50Buffer", str);
1039  if ((status != DB_SUCCESS) && (status != DB_OPEN_RECORD)) {
1040  cm_msg(MERROR, "sep61vac_init", "sep61vac_init: Error creating sep61vac DB50Buffer record in ODB, status=%d", status);
1041  cm_yield(0);
1042  return FE_ERR_ODB;
1043  }
1044  }
1045 
1046  db_find_key(hDB, hKey, "DD/DB50Buffer", &hkeydd);
1047  size = sizeof(gInfo->sep61vac_db50_buffer);
1048  status = db_get_record(hDB, hkeydd, &gInfo->sep61vac_db50_buffer, &size, 0);
1049  // open hotlink
1050  status = db_open_record(hDB, hkeydd, &gInfo->sep61vac_db50_buffer, size, MODE_WRITE, NULL, NULL);
1051  gInfo->hKeyDB50Buffer = hkeydd;
1052 
1053  // initialize driver
1054  gInfo->bd = bd; // keep the bus driver entry function
1055  gInfo->bd_info = 0; // initialize the pointer to the BD info structure
1056  gInfo->read_timer = ss_time(); // timer for error handling
1057 
1058  cm_msg(MINFO, "sep61vac_init", "sep61vac initialized ...");
1059  cm_yield(0);
1060 
1061  return FE_SUCCESS;
1062 }
1063 
1064 /*----------------------------------------------------------------------------*/
1074 {
1075  // close all hotlinks
1076  db_close_record(info->hDB, info->hKeyDB50);
1077  db_close_record(info->hDB, info->hKeyDB50Buffer);
1078 
1079  free(info);
1080 
1081  return FE_SUCCESS;
1082 }
1083 
1084 /*----------------------------------------------------------------------------*/
1095 {
1097  char req[SEP61VAC_REQ_SIZE] = {'S','5',16,1,3,5,3,8,1,50,0,0,0,0,0xff,2}; // fetch request
1098  INT status, i;
1099 
1100  // communication error report handling
1101  float delta = ss_time()-info->errTime;
1102  if (delta > SEP61VAC_TIMEOUT_ERROR) {
1103  if ((info->tcpip_open_error != 0) || (info->read_error != 0)) {
1104  if (info->intern.detailed_msg)
1105  cm_msg(MINFO, "sep61vac_get_all",
1106  "sep61vac_get_all: No of tcpip open errors = %d, tcpip read errors =%d of %d readings in the last %d secs.",
1108  // reset error counters
1109  info->tcpip_open_error = 0;
1110  info->read_error = 0;
1111  info->read_counts = 0;
1112  // restart timer
1113  info->errTime = ss_time();
1114  }
1115  }
1116 
1117  // open tcpip connection
1118  status = info->bd(CMD_INIT, info->hKeyDD, &info->bd_info);
1119  if (status != SUCCESS) {
1120  info->tcpip_open_error++;
1121  if (info->intern.detailed_msg)
1122  cm_msg(MINFO, "sep61vac_get_all", "sep61vac_get_all: open bounced off. status=%d", status);
1123  return;
1124  }
1125 
1126  // request data
1127  req[0xc] = (SEP61VAC_SPS_MAX_BYTES/2)/0x100; // set higher byte size request
1128  req[0xd] = (SEP61VAC_SPS_MAX_BYTES/2)%0x100; // set lower byte size request
1129  status = info->bd(CMD_WRITE, info->bd_info, req, SEP61VAC_REQ_SIZE);
1130  if ((status != SEP61VAC_REQ_SIZE) && info->intern.detailed_msg)
1131  cm_msg(MINFO, "sep61vac_get_all", "sep61vac_get_all: req.data.status=%d", status);
1132 
1133  ss_sleep(1000);
1134 
1135  // get data
1136  status = info->bd(CMD_READ, info->bd_info, str, sizeof(str), 1000); // read data
1138  cm_msg(MINFO, "sep61vac_get_all", "sep61vac_get_all: get.data.status=%d", status);
1139 
1140  // close connection
1141  info->bd(CMD_EXIT, info->bd_info);
1142 
1143  info->read_counts++;
1144 
1145  // check for errors
1146  // (error byte set) or (haven't gotten all the data)
1147  if ((str[8] != 0) || (status != SEP61VAC_SPS_MAX_BYTES+SEP61VAC_REQ_SIZE)) {
1148  info->read_error++;
1149  return;
1150  }
1151 
1152  // update DB50Buffer
1153  for (i=0; i<SEP61VAC_SPS_MAX_BYTES; i++)
1154  info->sep61vac_db50_buffer[i] = str[i+SEP61VAC_REQ_SIZE];
1155 
1156  // update DB50
1157  status = sep61vac_decode_str(info, str+SEP61VAC_REQ_SIZE);
1158  if (status != 0) { // error
1159  cm_msg(MERROR, "sep61vac_get_all", "error while decoding data. status=%d", status);
1160  return;
1161  }
1162 
1163  // update sep61vac_data
1164  sep61vac_update_data(info);
1165 }
1166 
1167 /*-----------------------------------------------------------------------------*/
1177 INT sep61vac_get(SEP61VAC_INFO *info, INT channel, float *pvalue)
1178 {
1179  DWORD now;
1180 
1181  // read data only if the timeout is reached
1182  now = ss_time();
1183  if ((now > info->read_timer) && (now - info->read_timer > SEP61VAC_READ_TIME_CONST)) {
1184  sep61vac_get_all(info);
1185  // shift the timer
1186  info->read_timer = now;
1187  }
1188 
1189  // transfer value from internal structure
1190  *pvalue = info->sep61vac_data[channel];
1191 
1192  // to keep the CPU load down
1193  ss_sleep(10);
1194 
1195  return FE_SUCCESS;
1196 }
1197 
1198 /*----------------------------------------------------------------------------*/
1209 INT sep61vac_get_label(SEP61VAC_INFO *info, INT channel, char *name)
1210 {
1211  strcpy(name, info->sep61vac_names.name[channel]);
1212  return FE_SUCCESS;
1213 }
1214 
1215 /*---- device driver entry point -----------------------------------*/
1216 INT sep61vac(INT cmd, ...)
1217 {
1218  va_list argptr;
1219  HNDLE hKey;
1220  INT channel, status;
1221  float *pvalue;
1222  void *info, *bd;
1223  char *name;
1224  DWORD flags;
1225 
1226  va_start(argptr, cmd);
1227  status = FE_SUCCESS;
1228 
1229  switch (cmd) {
1230  case CMD_INIT:
1231  hKey = va_arg(argptr, HNDLE);
1232  info = va_arg(argptr, void *);
1233  channel = va_arg(argptr, INT);
1234  flags = va_arg(argptr, DWORD);
1235  bd = va_arg(argptr, void *);
1236  status = sep61vac_init(hKey, info, channel, bd);
1237  break;
1238 
1239  case CMD_EXIT:
1240  info = va_arg(argptr, void *);
1241  status = sep61vac_exit(info);
1242  break;
1243 
1244  case CMD_GET:
1245  info = va_arg(argptr, void *);
1246  channel = va_arg(argptr, INT);
1247  pvalue = va_arg(argptr, float*);
1248  status = sep61vac_get(info, channel, pvalue);
1249  break;
1250 
1251  case CMD_GET_LABEL:
1252  info = va_arg(argptr, void *);
1253  channel = va_arg(argptr, INT);
1254  name = va_arg(argptr, char *);
1255  status = sep61vac_get_label(info, channel, name);
1256  break;
1257 
1258  default:
1259  break;
1260  }
1261 
1262  va_end(argptr);
1263 
1264  return status;
1265 }
#define SEP61VAC_VARS
number of variables in the get list
Definition: sep61vac.h:12
INT read_error
how often there has been a read error
Definition: sep61vac.c:517
#define SEP61VAC_SPS_MAX_OBJ
number of objects in the DB50
Definition: sep61vac.c:23
short sep61vac_spsToNumber(unsigned char *buffer)
Definition: sep61vac.c:562
HNDLE hKeyDB50Buffer
handle to the raw DB50 data
Definition: sep61vac.c:511
short unused_3
unused space
Definition: sep61vac.c:89
char name[SEP61VAC_VARS][NAME_LENGTH]
Names of the input variable names as found in the ODB.
Definition: sep61vac.c:36
DWORD read_timer
timer triggering the reading process
Definition: sep61vac.c:514
short res_18
reserved for future use
Definition: sep61vac.c:72
INFO info
Definition: vme_fe.c:206
short no_of_objects
number of objects = 25
Definition: sep61vac.c:73
short gis61_value
analog value of the Penning of the ps61
Definition: sep61vac.c:147
short ps62_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:91
short vsd60_cmdword
cmd word of the vsd60
Definition: sep61vac.c:180
short gts60_value
analog value of the Pirani of the ps60
Definition: sep61vac.c:141
This is the c-structure holding the DB50 information of the SEP61VAC.
Definition: sep61vac.c:63
short ps61_statusword[4]
status word of the &quot;ps61&quot; pumping station
Definition: sep61vac.c:83
short gts60_statusword
status word of the thermal vacuum gauge of the ps60
Definition: sep61vac.c:139
description structure for the DB labels
Definition: sep61vac.c:56
short psz_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:135
short gts66_statusword
status word of the thermal vacuum gauge of the ps66
Definition: sep61vac.c:169
short gts64_statusword
status word of the thermal vacuum gauge of the ps64
Definition: sep61vac.c:159
short unused_16
unused space
Definition: sep61vac.c:168
INT tcpip_open_error
how often the attempt to open the tcpip communication failed
Definition: sep61vac.c:516
short ps64_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:105
short ps61_cmdword
command word for the &quot;ps61&quot;
Definition: sep61vac.c:88
short gts64_value
analog value of the Pirani of the ps64
Definition: sep61vac.c:161
short ps62_aw2
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:92
short ps61_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:84
short gts67_value
analog value of the Pirani of the ps67
Definition: sep61vac.c:176
short gis62_value
analog value of the Penning of the ps62
Definition: sep61vac.c:152
Stores DD specific internal information.
Definition: sep61vac.c:26
short res_12
reserved for future use
Definition: sep61vac.c:69
SEP61VAC_NAMES sep61vac_names
stores the internal DD settings
Definition: sep61vac.c:504
short ps65_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:114
short ps61_aw2
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:85
short offset
offset address within DB to reach the object
Definition: sep61vac.c:59
short ps66_aw2
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:120
short gts65_value
analog value of the Pirani of the ps65
Definition: sep61vac.c:166
#define SEP61VAC_SPS_MAX_BYTES
number of bytes in the SPS protocol
Definition: sep61vac.c:22
short unused_12
unused space
Definition: sep61vac.c:148
short gis62_statusword
status word of the ionization vacuum gauge of the ps62
Definition: sep61vac.c:150
SEP61VAC_Vac_Labels label[25]
object lable informations
Definition: sep61vac.c:74
HNDLE hDB
main ODB handle
Definition: sep61vac.c:508
DWORD errTime
timer for error handling concerning tcpip communication
Definition: sep61vac.c:515
short unused_6
unused space
Definition: sep61vac.c:110
short vsd61_cmdword
cmd word of the vsd61
Definition: sep61vac.c:183
short ps66_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:121
short lifesign
life sign counter (0 to 65536)
Definition: sep61vac.c:68
double sep61vac_pkr251(int analog)
Definition: sep61vac.c:535
short unused_2
unused space
Definition: sep61vac.c:82
short ps64_cmdword
command word for the &quot;ps64&quot;
Definition: sep61vac.c:109
short gis67_value
analog value of the Penning of the ps67
Definition: sep61vac.c:177
short generaltype
general type = 1, i.e. vacuum
Definition: sep61vac.c:67
short vsd63_cmdword
cmd word of the vsd63
Definition: sep61vac.c:189
short gis60_statusword
status word of the ionization vacuum gauge of the ps60
Definition: sep61vac.c:140
#define SEP61VAC_DB50_STR
Definition: sep61vac.c:206
short gis60_value
analog value of the Penning of the ps60
Definition: sep61vac.c:142
HNDLE hKey
Definition: write_summary.c:97
#define SEP61VAC_INTERN_STR
Initializing string for the struct SEP61VAC_INTERN.
Definition: sep61vac.c:31
short unused_4
unused space
Definition: sep61vac.c:96
short unused_8
unused space
Definition: sep61vac.c:124
INT read_counts
total no of tcpip reading attempts
Definition: sep61vac.c:518
short ps67_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:126
short unused_18
unused space
Definition: sep61vac.c:178
short vsd66_statusword[2]
status word of the vsd66
Definition: sep61vac.c:197
SEP61VAC_DB50 sep61vac_db50
DB50 data structure.
Definition: sep61vac.c:505
INT detailed_msg
flag indicating if detailed status/error messages are wanted
Definition: sep61vac.c:27
short gis65_value
analog value of the Penning of the ps65
Definition: sep61vac.c:167
short ps60_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:79
short gis67_statusword
status word of the ionization vacuum gauge of the ps67
Definition: sep61vac.c:175
DWORD unused_23
unused space
Definition: sep61vac.c:193
short gts62_statusword
status word of the thermal vacuum gauge of the ps62
Definition: sep61vac.c:149
LEMVAC_INFO * gInfo
global info structure, in/out-init routines need the same structure
Definition: lemvac.c:200
short ps60_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:80
short gis65_statusword
status word of the ionization vacuum gauge of the ps65
Definition: sep61vac.c:165
short ps61_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:86
short ps64_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:107
short unused_7
unused space
Definition: sep61vac.c:117
HNDLE hDB
Definition: write_summary.c:97
short unused_15
unused space
Definition: sep61vac.c:163
short ps61_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:87
char teststring[4]
test string = &#39;AB&#39;
Definition: sep61vac.c:65
INT(* bd)(INT cmd,...)
bus driver entry function for reading
Definition: sep61vac.c:512
short ps67_statusword[4]
status word of the &quot;ps67&quot; pumping station
Definition: sep61vac.c:125
short psz_cmdword
command word for the &quot;psz&quot;
Definition: sep61vac.c:137
short gts66_value
analog value of the Pirani of the ps66
Definition: sep61vac.c:171
short gis66_statusword
status word of the ionization vacuum gauge of the ps66
Definition: sep61vac.c:170
short ps64_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:108
DWORD unused_22
unused space
Definition: sep61vac.c:190
DWORD unused_25
unused space
Definition: sep61vac.c:199
short gts67_statusword
status word of the thermal vacuum gauge of the ps67
Definition: sep61vac.c:174
short res_14
reserved for future use
Definition: sep61vac.c:70
short ps64_statusword[4]
status word of the &quot;ps64&quot; pumping station
Definition: sep61vac.c:104
#define SEP61VAC_REQ_SIZE
SPS fetch/write request size.
Definition: sep61vac.c:21
short subtype
subtype of the object
Definition: sep61vac.c:58
short psz_statusword[4]
status word of the &quot;zp&quot; pumping station
Definition: sep61vac.c:132
short vsd61_statusword[2]
status word of the vsd61
Definition: sep61vac.c:182
INT sep61vac_exit(SEP61VAC_INFO *info)
Definition: sep61vac.c:1073
short vsd67_cmdword
cmd word of the vsd67
Definition: sep61vac.c:201
#define SEP61VAC_TIMEOUT_ERROR
after what time (sec.) read errors should be reported
Definition: sep61vac.c:20
short ps63_gfa
Pirani gauge value between Sep61 and lemvac (exit) in (mV)
Definition: sep61vac.c:100
short gis63_value
analog value of the Penning of the ps63
Definition: sep61vac.c:157
INT sep61vac_get_label(SEP61VAC_INFO *info, INT channel, char *name)
Definition: sep61vac.c:1209
short ps60_cmdword
command word for the &quot;ps60&quot;
Definition: sep61vac.c:81
INT sep61vac_decode_str(SEP61VAC_INFO *info, char *buffer)
Definition: sep61vac.c:604
short psz_gv2
central vacuum 2 gauge value in (mV)
Definition: sep61vac.c:134
short vsd62_statusword[2]
status word of the vsd62
Definition: sep61vac.c:185
short psz_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:136
short ps66_cmdword
command word for the &quot;ps66&quot;
Definition: sep61vac.c:123
short gts63_value
analog value of the Pirani of the ps63
Definition: sep61vac.c:156
#define SEP61VAC_NAMES_STR
Initializing string for the struct SEP61VAC_NAMES.
Definition: sep61vac.c:40
short vsd64_statusword[2]
status word of the vsd64
Definition: sep61vac.c:191
short ps63_cmdword
command word for the &quot;ps63&quot;
Definition: sep61vac.c:102
short vsd62_cmdword
cmd word of the vsd62
Definition: sep61vac.c:186
short gts65_statusword
status word of the thermal vacuum gauge of the ps65
Definition: sep61vac.c:164
short ps63_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:101
short gis63_statusword
status word of the ionization vacuum gauge of the ps63
Definition: sep61vac.c:155
short res_16
reserved for future use
Definition: sep61vac.c:71
short ps65_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:115
short ps66_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:119
short ps66_statusword[4]
status word of the &quot;ps66&quot; pumping station
Definition: sep61vac.c:118
short ps62_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:94
short ps63_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:98
short gis61_statusword
status word of the ionization vacuum gauge of the ps61
Definition: sep61vac.c:145
short gts63_statusword
status word of the thermal vacuum gauge of the ps63
Definition: sep61vac.c:154
short telegramlength
telegram length in words = 420 (word = 2 byte for the SPS!)
Definition: sep61vac.c:66
DWORD unused_26
unused space
Definition: sep61vac.c:202
char unused_1[128]
unused space
Definition: sep61vac.c:75
DWORD unused_19
unused space
Definition: sep61vac.c:181
DWORD unused_20
unused space
Definition: sep61vac.c:184
short testnumber
test number = 1
Definition: sep61vac.c:64
int sep61vac_spsToWord(unsigned char *buffer)
Definition: sep61vac.c:587
short ps67_aw2
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:127
short unused_13
unused space
Definition: sep61vac.c:153
short psz_gv1
central vacuum 1 gauge value in (mV)
Definition: sep61vac.c:133
short ps64_aw2
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:106
char sep61vac_db50_buffer[SEP61VAC_SPS_MAX_BYTES]
DB50 byte buffer.
Definition: sep61vac.c:506
short ps65_cmdword
command word for the &quot;ps65&quot;
Definition: sep61vac.c:116
Stores the names of the various channels which are than transferred form the DD to the variable names...
Definition: sep61vac.c:35
float sep61vac_data[SEP61VAC_VARS]
stores decoded values from DB50
Definition: sep61vac.c:507
void * bd_info
pointer to the BD info structure of the input channels
Definition: sep61vac.c:513
short ps63_statusword[4]
status word of the &quot;ps63&quot; pumping station
Definition: sep61vac.c:97
short ps63_gfe
Pirani gauge value between PS62 and Sep61 (entrance) in (mV)
Definition: sep61vac.c:99
short ps62_cmdword
command word for the &quot;ps62&quot;
Definition: sep61vac.c:95
short ps67_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:128
short ps60_aw2
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:78
short vsd65_cmdword
cmd word of the vsd65
Definition: sep61vac.c:195
DWORD unused_21
unused space
Definition: sep61vac.c:187
short ps60_statusword[4]
status word of the &quot;ps60&quot; pumping station
Definition: sep61vac.c:76
short gis64_statusword
status word of the ionization vacuum gauge of the ps64
Definition: sep61vac.c:160
This structure contains private variables for the device driver.
Definition: sep61vac.c:502
short unused_10
unused space
Definition: sep61vac.c:138
short unused_5
unused space
Definition: sep61vac.c:103
short gis64_value
analog value of the Penning of the ps64
Definition: sep61vac.c:162
short ps67_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:129
short unused_11
unused space
Definition: sep61vac.c:143
HNDLE hKeyDB50
handle to the decoded DB50 structure
Definition: sep61vac.c:510
short vsd64_cmdword
cmd word of the vsd64
Definition: sep61vac.c:192
short unused_17
unused space
Definition: sep61vac.c:173
short ps62_aw3
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:93
short ps60_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:77
HNDLE hKeyDD
main device driver handle for input channels
Definition: sep61vac.c:509
short gts61_statusword
status word of the thermal vacuum gauge of the ps61
Definition: sep61vac.c:144
short ps62_statusword[4]
status word of the &quot;ps62&quot; pumping station
Definition: sep61vac.c:90
INT sep61vac_init(HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
Definition: sep61vac.c:973
short unused_14
unused space
Definition: sep61vac.c:158
DWORD unused_24
unused space
Definition: sep61vac.c:196
SEP61VAC_INTERN intern
stores DD specific internal settings
Definition: sep61vac.c:503
short ps65_aw2
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:113
short ps65_statusword[4]
status word of the &quot;ps65&quot; pumping station
Definition: sep61vac.c:111
short unused_9
unused space
Definition: sep61vac.c:131
short vsd65_statusword[2]
status word of the vsd65
Definition: sep61vac.c:194
short vsd63_statusword[2]
status word of the vsd63
Definition: sep61vac.c:188
short ps67_cmdword
command word for the &quot;ps67&quot;
Definition: sep61vac.c:130
short ps65_gp
Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:112
double sep61vac_pirani_tpr280(int analog)
Definition: sep61vac.c:549
short gts61_value
analog value of the Pirani of the ps61
Definition: sep61vac.c:146
short vsd67_statusword[2]
status word of the vsd67
Definition: sep61vac.c:200
char obj[10]
name of the object
Definition: sep61vac.c:57
short gts62_value
analog value of the Pirani of the ps62
Definition: sep61vac.c:151
void sep61vac_update_data(SEP61VAC_INFO *info)
Definition: sep61vac.c:942
#define SEP61VAC_READ_TIME_CONST
trigger time constant for read out of the SPS
Definition: sep61vac.c:19
INT sep61vac(INT cmd,...)
Definition: sep61vac.c:1216
short gis66_value
analog value of the Penning of the ps66
Definition: sep61vac.c:172
short vsd66_cmdword
cmd word of the vsd66
Definition: sep61vac.c:198
short vsd60_statusword[2]
status word of the vsd60
Definition: sep61vac.c:179
short ps66_aw4
reserve Pirani gauge value of the buffer in (mV)
Definition: sep61vac.c:122
void sep61vac_get_all(SEP61VAC_INFO *info)
Definition: sep61vac.c:1094
INT sep61vac_get(SEP61VAC_INFO *info, INT channel, float *pvalue)
Definition: sep61vac.c:1177