From 4f0cc20e2b5f8abcd27d1609be99703ea59d58dc Mon Sep 17 00:00:00 2001 From: Evan Daykin Date: Tue, 9 Mar 2021 12:41:34 -0500 Subject: [PATCH] Feature: add SIMM=RAW to ao records --- modules/database/src/std/rec/aoRecord.c | 21 +++++++++++++------ modules/database/src/std/rec/aoRecord.dbd.pod | 4 ++-- modules/database/test/std/rec/simmTest.c | 18 ++++++++++++++-- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/modules/database/src/std/rec/aoRecord.c b/modules/database/src/std/rec/aoRecord.c index 022424054..11206277b 100644 --- a/modules/database/src/std/rec/aoRecord.c +++ b/modules/database/src/std/rec/aoRecord.c @@ -37,7 +37,7 @@ #include "recGbl.h" #include "menuConvert.h" #include "menuOmsl.h" -#include "menuYesNo.h" +#include "menuSimm.h" #include "menuIvoa.h" #define GEN_SIZE_OFFSET @@ -561,15 +561,24 @@ static long writeValue(aoRecord *prec) } switch (prec->simm) { - case menuYesNoNO: + case menuSimmNO: status = pdset->write_ao(prec); break; - case menuYesNoYES: { + case menuSimmYES: + case menuSimmRAW: + { recGblSetSevr(prec, SIMM_ALARM, prec->sims); - if (prec->pact || (prec->sdly < 0.)) { - status = dbPutLink(&prec->siol, DBR_DOUBLE, &prec->oval, 1); - prec->pact = FALSE; + if (prec->pact || (prec->sdly < 0.)) { + if(prec->simm == menuSimmYES){ + /* don't convert */ + status = dbPutLink(&prec->siol, DBR_DOUBLE, &prec->oval, 1); + } + else { /* prec->simm == menuSimmRAW*/ + /* convert */ + status = dbPutLink(&prec->siol, DBR_LONG, &prec->rval, 1); + } + prec->pact = FALSE; } else { /* !prec->pact && delay >= 0. */ epicsCallback *pvt = prec->simpvt; if (!pvt) { diff --git a/modules/database/src/std/rec/aoRecord.dbd.pod b/modules/database/src/std/rec/aoRecord.dbd.pod index 5fef0d09e..3789d1bef 100644 --- a/modules/database/src/std/rec/aoRecord.dbd.pod +++ b/modules/database/src/std/rec/aoRecord.dbd.pod @@ -263,7 +263,7 @@ processing. The following fields are used to operate the record in simulation mode. -If SIMM (fetched through SIML) is YES, the record is put in SIMS +If SIMM (fetched through SIML, if populated) is YES, the record is put in SIMS severity and the value is written through SIOL, without conversion. SSCN sets a different SCAN mechanism to use in simulation mode. SDLY sets a delay (in sec) that is used for asynchronous simulation @@ -557,7 +557,7 @@ for more information on simulation mode and its fields. prompt("Simulation Mode") special(SPC_MOD) interest(1) - menu(menuYesNo) + menu(menuSimm) } field(SIMS,DBF_MENU) { prompt("Simulation Mode Severity") diff --git a/modules/database/test/std/rec/simmTest.c b/modules/database/test/std/rec/simmTest.c index 17e4d7fe4..a253b791c 100644 --- a/modules/database/test/std/rec/simmTest.c +++ b/modules/database/test/std/rec/simmTest.c @@ -63,6 +63,7 @@ static char *rawSupp[] = { "bi", "mbbi", "mbbiDirect", + "ao" }; static @@ -77,6 +78,7 @@ int hasRawSimmSupport(const char *rectype) { static char nameVAL[PVNAMELENGTH]; static char nameB0[PVNAMELENGTH]; static char nameRVAL[PVNAMELENGTH]; +static char nameROFF[PVNAMELENGTH]; static char nameSGNL[PVNAMELENGTH]; static char nameSIMM[PVNAMELENGTH]; static char nameSIML[PVNAMELENGTH]; @@ -98,7 +100,7 @@ static char nameSimvalLEN[PVNAMELENGTH]; static void setNames(const char *name) { - SETNAME(VAL); SETNAME(B0); SETNAME(RVAL); SETNAME(SGNL); + SETNAME(VAL); SETNAME(B0); SETNAME(RVAL); SETNAME(ROFF); SETNAME(SGNL); SETNAME(SVAL); SETNAME(SIMM); SETNAME(SIML); SETNAME(SIOL); SETNAME(SIMS); SETNAME(SCAN); SETNAME(PROC); SETNAME(PACT); SETNAME(STAT); SETNAME(SEVR); SETNAME(TSE); @@ -399,6 +401,18 @@ void testSiolWrite(const char *name, testdbPutFieldOk(nameVAL, DBR_LONG, 1); testdbGetFieldEqual(nameSimval, DBR_USHORT, 1); + if(hasRawSimmSupport(name)){ + testDiag("in simmRAW, RVAL should be written to SIOL"); + testDiag("SIML overrides SIMM, disable it here"); + testdbPutFieldOk(nameSIML, DBR_STRING, ""); + testdbPutFieldOk(nameSIMM, DBR_STRING, "RAW"); + testdbPutFieldOk(nameROFF, DBR_ULONG, 2); + testdbPutFieldOk(nameVAL, DBR_DOUBLE, 5.); + testdbGetFieldEqual(nameRVAL, DBR_LONG, 3); + testdbGetFieldEqual(nameSimval, DBR_DOUBLE, 3.); + testdbPutFieldOk(nameSIML, DBR_STRING, nameSimmode); + } + /* Set TSE to -2 (from device) and reprocess: timestamp is taken from IOC */ epicsTimeGetCurrent(&now); testdbPutFieldOk(nameTSE, DBR_SHORT, -2); @@ -502,7 +516,7 @@ void testAllRecTypes(void) MAIN(simmTest) { - testPlan(1176); + testPlan(1219); startSimmTestIoc("simmTest.db"); testSimmSetup();