From 0552f2bb721a9796d23edf86f1a5a92c54120939 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 19 Apr 2022 09:31:05 -0700 Subject: [PATCH] aao: add OMSL and DOL --- modules/database/src/std/rec/aaoRecord.c | 35 ++++++++++++++++++- .../database/src/std/rec/aaoRecord.dbd.pod | 34 +++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/modules/database/src/std/rec/aaoRecord.c b/modules/database/src/std/rec/aaoRecord.c index c9939b343..1aae712d0 100644 --- a/modules/database/src/std/rec/aaoRecord.c +++ b/modules/database/src/std/rec/aaoRecord.c @@ -44,6 +44,7 @@ #include "special.h" #include "cantProceed.h" #include "menuYesNo.h" +#include "menuOmsl.h" #define GEN_SIZE_OFFSET #include "aaoRecord.h" @@ -92,6 +93,7 @@ rset aaoRSET={ epicsExportAddress(rset,aaoRSET); static void monitor(aaoRecord *); +static long fetchValue(aaoRecord *, int); static long writeValue(aaoRecord *); static long init_record(struct dbCommon *pcommon, int pass) @@ -142,7 +144,7 @@ static long init_record(struct dbCommon *pcommon, int pass) recGblRecordError(S_dev_missingSup, prec, "aao: init_record"); return S_dev_missingSup; } - return 0; + return fetchValue(prec, 1); } static long process(struct dbCommon *pcommon) @@ -161,6 +163,9 @@ static long process(struct dbCommon *pcommon) if ( !pact ) { prec->udf = FALSE; + if(!!(status = fetchValue(prec, 0))) + return status; + /* Update the timestamp before writing output values so it * will be up to date if any downstream records fetch it via TSEL */ recGblGetTimeStampSimm(prec, prec->simm, NULL); @@ -339,6 +344,34 @@ static void monitor(aaoRecord *prec) db_post_events(prec, &prec->val, monitor_mask); } +static long fetchValue(aaoRecord *prec, int init) +{ + int isConst; + long status; + long nReq = prec->nelm; + + if(prec->omsl!=menuOmslclosed_loop) + return 0; + + isConst = dbLinkIsConstant(&prec->dol); + + if(init && isConst) { + status = dbLoadLinkArray(&prec->dol, prec->ftvl, prec->bptr, &nReq); + + } else if(!init && !isConst) { + status = dbGetLink(&prec->dol, prec->ftvl, prec->bptr, 0, &nReq); + + } else { + return 0; + } + + if(!status) { + prec->nord = nReq; + prec->udf = FALSE; + } + return status; +} + static long writeValue(aaoRecord *prec) { aaodset *pdset = (aaodset *) prec->dset; diff --git a/modules/database/src/std/rec/aaoRecord.dbd.pod b/modules/database/src/std/rec/aaoRecord.dbd.pod index fb47672d0..480634153 100644 --- a/modules/database/src/std/rec/aaoRecord.dbd.pod +++ b/modules/database/src/std/rec/aaoRecord.dbd.pod @@ -125,7 +125,28 @@ BPTR field holds the address of the array. The NORD field holds a counter of the number of elements that have been written to the output, -=fields VAL, BPTR, NORD +=fields VAL, BPTR, NORD, OMSL, DOL + +The following steps are performed in order during record processing. + +=head4 Fetch Value + +The OMSL menu field is used to determine whether the DOL link +field should be used during processing or not: + +=over + +=item * +If OMSL is C the DOL field are not used. +The new output value is taken from the VAL field, which may have been set from +elsewhere. + +=item * +If OMSL is C the DOL link field is read to obtain a value. + +=back + +OMSL and DOL were added to aaoRecord with Base UNRELEASED. =head3 Simulation Mode Parameters @@ -327,6 +348,17 @@ Scan forward link if necessary, set PACT FALSE, and return. promptgroup("50 - Output") interest(1) } + field(DOL,DBF_INLINK) { + prompt("Desired Output Link") + promptgroup("40 - Input") + interest(1) + } + field(OMSL,DBF_MENU) { + prompt("Output Mode Select") + promptgroup("50 - Output") + interest(1) + menu(menuOmsl) + } field(EGU,DBF_STRING) { prompt("Engineering Units") promptgroup("80 - Display")