EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dbAccessDefs.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 /* dbAccessDefs.h */
11 
12 #ifndef INCdbAccessDefsh
13 #define INCdbAccessDefsh
14 
15 #include "epicsTypes.h"
16 #include "epicsTime.h"
17 
18 #include "dbCoreAPI.h"
19 
20 #include "dbBase.h"
21 #include "dbAddr.h"
22 #include "recSup.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 
29 DBCORE_API extern struct dbBase *pdbbase;
30 DBCORE_API extern volatile int interruptAccept;
31 DBCORE_API extern int dbAccessDebugPUTF;
32 
33 /* The database field and request types are defined in dbFldTypes.h*/
34 /* Data Base Request Options */
35 #define DBR_STATUS 0x00000001
36 #define DBR_AMSG 0x00000002
37 #define DBR_UNITS 0x00000004
38 #define DBR_PRECISION 0x00000008
39 #define DBR_TIME 0x00000010
40 #define DBR_UTAG 0x00000020
41 #define DBR_ENUM_STRS 0x00000040
42 #define DBR_GR_LONG 0x00000080
43 #define DBR_GR_DOUBLE 0x00000100
44 #define DBR_CTRL_LONG 0x00000200
45 #define DBR_CTRL_DOUBLE 0x00000400
46 #define DBR_AL_LONG 0x00000800
47 #define DBR_AL_DOUBLE 0x00001000
48 
49 /**********************************************************************
50  * The next page contains macros for defining requests.
51  * As an example the following defines a buffer to accept an array
52  * of 10 float values + DBR_STATUS and DBR_TIME options
53  *
54  * struct {
55  * DBRstatus
56  * DBRtime
57  * epicsFloat32 value[10]
58  * } buffer;
59  *
60  * IMPORTANT!! The DBRoptions must be given in the order that they
61  * appear in the Data Base Request Options #defines
62  *
63  * The associated dbGetField call is:
64  *
65  * long options,number_elements;
66  * ...
67  * options = DBR_STATUS|DBR_TIME;
68  * number_elements = 10;
69  * rtnval=dbGetField(paddr,DBR_FLOAT,&buffer,&options,&number_elements);
70  *
71  * When dbGetField returns:
72  * rtnval is error status (0 means success)
73  * options has a bit set for each option that was accepted
74  * number_elements is actual number of elements obtained
75  *
76  * The individual items can be referred to by the expressions::
77  *
78  * buffer.status
79  * buffer.severity
80  * buffer.err_status
81  * buffer.epoch_seconds
82  * buffer.nano_seconds
83  * buffer.value[i]
84  *
85  * The following is also a valid declaration:
86  *
87  * typedef struct {
88  * DBRstatus
89  * DBRtime
90  * epicsFloat32 value[10]
91  * } MYBUFFER;
92  *
93  * With this definition you can give definitions such as the following:
94  *
95  * MYBUFFER *pbuf1;
96  * MYBUFFER buf;
97  *************************************************************************/
98 
99 /* Macros for defining each option */
100 #define DBRstatus \
101  epicsUInt16 status; /* alarm status */\
102  epicsUInt16 severity; /* alarm severity*/\
103  epicsUInt16 acks; /* alarm ack severity*/\
104  epicsUInt16 ackt; /* Acknowledge transient alarms?*/
105 #define DB_AMSG_SIZE 40
106 #define DBRamsg \
107  char amsg[DB_AMSG_SIZE];
108 #define DB_UNITS_SIZE 16
109 #define DBRunits \
110  char units[DB_UNITS_SIZE]; /* units */
111 #define DBRprecision union { \
112  long dp; /* number of decimal places*/\
113  double unused; /* for alignment */\
114  } precision;
115  /* precision.dp must be long to match the pointer arguments to
116  * RSET->get_precision() and recGblGetPrec(), which it's
117  * too late to change now. DBRprecision must be padded to
118  * maintain 8-byte alignment. */
119 #define DBRtime \
120  epicsTimeStamp time; /* time stamp*/
121 #define DBRutag \
122  epicsUTag utag;
123 #define DBRenumStrs \
124  epicsUInt32 no_str; /* number of strings*/\
125  epicsInt32 padenumStrs; /*padding to force 8 byte align*/\
126  char strs[DB_MAX_CHOICES][MAX_STRING_SIZE]; /* string values */
127 #define DBRgrLong \
128  epicsInt32 upper_disp_limit; /*upper limit of graph*/\
129  epicsInt32 lower_disp_limit; /*lower limit of graph*/
130 #define DBRgrDouble \
131  epicsFloat64 upper_disp_limit; /*upper limit of graph*/\
132  epicsFloat64 lower_disp_limit; /*lower limit of graph*/
133 #define DBRctrlLong \
134  epicsInt32 upper_ctrl_limit; /*upper limit of graph*/\
135  epicsInt32 lower_ctrl_limit; /*lower limit of graph*/
136 #define DBRctrlDouble \
137  epicsFloat64 upper_ctrl_limit; /*upper limit of graph*/\
138  epicsFloat64 lower_ctrl_limit; /*lower limit of graph*/
139 #define DBRalLong \
140  epicsInt32 upper_alarm_limit;\
141  epicsInt32 upper_warning_limit;\
142  epicsInt32 lower_warning_limit;\
143  epicsInt32 lower_alarm_limit;
144 #define DBRalDouble \
145  epicsFloat64 upper_alarm_limit;\
146  epicsFloat64 upper_warning_limit;\
147  epicsFloat64 lower_warning_limit;\
148  epicsFloat64 lower_alarm_limit;
149 
150 /* structures for each option type */
151 struct dbr_status {DBRstatus};
152 struct dbr_units {DBRunits};
153 struct dbr_precision {DBRprecision};
154 struct dbr_time {DBRtime};
155 struct dbr_enumStrs {DBRenumStrs};
156 struct dbr_grLong {DBRgrLong};
157 struct dbr_grDouble {DBRgrDouble};
158 struct dbr_ctrlLong {DBRctrlLong};
159 struct dbr_ctrlDouble {DBRctrlDouble};
160 struct dbr_alLong {DBRalLong};
161 struct dbr_alDouble {DBRalDouble};
162 /* sizes for each option structure */
163 #define dbr_status_size sizeof(struct dbr_status)
164 #define dbr_units_size sizeof(struct dbr_units)
165 #define dbr_precision_size sizeof(struct dbr_precision)
166 #define dbr_time_size sizeof(struct dbr_time)
167 #define dbr_enumStrs_size sizeof(struct dbr_enumStrs)
168 #define dbr_grLong_size sizeof(struct dbr_grLong)
169 #define dbr_grDouble_size sizeof(struct dbr_grDouble)
170 #define dbr_ctrlLong_size sizeof(struct dbr_ctrlLong)
171 #define dbr_ctrlDouble_size sizeof(struct dbr_ctrlDouble)
172 #define dbr_alLong_size sizeof(struct dbr_alLong)
173 #define dbr_alDouble_size sizeof(struct dbr_alDouble)
174 
175 #include "errMdef.h"
176 
177 #define S_db_notFound (M_dbAccess| 1) /*Process Variable Not Found*/
178 #define S_db_badDbrtype (M_dbAccess| 3) /*Illegal Database Request Type*/
179 #define S_db_noMod (M_dbAccess| 5) /*Attempt to modify noMod field*/
180 #define S_db_badLset (M_dbAccess| 7) /*Illegal Lock Set*/
181 #define S_db_precision (M_dbAccess| 9) /*get precision failed */
182 #define S_db_onlyOne (M_dbAccess|11) /*Only one element allowed*/
183 #define S_db_badChoice (M_dbAccess|13) /*Illegal choice*/
184 #define S_db_badField (M_dbAccess|15) /*Illegal field value*/
185 #define S_db_lsetLogic (M_dbAccess|17) /*Logic error generating lock sets*/
186 #define S_db_noLSET (M_dbAccess|21) /*No link support table or entry*/
187 #define S_db_noRSET (M_dbAccess|31) /*missing record support entry table*/
188 #define S_db_noSupport (M_dbAccess|33) /*RSET or DSXT routine not defined*/
189 #define S_db_BadSub (M_dbAccess|35) /*Subroutine not found*/
190 
191 #define S_db_Pending (M_dbAccess|37) /*Request is pending*/
192 
193 #define S_db_Blocked (M_dbAccess|39) /*Request is Blocked*/
194 #define S_db_putDisabled (M_dbAccess|41) /*putFields are disabled*/
195 #define S_db_badHWaddr (M_dbAccess|43) /*Hardware link type not on INP/OUT*/
196 #define S_db_bkptSet (M_dbAccess|53) /*Breakpoint already set*/
197 #define S_db_bkptNotSet (M_dbAccess|55) /*No breakpoint set in record*/
198 #define S_db_notStopped (M_dbAccess|57) /*Record not stopped*/
199 #define S_db_errArg (M_dbAccess|59) /*Error in argument*/
200 #define S_db_bkptLogic (M_dbAccess|61) /*Logic error in breakpoint routine*/
201 #define S_db_cntSpwn (M_dbAccess|63) /*Cannot spawn dbContTask*/
202 #define S_db_cntCont (M_dbAccess|65) /*Cannot resume dbContTask*/
203 #define S_db_noMemory (M_dbAccess|66) /*unable to allocate data structure from pool*/
204 #define S_db_notInit (M_dbAccess|67) /*Not initialized*/
205 #define S_db_bufFull (M_dbAccess|68) /*Buffer full*/
206 
207 struct dbEntry;
208 
209 DBCORE_API long dbPutSpecial(struct dbAddr *paddr,int pass);
210 DBCORE_API rset * dbGetRset(const struct dbAddr *paddr);
211 DBCORE_API long dbPutAttribute(
212  const char *recordTypename,const char *name,const char*value);
213 DBCORE_API int dbIsValueField(const struct dbFldDes *pdbFldDes);
214 DBCORE_API int dbGetFieldIndex(const struct dbAddr *paddr);
215 DBCORE_API long dbScanPassive(
216  struct dbCommon *pfrom,struct dbCommon *pto);
217 DBCORE_API long dbProcess(struct dbCommon *precord);
218 DBCORE_API long dbNameToAddr(const char *pname, struct dbAddr *paddr);
219 
224 DBCORE_API long dbEntryToAddr(const struct dbEntry *pdbentry,
225  struct dbAddr *paddr);
226 
231 DBCORE_API void dbInitEntryFromAddr(struct dbAddr *paddr,
232  struct dbEntry *pdbentry);
233 
238 DBCORE_API void dbInitEntryFromRecord(struct dbCommon *prec,
239  struct dbEntry *pdbentry);
240 
241 DBCORE_API devSup* dbDTYPtoDevSup(dbRecordType *prdes, int dtyp);
242 DBCORE_API devSup* dbDSETtoDevSup(dbRecordType *prdes, dset *pdset);
243 DBCORE_API long dbGetField(
244  struct dbAddr *,short dbrType,void *pbuffer,long *options,
245  long *nRequest,void *pfl);
246 DBCORE_API long dbGet(
247  struct dbAddr *,short dbrType,void *pbuffer,long *options,
248  long *nRequest,void *pfl);
249 DBCORE_API long dbPutField(
250  struct dbAddr *,short dbrType,const void *pbuffer,long nRequest);
251 DBCORE_API long dbPut(
252  struct dbAddr *,short dbrType,const void *pbuffer,long nRequest);
253 
254 typedef void(*SPC_ASCALLBACK)(struct dbCommon *);
255 /*dbSpcAsRegisterCallback called by access security */
256 DBCORE_API void dbSpcAsRegisterCallback(SPC_ASCALLBACK func);
257 DBCORE_API long dbBufferSize(
258  short dbrType,long options,long nRequest);
259 DBCORE_API long dbValueSize(short dbrType);
260 
261 /* Hook Routine */
262 
263 typedef void (*DB_LOAD_RECORDS_HOOK_ROUTINE)(const char* filename,
264  const char* substitutions);
265 DBCORE_API extern DB_LOAD_RECORDS_HOOK_ROUTINE dbLoadRecordsHook;
266 
267 DBCORE_API int dbLoadDatabase(
268  const char *filename, const char *path, const char *substitutions);
269 DBCORE_API int dbLoadRecords(
270  const char* filename, const char* substitutions);
271 
272 #ifdef __cplusplus
273 }
274 #endif
275 
276 #endif /*INCdbAccessDefsh*/
Definition: link.h:175
The core data types used by epics.
Declaration of dbCommon.
Definition: dbCommon.h:18
Definition: dbAddr.h:17
Definition: devSup.h:141
Definition: dbBase.h:39
Definition: dbBase.h:171
Definition: recSup.h:68
EPICS time-stamps (epicsTimeStamp), epicsTime C++ class and C functions for handling wall-clock times...