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