Debian Codegraph @

libsrc/xcon/xck.c

raw
1 /*===========================================================================
2 Copyright (C) 1995-2009 European Southern Observatory (ESO)
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public
15 License along with this program; if not, write to the Free
16 Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
17 MA 02139, USA.
18
19 Correspondence concerning ESO-MIDAS should be addressed as follows:
20 Internet e-mail: [email protected]
21 Postal address: European Southern Observatory
22 Data Management Division
23 Karl-Schwarzschild-Strasse 2
24 D 85748 Garching bei Muenchen
25 GERMANY
26 ===========================================================================*/
27
28 /*+++++++++++++++++++++++ XC interface module XCK +++++++++++++++++++++++
29 .LANGUAGE C
30 .IDENTIFICATION Module XCK
31 .AUTHOR K. Banse ESO - Garching
32 .KEYWORDS standard interfaces, keyword data base
33 .ENVIRONMENT VMS and UNIX
34 .COMMENTS
35 holds XCKRDx (x=I,R,D,C) routines
36 .VERSION [1.00] 940426: creation
37 .VERSION [1.10] 940505: add XCKWRx interfaces
38
39 090407 last modif
40 -----------------------------------------------------------------------------*/
41
42 #include <midas_def.h>
43 #include <xconndef.h>
44
45 #include <stdio.h>
46
47
48 /*
49
50 */
51
52 int XCKRDI(cid,key,felem,maxvals,actvals,values,unit,null,kstat)
53
54 /*++++++++++++++++++++++++++++++++++++++++++++++++++
55 .PURPOSE
56 use background Midas to read data from integer keyword
57 .ALGORITHM
58 straight forward
59 .RETURNS
60 return status ( 0 = ok )
61 = 1; background Midas busy
62 = -1; problems with socket communication (kstat = error from communication)
63 = -90; invalid input to this interface
64 = -91; only non-socket communication established
65 --------------------------------------------------*/
66
67 int cid; /* IN: id of background Midas */
68 char *key; /* IN: name of keyword */
69 int felem; /* IN: first data item to be read */
70 int maxvals; /* IN: no. of elements to get */
71 int *actvals; /* OUT: actual no. of elements returned */
72 int *values; /* OUT: buffer for data values */
73 int *unit; /* OUT: unit-pointer */
74 int *null; /* OUT: no. of null values in keyword */
75 int *kstat; /* OUT: status from SCKRDI */
76
77 {
78 int stat, retstat, karr[4];
79 char Comndline[40];
80
81
82 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
83 return (-90);
84 else if (BKMIDAS[cid].METHOD != 's')
85 return (-91);
86 else if (BKMIDAS[cid].ACTIVE != 'N')
87 return (1);
88
89 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
90 Comndline[1] = XCONNECT.MYUNIT[1];
91 (void)sprintf(&Comndline[2],
92 "READ/KEYW %s/i/%d/%d XCONNECT",key,felem,maxvals);
93
94 stat = ClientKRead(BKMIDAS[cid].CHAN,1,Comndline,(char *)values,
95 karr,&retstat);
96
97 if (stat == 0)
98 {
99 *actvals = karr[0];
100 *unit = karr[1];
101 *null = karr[2];
102 *kstat = karr[3];
103 return (0);
104 }
105 else
106 {
107 *kstat = retstat;
108 return (-1);
109 }
110 }
111 /*
112
113 */
114
115 int XCKRDR(cid,key,felem,maxvals,actvals,values,unit,null,kstat)
116
117 /*++++++++++++++++++++++++++++++++++++++++++++++++++
118 .PURPOSE
119 use background Midas to read data from integer keyword
120 .ALGORITHM
121 straight forward
122 .RETURNS
123 return status ( 0 = ok )
124 = 1; background Midas busy
125 = -1; problems with socket communication (kstat = error from communication)
126 = -90; invalid input to this interface
127 = -91; only non-socket communication established
128 --------------------------------------------------*/
129
130 int cid; /* IN: id of background Midas */
131 char *key; /* IN: name of keyword */
132 int felem; /* IN: first data item to be read */
133 int maxvals; /* IN: no. of elements to get */
134 int *actvals; /* OUT: actual no. of elements returned */
135 float *values; /* OUT: buffer for data values */
136 int *unit; /* OUT: unit-pointer */
137 int *null; /* OUT: no. of null values in keyword */
138 int *kstat; /* OUT: status from SCKRDR */
139
140 {
141 int stat, retstat, karr[4];
142 char Comndline[40];
143
144
145 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
146 return (90);
147 else if (BKMIDAS[cid].METHOD != 's')
148 return (-91);
149 else if (BKMIDAS[cid].ACTIVE != 'N')
150 return (1);
151
152
153 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
154 Comndline[1] = XCONNECT.MYUNIT[1];
155 (void)sprintf(&Comndline[2],
156 "READ/KEYW %s/r/%d/%d XCONNECT",key,felem,maxvals);
157
158 stat = ClientKRead(BKMIDAS[cid].CHAN,2,Comndline,(char *)values,
159 karr,&retstat);
160 if (stat == 0)
161 {
162 *actvals = karr[0];
163 *unit = karr[1];
164 *null = karr[2];
165 *kstat = karr[3];
166 return (0);
167 }
168 else
169 {
170 *kstat = retstat;
171 return (-1);
172 }
173 }
174 /*
175
176 */
177
178 int XCKRDD(cid,key,felem,maxvals,actvals,values,unit,null,kstat)
179
180 /*++++++++++++++++++++++++++++++++++++++++++++++++++
181 .PURPOSE
182 use background Midas to read data from integer keyword
183 .ALGORITHM
184 straight forward
185 .RETURNS
186 return status ( 0 = ok )
187 = 1; background Midas busy
188 = -1; problems with socket communication (kstat = error from communication)
189 = -90; invalid input to this interface
190 = -91; only non-socket communication established
191 --------------------------------------------------*/
192
193 int cid; /* IN: id of background Midas */
194 char *key; /* IN: name of keyword */
195 int felem; /* IN: first data item to be read */
196 int maxvals; /* IN: no. of elements to get */
197 int *actvals; /* OUT: actual no. of elements returned */
198 double *values; /* OUT: buffer for data values */
199 int *unit; /* OUT: unit-pointer */
200 int *null; /* OUT: no. of null values in keyword */
201 int *kstat; /* OUT: status from SCKRDD */
202
203 {
204 int stat, retstat, karr[4];
205 char Comndline[40];
206
207
208 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
209 return (90);
210 else if (BKMIDAS[cid].METHOD != 's')
211 return (-91);
212 else if (BKMIDAS[cid].ACTIVE != 'N')
213 return (1);
214
215
216 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
217 Comndline[1] = XCONNECT.MYUNIT[1];
218 (void)sprintf(&Comndline[2],
219 "READ/KEYW %s/d/%d/%d XCONNECT",key,felem,maxvals);
220
221 stat = ClientKRead(BKMIDAS[cid].CHAN,4,Comndline,(char *)values,
222 karr,&retstat);
223 if (stat == 0)
224 {
225 *actvals = karr[0];
226 *unit = karr[1];
227 *null = karr[2];
228 *kstat = karr[3];
229 return (0);
230 }
231 else
232 {
233 *kstat = retstat;
234 return (-1);
235 }
236 }
237 /*
238
239 */
240
241 int XCKRDC(cid,key,noelm,felem,maxvals,actvals,values,unit,null,kstat)
242
243 /*++++++++++++++++++++++++++++++++++++++++++++++++++
244 .PURPOSE
245 use background Midas to read data from integer keyword
246 .ALGORITHM
247 straight forward
248 .RETURNS
249 return status ( 0 = ok )
250 = 1; background Midas busy
251 = -1; problems with socket communication (kstat = error from communication)
252 = -90; invalid input to this interface
253 = -91; only non-socket communication established
254 --------------------------------------------------*/
255
256 int cid; /* IN: id of background Midas */
257 char *key; /* IN: name of keyword */
258 int noelm; /* IN: no. of bytes per element */
259 int felem; /* IN: first data item to be read */
260 int maxvals; /* IN: no. of elements to get */
261 int *actvals; /* OUT: actual no. of elements returned */
262 char *values; /* OUT: buffer for data values */
263 int *unit; /* OUT: unit-pointer */
264 int *null; /* OUT: no. of null values in keyword */
265 int *kstat; /* OUT: status from SCKRDC */
266
267 {
268 int stat, retstat, karr[4];
269 char Comndline[40];
270
271
272 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
273 return (90);
274 else if (BKMIDAS[cid].METHOD != 's')
275 return (-91);
276 else if (BKMIDAS[cid].ACTIVE != 'N')
277 return (1);
278
279
280 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
281 Comndline[1] = XCONNECT.MYUNIT[1];
282 if (noelm > 1)
283 (void)sprintf(&Comndline[2],
284 "READ/KEYW %s/c*%d/%d/%d XCONNECT",key,noelm,felem,maxvals);
285 else
286 (void)sprintf(&Comndline[2],
287 "READ/KEYW %s/c/%d/%d XCONNECT",key,felem,maxvals);
288
289 stat = ClientKRead(BKMIDAS[cid].CHAN,3,Comndline,values,karr,&retstat);
290 if (stat == 0)
291 {
292 *actvals = karr[0];
293 *unit = karr[1];
294 *null = karr[2];
295 *kstat = karr[3];
296 return (0);
297 }
298 else
299 {
300 *kstat = retstat;
301 return (-1);
302 }
303 }
304 /*
305
306 */
307
308 int XCKWRI(cid,key,values,felem,maxvals,unit,kstat)
309
310 /*++++++++++++++++++++++++++++++++++++++++++++++++++
311 .PURPOSE
312 use background Midas to write data into integer keyword
313 .ALGORITHM
314 straight forward
315 .RETURNS
316 return status ( 0 = ok )
317 = 1; background Midas busy
318 = -1; problems with socket communication (kstat = error from communication)
319 = -90; invalid input to this interface
320 = -91; only non-socket communication established
321 --------------------------------------------------*/
322
323 int cid; /* IN: id of background Midas */
324 char *key; /* IN: name of keyword */
325 int *values; /* IN: buffer for data values */
326 int felem; /* IN: first data item to be written */
327 int maxvals; /* IN: no. of elements to write */
328 int *unit; /* IN: unit-pointer */
329 int *kstat; /* OUT: status from SCKWRI */
330
331 {
332 int stat, retstat, karr[4];
333 char Comndline[40];
334
335
336 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
337 return (-90);
338 else if (BKMIDAS[cid].METHOD != 's')
339 return (-91);
340 else if (BKMIDAS[cid].ACTIVE != 'N')
341 return (1);
342
343
344 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
345 Comndline[1] = XCONNECT.MYUNIT[1];
346
347 (void)sprintf(&Comndline[2],
348 "WRITE/KEYW %s/i/%d/%d ? XCONNECT",key,felem,maxvals);
349
350 karr[0] = maxvals;
351 karr[1] = *unit;
352 karr[2] = 0; /* `null' param. not used */
353 stat = ClientKWrite(BKMIDAS[cid].CHAN,1,Comndline,(char *)values,
354 karr,&retstat);
355 if (stat == 0)
356 {
357 *kstat = karr[3];
358 return (0);
359 }
360 else
361 {
362 *kstat = retstat;
363 return (-1);
364 }
365 }
366 /*
367
368 */
369
370 int XCKWRR(cid,key,values,felem,maxvals,unit,kstat)
371
372 /*++++++++++++++++++++++++++++++++++++++++++++++++++
373 .PURPOSE
374 use background Midas to write data into integer keyword
375 .ALGORITHM
376 straight forward
377 .RETURNS
378 return status ( 0 = ok )
379 = 1; background Midas busy
380 = -1; problems with socket communication (kstat = error from communication)
381 = -90; invalid input to this interface
382 = -91; only non-socket communication established
383 --------------------------------------------------*/
384
385 int cid; /* IN: id of background Midas */
386 char *key; /* IN: name of keyword */
387 float *values; /* IN: buffer for data values */
388 int felem; /* IN: first data item to be written */
389 int maxvals; /* IN: no. of elements to write */
390 int *unit; /* IN: unit-pointer */
391 int *kstat; /* OUT: status from SCKWRI */
392
393 {
394 int stat, retstat, karr[4];
395 char Comndline[40];
396
397
398 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
399 return (-90);
400 else if (BKMIDAS[cid].METHOD != 's')
401 return (-91);
402 else if (BKMIDAS[cid].ACTIVE != 'N')
403 return (1);
404
405
406 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
407 Comndline[1] = XCONNECT.MYUNIT[1];
408
409 (void)sprintf(&Comndline[2],
410 "WRITE/KEYW %s/r/%d/%d ? XCONNECT",key,felem,maxvals);
411
412 karr[0] = maxvals;
413 karr[1] = *unit;
414 karr[2] = 0; /* `null' param. not used */
415 stat = ClientKWrite(BKMIDAS[cid].CHAN,2,Comndline,(char *)values,
416 karr,&retstat);
417 if (stat == 0)
418 {
419 *kstat = karr[3];
420 return (0);
421 }
422 else
423 {
424 *kstat = retstat;
425 return (-1);
426 }
427 }
428 /*
429
430 */
431
432 int XCKWRD(cid,key,values,felem,maxvals,unit,kstat)
433
434 /*++++++++++++++++++++++++++++++++++++++++++++++++++
435 .PURPOSE
436 use background Midas to write data into integer keyword
437 .ALGORITHM
438 straight forward
439 .RETURNS
440 return status ( 0 = ok )
441 = 1; background Midas busy
442 = -1; problems with socket communication (kstat = error from communication)
443 = -90; invalid input to this interface
444 = -91; only non-socket communication established
445 --------------------------------------------------*/
446
447 int cid; /* IN: id of background Midas */
448 char *key; /* IN: name of keyword */
449 double *values; /* IN: buffer for data values */
450 int felem; /* IN: first data item to be written */
451 int maxvals; /* IN: no. of elements to write */
452 int *unit; /* IN: unit-pointer */
453 int *kstat; /* OUT: status from SCKWRI */
454
455 {
456 int stat, retstat, karr[4];
457 char Comndline[40];
458
459
460 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
461 return (-90);
462 else if (BKMIDAS[cid].METHOD != 's')
463 return (-91);
464 else if (BKMIDAS[cid].ACTIVE != 'N')
465 return (1);
466
467
468 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
469 Comndline[1] = XCONNECT.MYUNIT[1];
470
471 (void)sprintf(&Comndline[2],
472 "WRITE/KEYW %s/d/%d/%d ? XCONNECT",key,felem,maxvals);
473
474 karr[0] = maxvals;
475 karr[1] = *unit;
476 karr[2] = 0; /* `null' param. not used */
477 stat = ClientKWrite(BKMIDAS[cid].CHAN,4,Comndline,(char *)values,
478 karr,&retstat);
479 if (stat == 0)
480 {
481 *kstat = karr[3];
482 return (0);
483 }
484 else
485 {
486 *kstat = retstat;
487 return (-1);
488 }
489 }
490 /*
491
492 */
493
494 int XCKWRC(cid,key,noelm,values,felem,maxvals,unit,kstat)
495
496 /*++++++++++++++++++++++++++++++++++++++++++++++++++
497 .PURPOSE
498 use background Midas to write data into integer keyword
499 .ALGORITHM
500 straight forward
501 .RETURNS
502 return status ( 0 = ok )
503 = 1; background Midas busy
504 = -1; problems with socket communication (kstat = error from communication)
505 = -90; invalid input to this interface
506 = -91; only non-socket communication established
507 --------------------------------------------------*/
508
509 int cid; /* IN: id of background Midas */
510 char *key; /* IN: name of keyword */
511 int noelm; /* IN: no. of bytes per element */
512 char *values; /* IN: buffer for data values */
513 int felem; /* IN: first data item to be written */
514 int maxvals; /* IN: no. of elements to write */
515 int *unit; /* IN: unit-pointer */
516 int *kstat; /* OUT: status from SCKWRI */
517
518 {
519 int stat, retstat, karr[4];
520 char Comndline[40];
521
522
523 if ((cid < 0) || (cid >= MAX_BACK) || (BKMIDAS[cid].UNIT[0] == ' '))
524 return (-90);
525 else if (BKMIDAS[cid].METHOD != 's')
526 return (-91);
527 else if (BKMIDAS[cid].ACTIVE != 'N')
528 return (1);
529
530
531 Comndline[0] = XCONNECT.MYUNIT[0]; /* include return address */
532 Comndline[1] = XCONNECT.MYUNIT[1];
533
534 if (noelm > 1)
535 (void)sprintf(&Comndline[2],
536 "WRITE/KEYW %s/c*%d/%d/%d XCONNECT",key,noelm,felem,maxvals);
537 else
538 (void)sprintf(&Comndline[2],
539 "WRITE/KEYW %s/c/%d/%d XCONNECT",key,felem,maxvals);
540
541 karr[0] = maxvals * noelm;
542 karr[1] = *unit;
543 karr[2] = 0; /* `null' param. not used */
544 stat = ClientKWrite(BKMIDAS[cid].CHAN,3,Comndline,values,karr,&retstat);
545 if (stat == 0)
546 {
547 *kstat = karr[3];
548 return (0);
549 }
550 else
551 {
552 *kstat = retstat;
553 return (-1);
554 }
555 }