45 #include "menuYesNo.h" 47 #define GEN_SIZE_OFFSET 48 #include "aaoRecord.h" 49 #undef GEN_SIZE_OFFSET 54 #define initialize NULL 56 static long process(
struct dbCommon *);
57 static long special(DBADDR *,
int);
58 #define get_value NULL 64 #define get_enum_str NULL 65 #define get_enum_strs NULL 66 #define put_enum_str NULL 69 #define get_alarm_double NULL 93 static void monitor(aaoRecord *);
94 static long writeValue(aaoRecord *);
96 static long init_record(
struct dbCommon *pcommon,
int pass)
98 struct aaoRecord *
prec = (
struct aaoRecord *)pcommon;
99 aaodset *pdset = (aaodset *)(prec->dset);
104 recGblRecordError(
S_dev_noDSET, prec,
"aao: init_record");
113 if (prec->nelm == 1) {
124 if (pdset->common.init_record) {
126 if ((status = pdset->common.init_record(pcommon)))
132 "aao: buffer calloc failed");
137 recGblInitSimm(pcommon, &prec->sscn, &prec->oldsimm, &prec->simm, &prec->siml);
140 if (pdset->common.number < 5 || pdset->write_aao ==
NULL) {
147 static long process(
struct dbCommon *pcommon)
149 struct aaoRecord *
prec = (
struct aaoRecord *)pcommon;
150 aaodset *pdset = (aaodset *)(prec->dset);
152 unsigned char pact = prec->pact;
154 if (pdset ==
NULL || pdset->write_aao ==
NULL) {
160 status = writeValue(prec);
161 if (!pact && prec->pact)
return 0;
165 recGblGetTimeStampSimm(prec, prec->simm,
NULL);
175 static long special(DBADDR *paddr,
int after)
177 aaoRecord *
prec = (aaoRecord *)(paddr->precord);
178 int special_type = paddr->special;
180 switch(special_type) {
182 if (dbGetFieldIndex(paddr) == aaoRecordSIMM) {
184 recGblSaveSimm(prec->sscn, &prec->oldsimm, prec->simm);
186 recGblCheckSimm((dbCommon *)prec, &prec->sscn, prec->oldsimm, prec->simm);
190 recGblDbaddrError(S_db_badChoice, paddr,
"aao: special");
191 return(S_db_badChoice);
197 aaoRecord *
prec = (aaoRecord *)paddr->precord;
199 paddr->no_elements = prec->nelm;
200 paddr->field_type = prec->ftvl;
201 paddr->field_size = dbValueSize(prec->ftvl);
202 paddr->dbr_field_type = prec->ftvl;
206 static long get_array_info(DBADDR *paddr,
long *no_elements,
long *offset)
208 aaoRecord *
prec = (aaoRecord *)paddr->precord;
210 paddr->pfield = prec->bptr;
211 *no_elements = prec->nord;
218 aaoRecord *
prec = (aaoRecord *)paddr->precord;
222 if (prec->nord > prec->nelm)
223 prec->nord = prec->nelm;
225 if (nord != prec->nord)
230 #define indexof(field) aaoRecord##field 232 static long get_units(DBADDR *paddr,
char *units)
234 aaoRecord *
prec = (aaoRecord *)paddr->precord;
236 switch (dbGetFieldIndex(paddr)) {
242 strncpy(units,prec->egu,DB_UNITS_SIZE);
247 static long get_precision(
const DBADDR *paddr,
long *precision)
249 aaoRecord *
prec = (aaoRecord *)paddr->precord;
251 *precision = prec->prec;
252 if (dbGetFieldIndex(paddr) !=
indexof(VAL))
253 recGblGetPrec(paddr, precision);
259 aaoRecord *
prec = (aaoRecord *)paddr->precord;
261 switch (dbGetFieldIndex(paddr)) {
263 pgd->upper_disp_limit = prec->hopr;
264 pgd->lower_disp_limit = prec->lopr;
267 pgd->upper_disp_limit = prec->nelm;
268 pgd->lower_disp_limit = 0;
271 recGblGetGraphicDouble(paddr, pgd);
278 aaoRecord *
prec = (aaoRecord *)paddr->precord;
280 switch (dbGetFieldIndex(paddr)) {
282 pcd->upper_ctrl_limit = prec->hopr;
283 pcd->lower_ctrl_limit = prec->lopr;
286 pcd->upper_ctrl_limit = prec->nelm;
287 pcd->lower_ctrl_limit = 0;
290 recGblGetControlDouble(paddr, pcd);
295 static void monitor(aaoRecord *
prec)
297 unsigned short monitor_mask;
298 unsigned int hash = 0;
300 monitor_mask = recGblResetAlarms(prec);
302 if (prec->mpst == aaoPOST_Always)
304 if (prec->apst == aaoPOST_Always)
308 if ((prec->mpst == aaoPOST_OnChange) ||
309 (prec->apst == aaoPOST_OnChange)) {
311 prec->nord * dbValueSize(prec->ftvl), 0);
314 if (hash != prec->hash) {
315 if (prec->mpst == aaoPOST_OnChange)
317 if (prec->apst == aaoPOST_OnChange)
323 db_post_events(prec, &prec->hash,
DBE_VALUE);
328 db_post_events(prec, &prec->val, monitor_mask);
331 static long writeValue(aaoRecord *
prec)
333 aaodset *pdset = (aaodset *) prec->dset;
337 status = recGblGetSimm((dbCommon *)prec, &prec->sscn, &prec->oldsimm, &prec->simm, &prec->siml);
341 switch (prec->simm) {
343 status = pdset->write_aao(prec);
348 if (prec->pact || (prec->sdly < 0.)) {
358 status = pdset->write_aao(prec);
361 epicsCallback *pvt = prec->simpvt;
363 pvt = calloc(1,
sizeof(epicsCallback));
366 if (pvt) callbackRequestProcessCallbackDelayed(pvt, prec->prio, prec, prec->sdly);
Miscellaneous macro definitions.
#define get_control_double
LIBCOM_API void * callocMustSucceed(size_t count, size_t size, const char *msg)
A calloc() that never returns NULL.
epicsExportAddress(rset, aaoRSET)
unsigned int epicsMemHash(const char *str, size_t length, unsigned int seed)
Routines for code that can't continue or return after an error.
#define get_graphic_double