From 181f1e720fb462e38fa592c83c4df8983295a65e Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 26 Jul 2001 15:56:33 +0000 Subject: [PATCH] add support for RAWL RAWF --- src/dev/softDev/devAiSoftRaw.c | 62 ++++++++++++++++++++++------------ src/dev/softDev/devAoSoftRaw.c | 58 ++++++++++++++++++++----------- 2 files changed, 79 insertions(+), 41 deletions(-) diff --git a/src/dev/softDev/devAiSoftRaw.c b/src/dev/softDev/devAiSoftRaw.c index 4032ea751..346b2387e 100644 --- a/src/dev/softDev/devAiSoftRaw.c +++ b/src/dev/softDev/devAiSoftRaw.c @@ -34,19 +34,20 @@ * .04 10-10-92 jba replaced code with recGblGetLinkValue call * ... */ -#include -#include -#include +#include +#include +#include -#include "alarm.h" -#include "cvtTable.h" -#include "dbDefs.h" -#include "dbAccess.h" -#include "recGbl.h" -#include "recSup.h" -#include "devSup.h" -#include "link.h" -#include "aiRecord.h" +#include "alarm.h" +#include "cvtTable.h" +#include "dbDefs.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "recGbl.h" +#include "recSup.h" +#include "devSup.h" +#include "link.h" +#include "aiRecord.h" /* Create the dset for devAiSoftRaw */ static long init_record(); static long read_ai(); @@ -69,10 +70,9 @@ struct { special_linconv }; -static long init_record(pai) - struct aiRecord *pai; +static long init_record(aiRecord *pai) { - + special_linconv(pai,1); /* ai.inp must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/ switch (pai->inp.type) { case (CONSTANT) : @@ -87,11 +87,11 @@ static long init_record(pai) "devAiSoftRaw (init_record) Illegal INP field"); return(S_db_badField); } + special_linconv(pai,1); return(0); } -static long read_ai(pai) - struct aiRecord *pai; +static long read_ai( aiRecord *pai) { long status; @@ -99,9 +99,29 @@ static long read_ai(pai) return(0); } -static long special_linconv(pai,after) - struct aiRecord *pai; - int after; +static long special_linconv(aiRecord *pai,int after) { - return(0); + double eguf,egul,rawf,rawl; + double eslo,eoff; + + if(!after) return(0); + if(pai->rawf == pai->rawl) { + errlogPrintf("%s devAiSoftRaw RAWF == RAWL\n",pai->name); + return(0); + } + eguf = pai->eguf; + egul = pai->egul; + rawf = (double)pai->rawf; + rawl = (double)pai->rawl; + eslo = (eguf - egul)/(rawf - rawl); + eoff = (rawf*egul - rawl*eguf)/(rawf - rawl); + if(pai->eslo != eslo) { + pai->eslo = eslo; + db_post_events(pai,&pai->eslo,DBE_VALUE|DBE_LOG); + } + if(pai->eoff != eoff) { + pai->eoff = eoff; + db_post_events(pai,&pai->eoff,DBE_VALUE|DBE_LOG); + } + return(0); } diff --git a/src/dev/softDev/devAoSoftRaw.c b/src/dev/softDev/devAoSoftRaw.c index 5fa89ac91..a51ce6b8b 100644 --- a/src/dev/softDev/devAoSoftRaw.c +++ b/src/dev/softDev/devAoSoftRaw.c @@ -36,23 +36,25 @@ * ... */ -#include -#include -#include +#include +#include +#include -#include "alarm.h" -#include "dbDefs.h" -#include "dbAccess.h" -#include "recGbl.h" -#include "recSup.h" -#include "devSup.h" -#include "link.h" -#include "special.h" -#include "aoRecord.h" +#include "alarm.h" +#include "dbDefs.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "recGbl.h" +#include "recSup.h" +#include "devSup.h" +#include "link.h" +#include "special.h" +#include "aoRecord.h" static long init_record(); /* Create the dset for devAoSoftRaw */ +static long init_record(); static long write_ao(); static long special_linconv(); struct { @@ -72,14 +74,13 @@ struct { write_ao, special_linconv}; -static long init_record(pao) -struct aoRecord *pao; +static long init_record(aoRecord *pao) { + special_linconv(pao,1); return 0; } /* end init_record() */ -static long write_ao(pao) - struct aoRecord *pao; +static long write_ao(aoRecord *pao) { long status; @@ -88,13 +89,30 @@ static long write_ao(pao) return(status); } -static long special_linconv(pao,after) - struct aoRecord *pao; - int after; +static long special_linconv(aoRecord *pao, int after) { + double eguf,egul,rawf,rawl; + double eslo,eoff; if(!after) return(0); - + if(pao->rawf == pao->rawl) { + errlogPrintf("%s devAoSoftRaw RAWF == RAWL\n",pao->name); + return(0); + } + eguf = pao->eguf; + egul = pao->egul; + rawf = (double)pao->rawf; + rawl = (double)pao->rawl; + eslo = (eguf - egul)/(rawf - rawl); + eoff = (rawf*egul - rawl*eguf)/(rawf - rawl); + if(pao->eslo != eslo) { + pao->eslo = eslo; + db_post_events(pao,&pao->eslo,DBE_VALUE|DBE_LOG); + } + if(pao->eoff != eoff) { + pao->eoff = eoff; + db_post_events(pao,&pao->eoff,DBE_VALUE|DBE_LOG); + } return(0); }