EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
db_access.h
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 /* base/include/db_access.h */
11 /* Author: Bob Dalesio
12  * Date: 4-4-88
13 */
14 
15 #ifndef INC_db_access_H
16 #define INC_db_access_H
17 
18 #include <stddef.h>
19 
20 #include "epicsTypes.h"
21 #include "epicsTime.h"
22 
23 #include "libCaAPI.h"
24 
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define MAX_UNITS_SIZE 8
31 #define MAX_ENUM_STRING_SIZE 26
32 #define MAX_ENUM_STATES 16
33 
34 /*
35  * architecture independent types
36  *
37  * (so far this is sufficient for all archs we have ported to)
38  */
39 typedef epicsOldString dbr_string_t;
40 typedef epicsUInt8 dbr_char_t;
41 typedef epicsInt16 dbr_short_t;
42 typedef epicsUInt16 dbr_ushort_t;
43 typedef epicsInt16 dbr_int_t;
44 typedef epicsUInt16 dbr_enum_t;
45 typedef epicsInt32 dbr_long_t;
46 typedef epicsUInt32 dbr_ulong_t;
47 typedef epicsFloat32 dbr_float_t;
48 typedef epicsFloat64 dbr_double_t;
49 typedef epicsUInt16 dbr_put_ackt_t;
50 typedef epicsUInt16 dbr_put_acks_t;
51 typedef epicsOldString dbr_stsack_string_t;
52 typedef epicsOldString dbr_class_name_t;
53 
54 #ifndef db_accessHFORdb_accessC
55 /* database field types */
56 #define DBF_STRING 0
57 #define DBF_INT 1
58 #define DBF_SHORT 1
59 #define DBF_FLOAT 2
60 #define DBF_ENUM 3
61 #define DBF_CHAR 4
62 #define DBF_LONG 5
63 #define DBF_DOUBLE 6
64 #define DBF_NO_ACCESS 7
65 #define LAST_TYPE DBF_DOUBLE
66 #define VALID_DB_FIELD(x) ((x >= 0) && (x <= LAST_TYPE))
67 #define INVALID_DB_FIELD(x) ((x < 0) || (x > LAST_TYPE))
68 
69 /* data request buffer types */
70 #define DBR_STRING DBF_STRING
71 #define DBR_INT DBF_INT
72 #define DBR_SHORT DBF_INT
73 #define DBR_FLOAT DBF_FLOAT
74 #define DBR_ENUM DBF_ENUM
75 #define DBR_CHAR DBF_CHAR
76 #define DBR_LONG DBF_LONG
77 #define DBR_DOUBLE DBF_DOUBLE
78 #define DBR_STS_STRING 7
79 #define DBR_STS_SHORT 8
80 #define DBR_STS_INT DBR_STS_SHORT
81 #define DBR_STS_FLOAT 9
82 #define DBR_STS_ENUM 10
83 #define DBR_STS_CHAR 11
84 #define DBR_STS_LONG 12
85 #define DBR_STS_DOUBLE 13
86 #define DBR_TIME_STRING 14
87 #define DBR_TIME_INT 15
88 #define DBR_TIME_SHORT 15
89 #define DBR_TIME_FLOAT 16
90 #define DBR_TIME_ENUM 17
91 #define DBR_TIME_CHAR 18
92 #define DBR_TIME_LONG 19
93 #define DBR_TIME_DOUBLE 20
94 #define DBR_GR_STRING 21
95 #define DBR_GR_SHORT 22
96 #define DBR_GR_INT DBR_GR_SHORT
97 #define DBR_GR_FLOAT 23
98 #define DBR_GR_ENUM 24
99 #define DBR_GR_CHAR 25
100 #define DBR_GR_LONG 26
101 #define DBR_GR_DOUBLE 27
102 #define DBR_CTRL_STRING 28
103 #define DBR_CTRL_SHORT 29
104 #define DBR_CTRL_INT DBR_CTRL_SHORT
105 #define DBR_CTRL_FLOAT 30
106 #define DBR_CTRL_ENUM 31
107 #define DBR_CTRL_CHAR 32
108 #define DBR_CTRL_LONG 33
109 #define DBR_CTRL_DOUBLE 34
110 #define DBR_PUT_ACKT DBR_CTRL_DOUBLE + 1
111 #define DBR_PUT_ACKS DBR_PUT_ACKT + 1
112 #define DBR_STSACK_STRING DBR_PUT_ACKS + 1
113 #define DBR_CLASS_NAME DBR_STSACK_STRING + 1
114 #define LAST_BUFFER_TYPE DBR_CLASS_NAME
115 #define VALID_DB_REQ(x) ((x >= 0) && (x <= LAST_BUFFER_TYPE))
116 #define INVALID_DB_REQ(x) ((x < 0) || (x > LAST_BUFFER_TYPE))
117 
118 /*
119  * The enumeration "epicsType" is an index to this array
120  * of type DBR types. In some cases we select the a
121  * larger type to avoid loss of information
122  */
123 LIBCA_API extern const int epicsTypeToDBR_XXXX [lastEpicsType+1];
124 
125 /*
126  * The DBR_XXXX types are indices into this array
127  */
128 LIBCA_API extern const epicsType DBR_XXXXToEpicsType [LAST_BUFFER_TYPE+1];
129 
130 /* values returned for each field type
131  * DBR_STRING returns a NULL terminated string
132  * DBR_SHORT returns an unsigned short
133  * DBR_INT returns an unsigned short
134  * DBR_FLOAT returns an IEEE floating point value
135  * DBR_ENUM returns an unsigned short which is the enum item
136  * DBR_CHAR returns an unsigned char
137  * DBR_LONG returns an unsigned long
138  * DBR_DOUBLE returns a double precision floating point number
139  * DBR_STS_STRING returns a string status structure (dbr_sts_string)
140  * DBR_STS_SHORT returns a short status structure (dbr_sts_short)
141  * DBR_STS_INT returns a short status structure (dbr_sts_int)
142  * DBR_STS_FLOAT returns a float status structure (dbr_sts_float)
143  * DBR_STS_ENUM returns an enum status structure (dbr_sts_enum)
144  * DBR_STS_CHAR returns a char status structure (dbr_sts_char)
145  * DBR_STS_LONG returns a long status structure (dbr_sts_long)
146  * DBR_STS_DOUBLE returns a double status structure (dbr_sts_double)
147  * DBR_TIME_STRING returns a string time structure (dbr_time_string)
148  * DBR_TIME_SHORT returns a short time structure (dbr_time_short)
149  * DBR_TIME_INT returns a short time structure (dbr_time_short)
150  * DBR_TIME_FLOAT returns a float time structure (dbr_time_float)
151  * DBR_TIME_ENUM returns an enum time structure (dbr_time_enum)
152  * DBR_TIME_CHAR returns a char time structure (dbr_time_char)
153  * DBR_TIME_LONG returns a long time structure (dbr_time_long)
154  * DBR_TIME_DOUBLE returns a double time structure (dbr_time_double)
155  * DBR_GR_STRING returns a graphic string structure (dbr_gr_string)
156  * DBR_GR_SHORT returns a graphic short structure (dbr_gr_short)
157  * DBR_GR_INT returns a graphic short structure (dbr_gr_int)
158  * DBR_GR_FLOAT returns a graphic float structure (dbr_gr_float)
159  * DBR_GR_ENUM returns a graphic enum structure (dbr_gr_enum)
160  * DBR_GR_CHAR returns a graphic char structure (dbr_gr_char)
161  * DBR_GR_LONG returns a graphic long structure (dbr_gr_long)
162  * DBR_GR_DOUBLE returns a graphic double structure (dbr_gr_double)
163  * DBR_CTRL_STRING returns a control string structure (dbr_ctrl_int)
164  * DBR_CTRL_SHORT returns a control short structure (dbr_ctrl_short)
165  * DBR_CTRL_INT returns a control short structure (dbr_ctrl_int)
166  * DBR_CTRL_FLOAT returns a control float structure (dbr_ctrl_float)
167  * DBR_CTRL_ENUM returns a control enum structure (dbr_ctrl_enum)
168  * DBR_CTRL_CHAR returns a control char structure (dbr_ctrl_char)
169  * DBR_CTRL_LONG returns a control long structure (dbr_ctrl_long)
170  * DBR_CTRL_DOUBLE returns a control double structure (dbr_ctrl_double)
171  */
172 #endif /*db_accessHFORdb_accessC*/
173 
174 /* VALUES WITH STATUS STRUCTURES */
175 
176 /* structure for a string status field */
178  dbr_short_t status; /* status of value */
179  dbr_short_t severity; /* severity of alarm */
180  dbr_string_t value; /* current value */
181 };
182 
183 /* structure for a string status and ack field */
185  dbr_ushort_t status; /* status of value */
186  dbr_ushort_t severity; /* severity of alarm */
187  dbr_ushort_t ackt; /* ack transient? */
188  dbr_ushort_t acks; /* ack severity */
189  dbr_string_t value; /* current value */
190 };
191 /* structure for an short status field */
192 struct dbr_sts_int{
193  dbr_short_t status; /* status of value */
194  dbr_short_t severity; /* severity of alarm */
195  dbr_short_t value; /* current value */
196 };
198  dbr_short_t status; /* status of value */
199  dbr_short_t severity; /* severity of alarm */
200  dbr_short_t value; /* current value */
201 };
202 
203 /* structure for a float status field */
205  dbr_short_t status; /* status of value */
206  dbr_short_t severity; /* severity of alarm */
207  dbr_float_t value; /* current value */
208 };
209 
210 /* structure for a enum status field */
212  dbr_short_t status; /* status of value */
213  dbr_short_t severity; /* severity of alarm */
214  dbr_enum_t value; /* current value */
215 };
216 
217 /* structure for a char status field */
219  dbr_short_t status; /* status of value */
220  dbr_short_t severity; /* severity of alarm */
221  dbr_char_t RISC_pad; /* RISC alignment */
222  dbr_char_t value; /* current value */
223 };
224 
225 /* structure for a long status field */
227  dbr_short_t status; /* status of value */
228  dbr_short_t severity; /* severity of alarm */
229  dbr_long_t value; /* current value */
230 };
231 
232 /* structure for a double status field */
234  dbr_short_t status; /* status of value */
235  dbr_short_t severity; /* severity of alarm */
236  dbr_long_t RISC_pad; /* RISC alignment */
237  dbr_double_t value; /* current value */
238 };
239 
240 /* VALUES WITH STATUS AND TIME STRUCTURES */
241 
242 /* structure for a string time field */
244  dbr_short_t status; /* status of value */
245  dbr_short_t severity; /* severity of alarm */
246  epicsTimeStamp stamp; /* time stamp */
247  dbr_string_t value; /* current value */
248 };
249 
250 /* structure for an short time field */
252  dbr_short_t status; /* status of value */
253  dbr_short_t severity; /* severity of alarm */
254  epicsTimeStamp stamp; /* time stamp */
255  dbr_short_t RISC_pad; /* RISC alignment */
256  dbr_short_t value; /* current value */
257 };
258 
259 /* structure for a float time field */
261  dbr_short_t status; /* status of value */
262  dbr_short_t severity; /* severity of alarm */
263  epicsTimeStamp stamp; /* time stamp */
264  dbr_float_t value; /* current value */
265 };
266 
267 /* structure for a enum time field */
269  dbr_short_t status; /* status of value */
270  dbr_short_t severity; /* severity of alarm */
271  epicsTimeStamp stamp; /* time stamp */
272  dbr_short_t RISC_pad; /* RISC alignment */
273  dbr_enum_t value; /* current value */
274 };
275 
276 /* structure for a char time field */
278  dbr_short_t status; /* status of value */
279  dbr_short_t severity; /* severity of alarm */
280  epicsTimeStamp stamp; /* time stamp */
281  dbr_short_t RISC_pad0; /* RISC alignment */
282  dbr_char_t RISC_pad1; /* RISC alignment */
283  dbr_char_t value; /* current value */
284 };
285 
286 /* structure for a long time field */
288  dbr_short_t status; /* status of value */
289  dbr_short_t severity; /* severity of alarm */
290  epicsTimeStamp stamp; /* time stamp */
291  dbr_long_t value; /* current value */
292 };
293 
294 /* structure for a double time field */
296  dbr_short_t status; /* status of value */
297  dbr_short_t severity; /* severity of alarm */
298  epicsTimeStamp stamp; /* time stamp */
299  dbr_long_t RISC_pad; /* RISC alignment */
300  dbr_double_t value; /* current value */
301 };
302 
303 /* VALUES WITH STATUS AND GRAPHIC STRUCTURES */
304 
305 /* structure for a graphic string */
306  /* not implemented; use struct_dbr_sts_string */
307 
308 /* structure for a graphic short field */
309 struct dbr_gr_int{
310  dbr_short_t status; /* status of value */
311  dbr_short_t severity; /* severity of alarm */
312  char units[MAX_UNITS_SIZE]; /* units of value */
313  dbr_short_t upper_disp_limit; /* upper limit of graph */
314  dbr_short_t lower_disp_limit; /* lower limit of graph */
315  dbr_short_t upper_alarm_limit;
316  dbr_short_t upper_warning_limit;
317  dbr_short_t lower_warning_limit;
318  dbr_short_t lower_alarm_limit;
319  dbr_short_t value; /* current value */
320 };
322  dbr_short_t status; /* status of value */
323  dbr_short_t severity; /* severity of alarm */
324  char units[MAX_UNITS_SIZE]; /* units of value */
325  dbr_short_t upper_disp_limit; /* upper limit of graph */
326  dbr_short_t lower_disp_limit; /* lower limit of graph */
327  dbr_short_t upper_alarm_limit;
328  dbr_short_t upper_warning_limit;
329  dbr_short_t lower_warning_limit;
330  dbr_short_t lower_alarm_limit;
331  dbr_short_t value; /* current value */
332 };
333 
334 /* structure for a graphic floating point field */
336  dbr_short_t status; /* status of value */
337  dbr_short_t severity; /* severity of alarm */
338  dbr_short_t precision; /* number of decimal places */
339  dbr_short_t RISC_pad0; /* RISC alignment */
340  char units[MAX_UNITS_SIZE]; /* units of value */
341  dbr_float_t upper_disp_limit; /* upper limit of graph */
342  dbr_float_t lower_disp_limit; /* lower limit of graph */
343  dbr_float_t upper_alarm_limit;
344  dbr_float_t upper_warning_limit;
345  dbr_float_t lower_warning_limit;
346  dbr_float_t lower_alarm_limit;
347  dbr_float_t value; /* current value */
348 };
349 
350 /* structure for a graphic enumeration field */
351 struct dbr_gr_enum{
352  dbr_short_t status; /* status of value */
353  dbr_short_t severity; /* severity of alarm */
354  dbr_short_t no_str; /* number of strings */
355  char strs[MAX_ENUM_STATES][MAX_ENUM_STRING_SIZE];
356  /* state strings */
357  dbr_enum_t value; /* current value */
358 };
359 
360 /* structure for a graphic char field */
361 struct dbr_gr_char{
362  dbr_short_t status; /* status of value */
363  dbr_short_t severity; /* severity of alarm */
364  char units[MAX_UNITS_SIZE]; /* units of value */
365  dbr_char_t upper_disp_limit; /* upper limit of graph */
366  dbr_char_t lower_disp_limit; /* lower limit of graph */
367  dbr_char_t upper_alarm_limit;
368  dbr_char_t upper_warning_limit;
369  dbr_char_t lower_warning_limit;
370  dbr_char_t lower_alarm_limit;
371  dbr_char_t RISC_pad; /* RISC alignment */
372  dbr_char_t value; /* current value */
373 };
374 
375 /* structure for a graphic long field */
376 struct dbr_gr_long{
377  dbr_short_t status; /* status of value */
378  dbr_short_t severity; /* severity of alarm */
379  char units[MAX_UNITS_SIZE]; /* units of value */
380  dbr_long_t upper_disp_limit; /* upper limit of graph */
381  dbr_long_t lower_disp_limit; /* lower limit of graph */
382  dbr_long_t upper_alarm_limit;
383  dbr_long_t upper_warning_limit;
384  dbr_long_t lower_warning_limit;
385  dbr_long_t lower_alarm_limit;
386  dbr_long_t value; /* current value */
387 };
388 
389 /* structure for a graphic double field */
391  dbr_short_t status; /* status of value */
392  dbr_short_t severity; /* severity of alarm */
393  dbr_short_t precision; /* number of decimal places */
394  dbr_short_t RISC_pad0; /* RISC alignment */
395  char units[MAX_UNITS_SIZE]; /* units of value */
396  dbr_double_t upper_disp_limit; /* upper limit of graph */
397  dbr_double_t lower_disp_limit; /* lower limit of graph */
398  dbr_double_t upper_alarm_limit;
399  dbr_double_t upper_warning_limit;
400  dbr_double_t lower_warning_limit;
401  dbr_double_t lower_alarm_limit;
402  dbr_double_t value; /* current value */
403 };
404 
405 /* VALUES WITH STATUS, GRAPHIC and CONTROL STRUCTURES */
406 
407 /* structure for a control string */
408  /* not implemented; use struct_dbr_sts_string */
409 
410 /* structure for a control integer */
412  dbr_short_t status; /* status of value */
413  dbr_short_t severity; /* severity of alarm */
414  char units[MAX_UNITS_SIZE]; /* units of value */
415  dbr_short_t upper_disp_limit; /* upper limit of graph */
416  dbr_short_t lower_disp_limit; /* lower limit of graph */
417  dbr_short_t upper_alarm_limit;
418  dbr_short_t upper_warning_limit;
419  dbr_short_t lower_warning_limit;
420  dbr_short_t lower_alarm_limit;
421  dbr_short_t upper_ctrl_limit; /* upper control limit */
422  dbr_short_t lower_ctrl_limit; /* lower control limit */
423  dbr_short_t value; /* current value */
424 };
426  dbr_short_t status; /* status of value */
427  dbr_short_t severity; /* severity of alarm */
428  char units[MAX_UNITS_SIZE]; /* units of value */
429  dbr_short_t upper_disp_limit; /* upper limit of graph */
430  dbr_short_t lower_disp_limit; /* lower limit of graph */
431  dbr_short_t upper_alarm_limit;
432  dbr_short_t upper_warning_limit;
433  dbr_short_t lower_warning_limit;
434  dbr_short_t lower_alarm_limit;
435  dbr_short_t upper_ctrl_limit; /* upper control limit */
436  dbr_short_t lower_ctrl_limit; /* lower control limit */
437  dbr_short_t value; /* current value */
438 };
439 
440 /* structure for a control floating point field */
442  dbr_short_t status; /* status of value */
443  dbr_short_t severity; /* severity of alarm */
444  dbr_short_t precision; /* number of decimal places */
445  dbr_short_t RISC_pad; /* RISC alignment */
446  char units[MAX_UNITS_SIZE]; /* units of value */
447  dbr_float_t upper_disp_limit; /* upper limit of graph */
448  dbr_float_t lower_disp_limit; /* lower limit of graph */
449  dbr_float_t upper_alarm_limit;
450  dbr_float_t upper_warning_limit;
451  dbr_float_t lower_warning_limit;
452  dbr_float_t lower_alarm_limit;
453  dbr_float_t upper_ctrl_limit; /* upper control limit */
454  dbr_float_t lower_ctrl_limit; /* lower control limit */
455  dbr_float_t value; /* current value */
456 };
457 
458 /* structure for a control enumeration field */
460  dbr_short_t status; /* status of value */
461  dbr_short_t severity; /* severity of alarm */
462  dbr_short_t no_str; /* number of strings */
463  char strs[MAX_ENUM_STATES][MAX_ENUM_STRING_SIZE];
464  /* state strings */
465  dbr_enum_t value; /* current value */
466 };
467 
468 /* structure for a control char field */
470  dbr_short_t status; /* status of value */
471  dbr_short_t severity; /* severity of alarm */
472  char units[MAX_UNITS_SIZE]; /* units of value */
473  dbr_char_t upper_disp_limit; /* upper limit of graph */
474  dbr_char_t lower_disp_limit; /* lower limit of graph */
475  dbr_char_t upper_alarm_limit;
476  dbr_char_t upper_warning_limit;
477  dbr_char_t lower_warning_limit;
478  dbr_char_t lower_alarm_limit;
479  dbr_char_t upper_ctrl_limit; /* upper control limit */
480  dbr_char_t lower_ctrl_limit; /* lower control limit */
481  dbr_char_t RISC_pad; /* RISC alignment */
482  dbr_char_t value; /* current value */
483 };
484 
485 /* structure for a control long field */
487  dbr_short_t status; /* status of value */
488  dbr_short_t severity; /* severity of alarm */
489  char units[MAX_UNITS_SIZE]; /* units of value */
490  dbr_long_t upper_disp_limit; /* upper limit of graph */
491  dbr_long_t lower_disp_limit; /* lower limit of graph */
492  dbr_long_t upper_alarm_limit;
493  dbr_long_t upper_warning_limit;
494  dbr_long_t lower_warning_limit;
495  dbr_long_t lower_alarm_limit;
496  dbr_long_t upper_ctrl_limit; /* upper control limit */
497  dbr_long_t lower_ctrl_limit; /* lower control limit */
498  dbr_long_t value; /* current value */
499 };
500 
501 /* structure for a control double field */
503  dbr_short_t status; /* status of value */
504  dbr_short_t severity; /* severity of alarm */
505  dbr_short_t precision; /* number of decimal places */
506  dbr_short_t RISC_pad0; /* RISC alignment */
507  char units[MAX_UNITS_SIZE]; /* units of value */
508  dbr_double_t upper_disp_limit; /* upper limit of graph */
509  dbr_double_t lower_disp_limit; /* lower limit of graph */
510  dbr_double_t upper_alarm_limit;
511  dbr_double_t upper_warning_limit;
512  dbr_double_t lower_warning_limit;
513  dbr_double_t lower_alarm_limit;
514  dbr_double_t upper_ctrl_limit; /* upper control limit */
515  dbr_double_t lower_ctrl_limit; /* lower control limit */
516  dbr_double_t value; /* current value */
517 };
518 
519 #define dbr_size_n(TYPE,COUNT)\
520 ((unsigned)((COUNT)<0?dbr_size[TYPE]:dbr_size[TYPE]+((COUNT)-1)*dbr_value_size[TYPE]))
521 
522 /* size for each type - array indexed by the DBR_ type code */
523 LIBCA_API extern const unsigned short dbr_size[];
524 
525 /* size for each type's value - array indexed by the DBR_ type code */
526 LIBCA_API extern const unsigned short dbr_value_size[];
527 
528 #ifndef db_accessHFORdb_accessC
529 /* class for each type's value */
530 enum dbr_value_class {
531  dbr_class_int,
532  dbr_class_float,
533  dbr_class_string,
534  dbr_class_max};
535 
536 LIBCA_API extern const enum dbr_value_class dbr_value_class[LAST_BUFFER_TYPE+1];
537 
538 /*
539  * ptr to value given a pointer to the structure and the DBR type
540  */
541 #define dbr_value_ptr(PDBR, DBR_TYPE) \
542 ((void *)(((char *)PDBR)+dbr_value_offset[DBR_TYPE]))
543 
544 /*
545  * ptr to value given a pointer to the structure and the structure declaration
546  */
547 #define dbr_value_ptr_from_structure(PDBR, STRUCTURE)\
548 ((void *)(((char *)PDBR)+BYTE_OS(STRUCTURE, value)))
549 
550 LIBCA_API extern const unsigned short dbr_value_offset[LAST_BUFFER_TYPE+1];
551 
552 
553 /* union for each fetch buffers */
555  dbr_string_t strval; /* string max size */
556  dbr_short_t shrtval; /* short */
557  dbr_short_t intval; /* short */
558  dbr_float_t fltval; /* IEEE Float */
559  dbr_enum_t enmval; /* item number */
560  dbr_char_t charval; /* character */
561  dbr_long_t longval; /* long */
562  dbr_double_t doubleval; /* double */
563  struct dbr_sts_string sstrval; /* string field with status */
564  struct dbr_sts_short sshrtval; /* short field with status */
565  struct dbr_sts_float sfltval; /* float field with status */
566  struct dbr_sts_enum senmval; /* item number with status */
567  struct dbr_sts_char schrval; /* char field with status */
568  struct dbr_sts_long slngval; /* long field with status */
569  struct dbr_sts_double sdblval; /* double field with time */
570  struct dbr_time_string tstrval; /* string field with time */
571  struct dbr_time_short tshrtval; /* short field with time */
572  struct dbr_time_float tfltval; /* float field with time */
573  struct dbr_time_enum tenmval; /* item number with time */
574  struct dbr_time_char tchrval; /* char field with time */
575  struct dbr_time_long tlngval; /* long field with time */
576  struct dbr_time_double tdblval; /* double field with time */
577  struct dbr_sts_string gstrval; /* graphic string info */
578  struct dbr_gr_short gshrtval; /* graphic short info */
579  struct dbr_gr_float gfltval; /* graphic float info */
580  struct dbr_gr_enum genmval; /* graphic item info */
581  struct dbr_gr_char gchrval; /* graphic char info */
582  struct dbr_gr_long glngval; /* graphic long info */
583  struct dbr_gr_double gdblval; /* graphic double info */
584  struct dbr_sts_string cstrval; /* control string info */
585  struct dbr_ctrl_short cshrtval; /* control short info */
586  struct dbr_ctrl_float cfltval; /* control float info */
587  struct dbr_ctrl_enum cenmval; /* control item info */
588  struct dbr_ctrl_char cchrval; /* control char info */
589  struct dbr_ctrl_long clngval; /* control long info */
590  struct dbr_ctrl_double cdblval; /* control double info */
591  dbr_put_ackt_t putackt; /* item number */
592  dbr_put_acks_t putacks; /* item number */
593  struct dbr_sts_string sastrval; /* string field with status */
594  dbr_string_t classname; /* string max size */
595 };
596 
597 /*----------------------------------------------------------------------------
598 * repository for some useful PV database constants and utilities
599 *
600 * item dimensions
601 * db_strval_dim dimension for string values
602 * db_units_dim dimension for record units text
603 * db_desc_dim dimension for record description text
604 * db_name_dim dimension for channel names (record.field\0)
605 * db_state_dim number of states possible in a state table
606 * db_state_text_dim dimension for a state text string
607 * usage: char state_table[db_state_dim][db_state_text_dim]
608 *
609 * type checking macros -- return non-zero if condition is true, zero otherwise
610 *
611 * int dbf_type_is_valid(type) type is a valid DBF_xxx
612 * int dbr_type_is_valid(type) type is a valid DBR_xxx
613 * int dbr_type_is_plain(type) type is a valid plain DBR_xxx
614 * int dbr_type_is_STS(type) type is a valid DBR_STS_xxx
615 * int dbr_type_is_TIME(type) type is a valid DBR_TIME_xxx
616 * int dbr_type_is_GR(type) type is a valid DBR_GR_xxx
617 * int dbr_type_is_CTRL(type) type is a valid DBR_CTRL_xxx
618 * int dbr_type_is_STRING(type) type is a valid DBR_STRING_xxx
619 * int dbr_type_is_SHORT(type) type is a valid DBR_SHORT_xxx
620 * int dbr_type_is_FLOAT(type) type is a valid DBR_FLOAT_xxx
621 * int dbr_type_is_ENUM(type) type is a valid DBR_ENUM_xxx
622 * int dbr_type_is_CHAR(type) type is a valid DBR_CHAR_xxx
623 * int dbr_type_is_LONG(type) type is a valid DBR_LONG_xxx
624 * int dbr_type_is_DOUBLE(type) type is a valid DBR_DOUBLE_xxx
625 *
626 * type conversion macros
627 *
628 * char *dbf_type_to_text(type) returns text matching DBF_xxx
629 * void dbf_text_to_type(text, type) finds DBF_xxx matching text
630 * int dbf_type_to_DBR(type) returns DBR_xxx matching DBF_xxx
631 * int dbf_type_to_DBR_TIME(type) returns DBR_TIME_xxx matching DBF_xxx
632 * int dbf_type_to_DBR_GR(type) returns DBR_GR_xxx matching DBF_xxx
633 * int dbf_type_to_DBR_CTRL(type) returns DBR_CTRL_xxx matching DBF_xxx
634 * char *dbr_type_to_text(type) returns text matching DBR_xxx
635 * void dbr_text_to_type(text, type) finds DBR_xxx matching text
636 *---------------------------------------------------------------------------*/
637 #define db_strval_dim MAX_STRING_SIZE
638 #define db_units_dim MAX_UNITS_SIZE
639 #define db_desc_dim 24
640 #define db_name_dim 36
641 #define db_state_dim MAX_ENUM_STATES
642 #define db_state_text_dim MAX_ENUM_STRING_SIZE
643 
644 #define dbf_type_is_valid(type) ((type) >= 0 && (type) <= LAST_TYPE)
645 #define dbr_type_is_valid(type) ((type) >= 0 && (type) <= LAST_BUFFER_TYPE)
646 #define dbr_type_is_plain(type) \
647  ((type) >= DBR_STRING && (type) <= DBR_DOUBLE)
648 #define dbr_type_is_STS(type) \
649  ((type) >= DBR_STS_STRING && (type) <= DBR_STS_DOUBLE)
650 #define dbr_type_is_TIME(type) \
651  ((type) >= DBR_TIME_STRING && (type) <= DBR_TIME_DOUBLE)
652 #define dbr_type_is_GR(type) \
653  ((type) >= DBR_GR_STRING && (type) <= DBR_GR_DOUBLE)
654 #define dbr_type_is_CTRL(type) \
655  ((type) >= DBR_CTRL_STRING && (type) <= DBR_CTRL_DOUBLE)
656 #define dbr_type_is_STRING(type) \
657  ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \
658  (type)%(LAST_TYPE+1) == DBR_STRING)
659 #define dbr_type_is_SHORT(type) \
660  ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \
661  (type)%(LAST_TYPE+1) == DBR_SHORT)
662 #define dbr_type_is_FLOAT(type) \
663  ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \
664  (type)%(LAST_TYPE+1) == DBR_FLOAT)
665 #define dbr_type_is_ENUM(type) \
666  ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \
667  (type)%(LAST_TYPE+1) == DBR_ENUM)
668 #define dbr_type_is_CHAR(type) \
669  ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \
670  (type)%(LAST_TYPE+1) == DBR_CHAR)
671 #define dbr_type_is_LONG(type) \
672  ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \
673  (type)%(LAST_TYPE+1) == DBR_LONG)
674 #define dbr_type_is_DOUBLE(type) \
675  ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \
676  (type)%(LAST_TYPE+1) == DBR_DOUBLE)
677 
678 #define dbf_type_to_text(type) \
679  ( ((type) >= -1 && (type) < dbf_text_dim-2) ? \
680  dbf_text[type+1] : dbf_text_invalid )
681 
682 #define dbf_text_to_type(text, type) \
683  for (type=dbf_text_dim-3; type>=0; type--) { \
684  if (strcmp(text, dbf_text[type+1]) == 0) \
685  break; \
686  }
687 
688 #define dbr_type_to_text(type) \
689  ( ((type) >= 0 && (type) < dbr_text_dim) ? \
690  dbr_text[(type)] : dbr_text_invalid )
691 
692 #define dbr_text_to_type(text, type) \
693  for (type=dbr_text_dim-2; type>=0; type--) { \
694  if (strcmp(text, dbr_text[type]) == 0) \
695  break; \
696  }
697 
698 #define dbf_type_to_DBR(type) \
699  (((type) >= 0 && (type) <= dbf_text_dim-3) ? \
700  (type) : -1 )
701 
702 #define dbf_type_to_DBR_STS(type) \
703  (((type) >= 0 && (type) <= dbf_text_dim-3) ? \
704  (type) + (dbf_text_dim-2) : -1 )
705 
706 #define dbf_type_to_DBR_TIME(type) \
707  (((type) >= 0 && (type) <= dbf_text_dim-3) ? \
708  (type) + 2*(dbf_text_dim-2) : -1 )
709 
710 #define dbf_type_to_DBR_GR(type) \
711  (((type) >= 0 && (type) <= dbf_text_dim-3) ? \
712  (type) + 3*(dbf_text_dim-2) : -1 )
713 
714 #define dbf_type_to_DBR_CTRL(type) \
715  (((type) >= 0 && (type) <= dbf_text_dim-3) ? \
716  (type) + 4*(dbf_text_dim-2) : -1 )
717 
718 
719 LIBCA_API extern const char *dbf_text[LAST_TYPE+3];
720 LIBCA_API extern const short dbf_text_dim;
721 LIBCA_API extern const char *dbf_text_invalid;
722 
723 LIBCA_API extern const char *dbr_text[LAST_BUFFER_TYPE+1];
724 LIBCA_API extern const short dbr_text_dim;
725 LIBCA_API extern const char *dbr_text_invalid;
726 #endif /*db_accessHFORdb_accessC*/
727 
728 #ifdef __cplusplus
729 }
730 #endif
731 
732 #endif /* ifndef INC_db_access_H */
Definition: link.h:175
The core data types used by epics.
EPICS time stamp, for use from C code.
Definition: epicsTime.h:42
epicsType
Corresponding Type Codes (this enum must start at zero)
Definition: epicsTypes.h:108
EPICS time-stamps (epicsTimeStamp), epicsTime C++ class and C functions for handling wall-clock times...
char epicsOldString[MAX_STRING_SIZE]
!! Don&#39;t use this - it may vanish in the future !!
Definition: epicsTypes.h:75