From ca61aed01e415781fbbadf5b6449a46ec1f6ae1d Mon Sep 17 00:00:00 2001 From: "Janet B. Anderson" Date: Thu, 5 Dec 1991 13:28:52 +0000 Subject: [PATCH] jba Moved set and reset of alarm stat and sevr to macros --- src/rec/recAi.c | 63 ++++++++------------------- src/rec/recAo.c | 73 +++++++++---------------------- src/rec/recBi.c | 31 +++---------- src/rec/recBo.c | 36 +++------------ src/rec/recCalc.c | 68 ++++++++--------------------- src/rec/recCompress.c | 21 ++------- src/rec/recFanout.c | 31 +++---------- src/rec/recLongin.c | 75 ++++++++++--------------------- src/rec/recLongout.c | 65 ++++++++------------------- src/rec/recMbbi.c | 33 +++----------- src/rec/recMbbo.c | 44 ++++--------------- src/rec/recPermissive.c | 11 +---- src/rec/recPid.c | 74 ++++++++----------------------- src/rec/recPulseCounter.c | 31 +++++-------- src/rec/recPulseDelay.c | 22 +++++----- src/rec/recPulseTrain.c | 34 ++++++--------- src/rec/recSel.c | 84 ++++++++++------------------------- src/rec/recState.c | 11 +---- src/rec/recSteppermotor.c | 92 ++++++++++----------------------------- src/rec/recStringin.c | 12 +---- src/rec/recStringout.c | 16 ++----- src/rec/recSub.c | 75 +++++++++---------------------- src/rec/recWaveform.c | 11 +---- 23 files changed, 263 insertions(+), 750 deletions(-) diff --git a/src/rec/recAi.c b/src/rec/recAi.c index 339e40b36..04c292966 100644 --- a/src/rec/recAi.c +++ b/src/rec/recAi.c @@ -56,6 +56,7 @@ * .16 04-18-90 mrk extensible record and device support * .17 09-18-91 jba fixed bug in break point table conversion * .18 09-30-91 jba Moved break point table conversion to libCom + * .19 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -297,10 +298,7 @@ static void alarm(pai) double val=pai->val; if(pai->udf == TRUE ){ - if (pai->nsevnsta = UDF_ALARM; - pai->nsev = VALID_ALARM; - } + recGblSetSevr(pai,UDF_ALARM,VALID_ALARM); return; } /* if difference is not > hysterisis use lalm not val */ @@ -309,43 +307,27 @@ static void alarm(pai) if (ftemp < pai->hyst) val=pai->lalm; /* alarm condition hihi */ - if (pai->nsevhhsv){ - if (val > pai->hihi){ - pai->lalm = val; - pai->nsta = HIHI_ALARM; - pai->nsev = pai->hhsv; - return; - } + if (val > pai->hihi && recGblSetSevr(pai,HIHI_ALARM,pai->hhsv)){ + pai->lalm = val; + return; } /* alarm condition lolo */ - if (pai->nsevllsv){ - if (val < pai->lolo){ - pai->lalm = val; - pai->nsta = LOLO_ALARM; - pai->nsev = pai->llsv; - return; - } + if (val < pai->lolo && recGblSetSevr(pai,LOLO_ALARM,pai->llsv)){ + pai->lalm = val; + return; } /* alarm condition high */ - if (pai->nsevhsv){ - if (val > pai->high){ - pai->lalm = val; - pai->nsta = HIGH_ALARM; - pai->nsev =pai->hsv; - return; - } + if (val > pai->high && recGblSetSevr(pai,HIGH_ALARM,pai->hsv)){ + pai->lalm = val; + return; } - /* alarm condition lolo */ - if (pai->nsevlsv){ - if (val < pai->low){ - pai->lalm = val; - pai->nsta = LOW_ALARM; - pai->nsev = pai->lsv; - return; - } + /* alarm condition low */ + if (val < pai->low && recGblSetSevr(pai,LOW_ALARM,pai->lsv)){ + pai->lalm = val; + return; } return; } @@ -372,10 +354,7 @@ struct aiRecord *pai; } else { /* must use breakpoint table */ if (cvtRawToEngBpt(&val,pai->linr,pai->init,&pai->pbrk,&pai->lbrk)!=0) { - if(pai->nsev < VALID_ALARM) { - pai->nsta = SOFT_ALARM; - pai->nsev = VALID_ALARM; - } + recGblSetSevr(pai,SOFT_ALARM,VALID_ALARM); } } @@ -398,15 +377,7 @@ static void monitor(pai) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pai->stat; - sevr=pai->sevr; - nsta=pai->nsta; - nsev=pai->nsev; - /*set current stat and sevr*/ - pai->stat = nsta; - pai->sevr = nsev; - pai->nsta = 0; - pai->nsev = 0; + recGblResetSevr(pai,stat,sevr,nsta,nsev); monitor_mask = 0; diff --git a/src/rec/recAo.c b/src/rec/recAo.c index 7fb5cb41f..9bd60895a 100644 --- a/src/rec/recAo.c +++ b/src/rec/recAo.c @@ -51,6 +51,7 @@ * .18 07-27-90 lrd implement the output to a database record * .19 10-10-90 mrk extensible record and device support * .20 09-25-91 jba added breakpoint table conversion + * .21 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -291,8 +292,8 @@ static long get_control_double(paddr,pcd) { struct aoRecord *pao=(struct aoRecord *)paddr->precord; - pcd->upper_ctrl_limit = pao->hopr; - pcd->lower_ctrl_limit = pao->lopr; + pcd->upper_ctrl_limit = pao->drvh; + pcd->lower_ctrl_limit = pao->drvl; return(0); } static long get_alarm_double(paddr,pad) @@ -316,10 +317,7 @@ static void alarm(pao) double val=pao->val; if(pao->udf == TRUE ){ - if (pao->nsevnsta = UDF_ALARM; - pao->nsev = VALID_ALARM; - } + recGblSetSevr(pao,UDF_ALARM,VALID_ALARM); return; } @@ -329,47 +327,30 @@ static void alarm(pao) if (ftemp < pao->hyst) val=pao->lalm; /* alarm condition hihi */ - if (pao->nsevhhsv){ - if (val > pao->hihi){ - pao->lalm = val; - pao->nsta = HIHI_ALARM; - pao->nsev = pao->hhsv; - return; - } + if (val > pao->hihi && recGblSetSevr(pao,HIHI_ALARM,pao->hhsv)){ + pao->lalm = val; + return; } /* alarm condition lolo */ - if (pao->nsevllsv){ - if (val < pao->lolo){ - pao->lalm = val; - pao->nsta = LOLO_ALARM; - pao->nsev = pao->llsv; - return; - } + if (val < pao->lolo && recGblSetSevr(pao,LOLO_ALARM,pao->llsv)){ + pao->lalm = val; + return; } /* alarm condition high */ - if (pao->nsevhsv){ - if (val > pao->high){ - pao->lalm = val; - pao->nsta = HIGH_ALARM; - pao->nsev =pao->hsv; - return; - } + if (val > pao->high && recGblSetSevr(pao,HIGH_ALARM,pao->hsv)){ + pao->lalm = val; + return; } - /* alarm condition lolo */ - if (pao->nsevlsv){ - if (val < pao->low){ - pao->lalm = val; - pao->nsta = LOW_ALARM; - pao->nsev = pao->lsv; - return; - } + /* alarm condition low */ + if (val < pao->low && recGblSetSevr(pao,LOW_ALARM,pao->lsv)){ + pao->lalm = val; + return; } return; } - static int convert(pao) struct aoRecord *pao; @@ -392,10 +373,7 @@ static int convert(pao) &value,&options,&nRequest); pao->pact = save_pact; if(status) { - if(pao->nsevnsta = LINK_ALARM; - pao->nsev=VALID_ALARM; - } + recGblSetSevr(pao,LINK_ALARM,VALID_ALARM); return(1); } if (pao->oif == OUTPUT_INCREMENTAL) value += pao->val; @@ -433,10 +411,7 @@ static int convert(pao) } }else{ if(cvtEngToRawBpt(&value,pao->linr,pao->init,&pao->pbrk,&pao->lbrk)!=0){ - if (pao->nsevnsta=SOFT_ALARM; - pao->nsev=VALID_ALARM; - } + recGblSetSevr(pao,SOFT_ALARM,VALID_ALARM); return(1); } pao->rval=value; @@ -453,15 +428,7 @@ static void monitor(pao) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pao->stat; - sevr=pao->sevr; - nsta=pao->nsta; - nsev=pao->nsev; - /*set current stat and sevr*/ - pao->stat = nsta; - pao->sevr = nsev; - pao->nsta = 0; - pao->nsev = 0; + recGblResetSevr(pao,stat,sevr,nsta,nsev); monitor_mask = 0; diff --git a/src/rec/recBi.c b/src/rec/recBi.c index 6b1e34049..a5fee29a5 100644 --- a/src/rec/recBi.c +++ b/src/rec/recBi.c @@ -45,6 +45,7 @@ * .11 04-11-90 lrd make local variables static * .12 10-10-90 mrk Made changes for new record and device support * .13 10-24-91 jba Moved comment + * .14 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -229,33 +230,21 @@ static void alarm(pbi) if(pbi->udf == TRUE){ - if (pbi->nsevnsta = UDF_ALARM; - pbi->nsev = VALID_ALARM; - } + recGblSetSevr(pbi,UDF_ALARM,VALID_ALARM); return; } if(val>1)return; /* check for state alarm */ if (val == 0){ - if (pbi->nsevzsv){ - pbi->nsta = STATE_ALARM; - pbi->nsev = pbi->zsv; - } + recGblSetSevr(pbi,STATE_ALARM,pbi->zsv); }else{ - if (pbi->nsevosv){ - pbi->nsta = STATE_ALARM; - pbi->nsev = pbi->osv; - } + recGblSetSevr(pbi,STATE_ALARM,pbi->osv); } /* check for cos alarm */ if(val == pbi->lalm) return; - if (pbi->nsevcosv) { - pbi->nsta = COS_ALARM; - pbi->nsev = pbi->cosv; - } + recGblSetSevr(pbi,COS_ALARM,pbi->cosv); pbi->lalm = val; return; } @@ -267,15 +256,7 @@ static void monitor(pbi) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pbi->stat; - sevr=pbi->sevr; - nsta=pbi->nsta; - nsev=pbi->nsev; - /*set current stat and sevr*/ - pbi->stat = nsta; - pbi->sevr = nsev; - pbi->nsta = 0; - pbi->nsev = 0; + recGblResetSevr(pbi,stat,sevr,nsta,nsev); monitor_mask = 0; diff --git a/src/rec/recBo.c b/src/rec/recBo.c index 67947a1a2..a4a887ba8 100644 --- a/src/rec/recBo.c +++ b/src/rec/recBo.c @@ -51,6 +51,7 @@ * .15 04-11-90 lrd make locals static * .16 05-02-90 lrd fix initial value set in the DOL field * .17 10-10-90 mrk Changes for record and device support + * .18 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -214,10 +215,7 @@ static long process(paddr) pbo->val = val; pbo->udf = FALSE; }else { - if(pbo->nsev < VALID_ALARM) { - pbo->nsev = VALID_ALARM; - pbo->nsta = LINK_ALARM; - } + recGblSetSevr(pbo,LINK_ALARM,VALID_ALARM); } } if ( pbo->mask != 0 ) { @@ -310,31 +308,19 @@ static void alarm(pbo) /* check for udf alarm */ if(pbo->udf == TRUE ){ - if (pbo->nsevnsta = UDF_ALARM; - pbo->nsev = VALID_ALARM; - } + recGblSetSevr(pbo,UDF_ALARM,VALID_ALARM); } /* check for state alarm */ if (val == 0){ - if (pbo->nsevzsv){ - pbo->nsta = STATE_ALARM; - pbo->nsev = pbo->zsv; - } + recGblSetSevr(pbo,STATE_ALARM,pbo->zsv); }else{ - if (pbo->nsevosv){ - pbo->nsta = STATE_ALARM; - pbo->nsev = pbo->osv; - } + recGblSetSevr(pbo,STATE_ALARM,pbo->osv); } /* check for cos alarm */ if(val == pbo->lalm) return; - if (pbo->nsevcosv) { - pbo->nsta = COS_ALARM; - pbo->nsev = pbo->cosv; - } + recGblSetSevr(pbo,COS_ALARM,pbo->cosv); pbo->lalm = val; return; } @@ -346,15 +332,7 @@ static void monitor(pbo) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pbo->stat; - sevr=pbo->sevr; - nsta=pbo->nsta; - nsev=pbo->nsev; - /*set current stat and sevr*/ - pbo->stat = nsta; - pbo->sevr = nsev; - pbo->nsta = 0; - pbo->nsev = 0; + recGblResetSevr(pbo,stat,sevr,nsta,nsev); monitor_mask = 0; diff --git a/src/rec/recCalc.c b/src/rec/recCalc.c index c13d44829..7ae002539 100644 --- a/src/rec/recCalc.c +++ b/src/rec/recCalc.c @@ -58,6 +58,7 @@ * .18 10-10-90 mrk Made changes for new record support * Note that all calc specific details moved * to libCalc + * .19 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -150,10 +151,7 @@ static long process(paddr) pcalc->pact = TRUE; if(fetch_values(pcalc)==0) { if(calcPerform(&pcalc->a,&pcalc->val,pcalc->rpcl)) { - if(pcalc->nsevnsta = CALC_ALARM; - pcalc->nsev = VALID_ALARM; - } + recGblSetSevr(pcalc,CALC_ALARM,VALID_ALARM); } else pcalc->udf = FALSE; } tsLocalTime(&pcalc->time); @@ -263,10 +261,7 @@ static void alarm(pcalc) double val=pcalc->val; if(pcalc->udf == TRUE ) { - if(pcalc->nsevnsev = VALID_ALARM; - pcalc->nsta = UDF_ALARM; - } + recGblSetSevr(pcalc,UDF_ALARM,VALID_ALARM); return; } /* if difference is not > hysterisis use lalm not val */ @@ -275,43 +270,27 @@ static void alarm(pcalc) if (ftemp < pcalc->hyst) val=pcalc->lalm; /* alarm condition hihi */ - if (pcalc->nsevhhsv){ - if (val > pcalc->hihi){ - pcalc->lalm = val; - pcalc->nsta = HIHI_ALARM; - pcalc->nsev = pcalc->hhsv; - return; - } + if (val > pcalc->hihi && recGblSetSevr(pcalc,HIHI_ALARM,pcalc->hhsv)){ + pcalc->lalm = val; + return; } /* alarm condition lolo */ - if (pcalc->nsevllsv){ - if (val < pcalc->lolo){ - pcalc->lalm = val; - pcalc->nsta = LOLO_ALARM; - pcalc->nsev = pcalc->llsv; - return; - } + if (val < pcalc->lolo && recGblSetSevr(pcalc,LOLO_ALARM,pcalc->llsv)){ + pcalc->lalm = val; + return; } /* alarm condition high */ - if (pcalc->nsevhsv){ - if (val > pcalc->high){ - pcalc->lalm = val; - pcalc->nsta = HIGH_ALARM; - pcalc->nsev =pcalc->hsv; - return; - } + if (val > pcalc->high && recGblSetSevr(pcalc,HIGH_ALARM,pcalc->hsv)){ + pcalc->lalm = val; + return; } - /* alarm condition lolo */ - if (pcalc->nsevlsv){ - if (val < pcalc->low){ - pcalc->lalm = val; - pcalc->nsta = LOW_ALARM; - pcalc->nsev = pcalc->lsv; - return; - } + /* alarm condition low */ + if (val < pcalc->low && recGblSetSevr(pcalc,LOW_ALARM,pcalc->lsv)){ + pcalc->lalm = val; + return; } return; } @@ -327,15 +306,7 @@ static void monitor(pcalc) int i; /* get previous stat and sevr and new stat and sevr*/ - stat=pcalc->stat; - sevr=pcalc->sevr; - nsta=pcalc->nsta; - nsev=pcalc->nsev; - /*set current stat and sevr*/ - pcalc->stat = nsta; - pcalc->sevr = nsev; - pcalc->nsta = 0; - pcalc->nsev = 0; + recGblResetSevr(pcalc,stat,sevr,nsta,nsev); monitor_mask = 0; @@ -396,10 +367,7 @@ struct calcRecord *pcalc; status = dbGetLink(&plink->value.db_link,pcalc,DBR_DOUBLE, pvalue,&options,&nRequest); if(status!=0) { - if(pcalc->nsevnsev=VALID_ALARM; - pcalc->nsta=LINK_ALARM; - } + recGblSetSevr(pcalc,LINK_ALARM,VALID_ALARM); return(-1); } diff --git a/src/rec/recCompress.c b/src/rec/recCompress.c index 96dc92cc9..8a72715e7 100644 --- a/src/rec/recCompress.c +++ b/src/rec/recCompress.c @@ -48,6 +48,7 @@ * .09 07-26-90 lrd fixed the N-to-1 character compression * value was not initialized * .10 10-11-90 mrk Made changes for new record support + * .11 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -149,10 +150,7 @@ static long process(paddr) if (pcompress->inp.type != DB_LINK) { status=0; }else if (pcompress->wptr == NULL) { - if(pcompress->nsevnsta = READ_ALARM; - pcompress->nsev = VALID_ALARM; - } + recGblSetSevr(pcompress,READ_ALARM,VALID_ALARM); status=0; } else { struct dbAddr *pdbAddr = @@ -163,10 +161,7 @@ static long process(paddr) if(dbGetLink(&pcompress->inp.value.db_link,pcompress,DBR_DOUBLE,pcompress->wptr, &options,&no_elements)!=0){ - if(pcompress->nsev < VALID_ALARM) { - pcompress->nsev = VALID_ALARM; - pcompress->nsta = LINK_ALARM; - } + recGblSetSevr(pcompress,LINK_ALARM,VALID_ALARM); } if(alg==AVERAGE) { @@ -319,15 +314,7 @@ static void monitor(pcompress) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pcompress->stat; - sevr=pcompress->sevr; - nsta=pcompress->nsta; - nsev=pcompress->nsev; - /*set current stat and sevr*/ - pcompress->stat = nsta; - pcompress->sevr = nsev; - pcompress->nsta = 0; - pcompress->nsev = 0; + recGblResetSevr(pcompress,stat,sevr,nsta,nsev); monitor_mask = 0; diff --git a/src/rec/recFanout.c b/src/rec/recFanout.c index 43484359e..dbf0fee09 100644 --- a/src/rec/recFanout.c +++ b/src/rec/recFanout.c @@ -39,6 +39,7 @@ * .07 10-31-90 mrk extensible record and device support * .08 09-25-91 jba added input link for seln * .09 09-26-91 jba added select_mask option + * .10 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -131,10 +132,7 @@ static long process(paddr) status=dbGetLink(&(pfanout->sell.value.db_link),pfanout,DBR_USHORT, &(pfanout->seln),&options,&nRequest); if(status!=0) { - if (pfanout->nsevnsev = VALID_ALARM; - pfanout->nsta = LINK_ALARM; - } + recGblSetSevr(pfanout,LINK_ALARM,VALID_ALARM); } } switch (pfanout->selm){ @@ -148,10 +146,7 @@ static long process(paddr) break; case (SELECTED): if(pfanout->seln<0 || pfanout->seln>6) { - if(pfanout->nsevnsev = VALID_ALARM; - pfanout->nsta = SOFT_ALARM; - } + recGblSetSevr(pfanout,SOFT_ALARM,VALID_ALARM); break; } if(pfanout->seln==0) { @@ -166,10 +161,7 @@ static long process(paddr) break; } if(pfanout->seln<0 || pfanout->seln>63 ) { - if(pfanout->nsevnsev = VALID_ALARM; - pfanout->nsta = SOFT_ALARM; - } + recGblSetSevr(pfanout,SOFT_ALARM,VALID_ALARM); break; } plink=&(pfanout->lnk1); @@ -179,24 +171,13 @@ static long process(paddr) } break; default: - if(pfanout->nsevnsev = VALID_ALARM; - pfanout->nsta = SOFT_ALARM; - } + recGblSetSevr(pfanout,SOFT_ALARM,VALID_ALARM); } pfanout->udf=FALSE; tsLocalTime(&pfanout->time); /* check monitors*/ /* get previous stat and sevr and new stat and sevr*/ - stat=pfanout->stat; - sevr=pfanout->sevr; - nsta=pfanout->nsta; - nsev=pfanout->nsev; - /*set current stat and sevr*/ - pfanout->stat = nsta; - pfanout->sevr = nsev; - pfanout->nsta = 0; - pfanout->nsev = 0; + recGblResetSevr(pfanout,stat,sevr,nsta,nsev); if((stat!=nsta || sevr!=nsev)){ db_post_events(pfanout,&pfanout->stat,DBE_VALUE); db_post_events(pfanout,&pfanout->sevr,DBE_VALUE); diff --git a/src/rec/recLongin.c b/src/rec/recLongin.c index 1abfe54f2..a5148832c 100644 --- a/src/rec/recLongin.c +++ b/src/rec/recLongin.c @@ -29,7 +29,7 @@ * * Modification Log: * ----------------- - * .01 mm-dd-yy iii Comment + * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ @@ -217,10 +217,7 @@ static void alarm(plongin) long val=plongin->val; if(plongin->udf == TRUE ){ - if (plongin->nsevnsta = UDF_ALARM; - plongin->nsev = VALID_ALARM; - } + recGblSetSevr(plongin,UDF_ALARM,VALID_ALARM); return; } /* if difference is not > hysterisis use lalm not val */ @@ -228,46 +225,30 @@ static void alarm(plongin) if(ftemp<0) ftemp = -ftemp; if (ftemp < plongin->hyst) val=plongin->lalm; - /* alarm condition hihi */ - if (plongin->nsevhhsv){ - if (val > plongin->hihi){ - plongin->lalm = val; - plongin->nsta = HIHI_ALARM; - plongin->nsev = plongin->hhsv; - return; - } - } + /* alarm condition hihi */ + if (val > plongin->hihi && recGblSetSevr(plongin,HIHI_ALARM,plongin->hhsv)){ + plongin->lalm = val; + return; + } - /* alarm condition lolo */ - if (plongin->nsevllsv){ - if (val < plongin->lolo){ - plongin->lalm = val; - plongin->nsta = LOLO_ALARM; - plongin->nsev = plongin->llsv; - return; - } - } + /* alarm condition lolo */ + if (val < plongin->lolo && recGblSetSevr(plongin,LOLO_ALARM,plongin->llsv)){ + plongin->lalm = val; + return; + } - /* alarm condition high */ - if (plongin->nsevhsv){ - if (val > plongin->high){ - plongin->lalm = val; - plongin->nsta = HIGH_ALARM; - plongin->nsev =plongin->hsv; - return; - } - } + /* alarm condition high */ + if (val > plongin->high && recGblSetSevr(plongin,HIGH_ALARM,plongin->hsv)){ + plongin->lalm = val; + return; + } - /* alarm condition lolo */ - if (plongin->nsevlsv){ - if (val < plongin->low){ - plongin->lalm = val; - plongin->nsta = LOW_ALARM; - plongin->nsev = plongin->lsv; - return; - } - } - return; + /* alarm condition low */ + if (val < plongin->low && recGblSetSevr(plongin,LOW_ALARM,plongin->lsv)){ + plongin->lalm = val; + return; + } + return; } static void monitor(plongin) @@ -278,15 +259,7 @@ static void monitor(plongin) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=plongin->stat; - sevr=plongin->sevr; - nsta=plongin->nsta; - nsev=plongin->nsev; - /*set current stat and sevr*/ - plongin->stat = nsta; - plongin->sevr = nsev; - plongin->nsta = 0; - plongin->nsev = 0; + recGblResetSevr(plongin,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; diff --git a/src/rec/recLongout.c b/src/rec/recLongout.c index 586c3e297..f4dd58836 100644 --- a/src/rec/recLongout.c +++ b/src/rec/recLongout.c @@ -29,7 +29,7 @@ * * Modification Log: * ----------------- - * .01 mm-dd-yy iii Comment + * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ @@ -148,10 +148,7 @@ static long process(paddr) DBR_LONG,&plongout->val,&options,&nRequest); plongout->pact = FALSE; if(status!=0){ - if(plongout->nsev < VALID_ALARM) { - plongout->nsev = VALID_ALARM; - plongout->nsta = LINK_ALARM; - } + recGblSetSevr(plongout,LINK_ALARM,VALID_ALARM); } else plongout->udf=FALSE; } } @@ -240,10 +237,7 @@ static void alarm(plongout) long val=plongout->val; if(plongout->udf == TRUE ){ - if (plongout->nsevnsta = UDF_ALARM; - plongout->nsev = VALID_ALARM; - } + recGblSetSevr(plongout,UDF_ALARM,VALID_ALARM); return; } @@ -253,47 +247,30 @@ static void alarm(plongout) if (ftemp < plongout->hyst) val=plongout->lalm; /* alarm condition hihi */ - if (plongout->nsevhhsv){ - if (val > plongout->hihi){ - plongout->lalm = val; - plongout->nsta = HIHI_ALARM; - plongout->nsev = plongout->hhsv; - return; - } + if (val > plongout->hihi && recGblSetSevr(plongout,HIHI_ALARM,plongout->hhsv)){ + plongout->lalm = val; + return; } /* alarm condition lolo */ - if (plongout->nsevllsv){ - if (val < plongout->lolo){ - plongout->lalm = val; - plongout->nsta = LOLO_ALARM; - plongout->nsev = plongout->llsv; - return; - } + if (val < plongout->lolo && recGblSetSevr(plongout,LOLO_ALARM,plongout->llsv)){ + plongout->lalm = val; + return; } /* alarm condition high */ - if (plongout->nsevhsv){ - if (val > plongout->high){ - plongout->lalm = val; - plongout->nsta = HIGH_ALARM; - plongout->nsev =plongout->hsv; - return; - } + if (val > plongout->high && recGblSetSevr(plongout,HIGH_ALARM,plongout->hsv)){ + plongout->lalm = val; + return; } - /* alarm condition lolo */ - if (plongout->nsevlsv){ - if (val < plongout->low){ - plongout->lalm = val; - plongout->nsta = LOW_ALARM; - plongout->nsev = plongout->lsv; - return; - } + /* alarm condition low */ + if (val < plongout->low && recGblSetSevr(plongout,LOW_ALARM,plongout->lsv)){ + plongout->lalm = val; + return; } return; } - static void monitor(plongout) struct longoutRecord *plongout; @@ -304,15 +281,7 @@ static void monitor(plongout) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=plongout->stat; - sevr=plongout->sevr; - nsta=plongout->nsta; - nsev=plongout->nsev; - /*set current stat and sevr*/ - plongout->stat = nsta; - plongout->sevr = nsev; - plongout->nsta = 0; - plongout->nsev = 0; + recGblResetSevr(plongout,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; diff --git a/src/rec/recMbbi.c b/src/rec/recMbbi.c index 73c30919c..439074b47 100644 --- a/src/rec/recMbbi.c +++ b/src/rec/recMbbi.c @@ -46,6 +46,7 @@ * .11 12-06-89 lrd add database fetch support * .12 02-08-90 lrd add Allen-Bradley PLC support * .13 10-31-90 mrk changes for new record and device support + * .14 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -312,35 +313,22 @@ static void alarm(pmbbi) /* check for udf alarm */ if(pmbbi->udf == TRUE ){ - if (pmbbi->nsevnsta = UDF_ALARM; - pmbbi->nsev = VALID_ALARM; - } + recGblSetSevr(pmbbi,UDF_ALARM,VALID_ALARM); } /* check for state alarm */ /* unknown state */ if (val > 15){ - if (pmbbi->nsevunsv){ - pmbbi->nsta = STATE_ALARM; - pmbbi->nsev = pmbbi->unsv; - } + recGblSetSevr(pmbbi,STATE_ALARM,pmbbi->unsv); } else { /* in a state which is an error */ severities = (unsigned short *)&(pmbbi->zrsv); - if (pmbbi->nsevval]){ - pmbbi->nsta = STATE_ALARM; - pmbbi->nsev = severities[pmbbi->val]; - } + recGblSetSevr(pmbbi,STATE_ALARM,severities[pmbbi->val]); } /* check for cos alarm */ if(val == pmbbi->lalm) return; - if (pmbbi->nsevcosv){ - pmbbi->nsta = COS_ALARM; - pmbbi->nsev = pmbbi->cosv; - return; - } + recGblSetSevr(pmbbi,COS_ALARM,pmbbi->cosv); pmbbi->lalm = val; return; } @@ -352,18 +340,9 @@ static void monitor(pmbbi) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pmbbi->stat; - sevr=pmbbi->sevr; - nsta=pmbbi->nsta; - nsev=pmbbi->nsev; - /*set current stat and sevr*/ - pmbbi->stat = nsta; - pmbbi->sevr = nsev; - pmbbi->nsta = 0; - pmbbi->nsev = 0; + recGblResetSevr(pmbbi,stat,sevr,nsta,nsev); monitor_mask = 0; - /* alarm condition changed this scan */ if (stat!=nsta || sevr!=nsev){ /* post events for alarm condition change*/ diff --git a/src/rec/recMbbo.c b/src/rec/recMbbo.c index 483bc94a6..c40f2dd53 100644 --- a/src/rec/recMbbo.c +++ b/src/rec/recMbbo.c @@ -49,6 +49,7 @@ * Allen-Bradley and added PLC support * .15 04-11-90 lrd make locals static * .16 10-11-90 mrk make changes for new record and device support + * .17 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -192,7 +193,7 @@ static long init_record(pmbbo) pmbbo->val = (unsigned short)rval; } pmbbo->udf = FALSE; - } else if (status==2) status==0; + } else if (status==2) status=0; } init_common(pmbbo); return(0); @@ -227,28 +228,19 @@ static long process(paddr) pmbbo->val= val; pmbbo->udf= FALSE; } else { - if(pmbbo->nsev < VALID_ALARM) { - pmbbo->nsev = VALID_ALARM; - pmbbo->nsta = LINK_ALARM; - } + recGblSetSevr(pmbbo,LINK_ALARM,VALID_ALARM); goto DONT_WRITE; } } if(pmbbo->udf==TRUE) { - if(pmbbo->nsev < VALID_ALARM) { - pmbbo->nsev = VALID_ALARM; - pmbbo->nsta = UDF_ALARM; - } + recGblSetSevr(pmbbo,UDF_ALARM,VALID_ALARM); goto DONT_WRITE; } if(pmbbo->sdef) { unsigned long *pvalues = &(pmbbo->zrvl); if(pmbbo->val>15) { - if(pmbbo->nsevnsta = SOFT_ALARM; - pmbbo->nsev = VALID_ALARM; - } + recGblSetSevr(pmbbo,SOFT_ALARM,VALID_ALARM); goto DONT_WRITE; } pmbbo->rval = pvalues[pmbbo->val]; @@ -370,26 +362,16 @@ static void alarm(pmbbo) /* check for state alarm */ /* unknown state */ if (val > 15){ - if (pmbbo->nsevunsv){ - pmbbo->nsta = STATE_ALARM; - pmbbo->nsev = pmbbo->unsv; - } + recGblSetSevr(pmbbo,STATE_ALARM,pmbbo->unsv); } else { /* in a state which is an error */ severities = (unsigned short *)&(pmbbo->zrsv); - if (pmbbo->nsevval]){ - pmbbo->nsta = STATE_ALARM; - pmbbo->nsev = severities[pmbbo->val]; - } + recGblSetSevr(pmbbo,STATE_ALARM,severities[pmbbo->val]); } /* check for cos alarm */ if(val == pmbbo->lalm) return; - if (pmbbo->nsevcosv){ - pmbbo->nsta = COS_ALARM; - pmbbo->nsev = pmbbo->cosv; - return; - } + if(recGblSetSevr(pmbbo,COS_ALARM,pmbbo->cosv)) return; pmbbo->lalm = val; return; } @@ -401,15 +383,7 @@ static void monitor(pmbbo) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pmbbo->stat; - sevr=pmbbo->sevr; - nsta=pmbbo->nsta; - nsev=pmbbo->nsev; - /*set current stat and sevr*/ - pmbbo->stat = nsta; - pmbbo->sevr = nsev; - pmbbo->nsta = 0; - pmbbo->nsev = 0; + recGblResetSevr(pmbbo,stat,sevr,nsta,nsev); monitor_mask = 0; diff --git a/src/rec/recPermissive.c b/src/rec/recPermissive.c index 5240b8e15..ae2dc19c6 100644 --- a/src/rec/recPermissive.c +++ b/src/rec/recPermissive.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 10-10-90 mrk extensible record and device support + * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -121,15 +122,7 @@ static void monitor(ppermissive) unsigned short val,oval,wflg,oflg; /* get previous stat and sevr and new stat and sevr*/ - stat=ppermissive->stat; - sevr=ppermissive->sevr; - nsta=ppermissive->nsta; - nsev=ppermissive->nsev; - /*set current stat and sevr*/ - ppermissive->stat = nsta; - ppermissive->sevr = nsev; - ppermissive->nsta = 0; - ppermissive->nsev = 0; + recGblResetSevr(ppermissive,stat,sevr,nsta,nsev); /* get val,oval,wflg,oflg*/ val=ppermissive->val; oval=ppermissive->oval; diff --git a/src/rec/recPid.c b/src/rec/recPid.c index 0c47d8ccf..42c577c3c 100644 --- a/src/rec/recPid.c +++ b/src/rec/recPid.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 10-15-90 mrk changes for new record support + * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -211,43 +212,27 @@ static void alarm(ppid) if (ftemp < ppid->hyst) val=ppid->lalm; /* alarm condition hihi */ - if (ppid->nsevhhsv){ - if (val > ppid->hihi){ - ppid->lalm = val; - ppid->nsta = HIHI_ALARM; - ppid->nsev = ppid->hhsv; - return; - } + if (val > ppid->hihi && recGblSetSevr(ppid,HIHI_ALARM,ppid->hhsv)){ + ppid->lalm = val; + return; } /* alarm condition lolo */ - if (ppid->nsevllsv){ - if (val < ppid->lolo){ - ppid->lalm = val; - ppid->nsta = LOLO_ALARM; - ppid->nsev = ppid->llsv; - return; - } + if (val < ppid->lolo && recGblSetSevr(ppid,LOLO_ALARM,ppid->llsv)){ + ppid->lalm = val; + return; } /* alarm condition high */ - if (ppid->nsevhsv){ - if (val > ppid->high){ - ppid->lalm = val; - ppid->nsta = HIGH_ALARM; - ppid->nsev =ppid->hsv; - return; - } + if (val > ppid->high && recGblSetSevr(ppid,HIGH_ALARM,ppid->hsv)){ + ppid->lalm = val; + return; } - /* alarm condition lolo */ - if (ppid->nsevlsv){ - if (val < ppid->low){ - ppid->lalm = val; - ppid->nsta = LOW_ALARM; - ppid->nsev = ppid->lsv; - return; - } + /* alarm condition low */ + if (val < ppid->low && recGblSetSevr(ppid,LOW_ALARM,ppid->lsv)){ + ppid->lalm = val; + return; } return; } @@ -260,15 +245,7 @@ static void monitor(ppid) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=ppid->stat; - sevr=ppid->sevr; - nsta=ppid->nsta; - nsev=ppid->nsev; - /*set current stat and sevr*/ - ppid->stat = nsta; - ppid->sevr = nsev; - ppid->nsta = 0; - ppid->nsev = 0; + recGblResetSevr(ppid,stat,sevr,nsta,nsev); monitor_mask = 0; @@ -361,20 +338,13 @@ struct pidRecord *ppid; /* fetch the controlled value */ if (ppid->cvl.type != DB_LINK) { /* nothing to control*/ - if (ppid->nsevnsta = SOFT_ALARM; - ppid->nsev = VALID_ALARM; - return(0); - } + if (recGblSetSevr(ppid,SOFT_ALARM,VALID_ALARM)) return(0); } options=0; nRequest=1; if(dbGetLink(&(ppid->cvl.value.db_link),ppid,DBR_FLOAT, &cval,&options,&nRequest)!=NULL) { - if (ppid->nsevnsta = LINK_ALARM; - ppid->nsev = VALID_ALARM; - } + recGblSetSevr(ppid,LINK_ALARM,VALID_ALARM); return(0); } /* fetch the setpoint */ @@ -383,19 +353,13 @@ struct pidRecord *ppid; nRequest=1; if(dbGetLink(&(ppid->stpl.value.db_link),ppid,DBR_FLOAT, &(ppid->val),&options,&nRequest)!=NULL) { - if (ppid->nsevnsta = LINK_ALARM; - ppid->nsev = VALID_ALARM; - } + recGblSetSevr(ppid,LINK_ALARM,VALID_ALARM); return(0); } else ppid->udf=FALSE; } val = ppid->val; if (ppid->udf == TRUE ) { - if (ppid->nsevnsta = UDF_ALARM; - ppid->nsev = VALID_ALARM; - } + recGblSetSevr(ppid,UDF_ALARM,VALID_ALARM); return(0); } diff --git a/src/rec/recPulseCounter.c b/src/rec/recPulseCounter.c index c026f477f..64c98a984 100644 --- a/src/rec/recPulseCounter.c +++ b/src/rec/recPulseCounter.c @@ -1,7 +1,7 @@ /* recPulseCounter.c */ /* share/src/rec $Id$ */ -/* recPulser.c - Record Support Routines for PulseCounter records */ +/* recPulseCounter.c - Record Support Routines for PulseCounter records */ /* * Author: Janet Anderson * Date: 10-17-91 @@ -29,7 +29,7 @@ * * Modification Log: * ----------------- - * .01 mm-dd-yy iii Comment + * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -163,10 +163,7 @@ static long process(paddr) &ppc->sgv,&options,&nRequest); ppc->pact = FALSE; if(status!=0) { - if (ppc->nsevnsta = LINK_ALARM; - ppc->nsev = VALID_ALARM; - } + recGblSetSevr(ppc,LINK_ALARM,VALID_ALARM); } } if(status=0){ @@ -181,16 +178,14 @@ static long process(paddr) ppc->cmd=save; ppc->osgv=ppc->sgv; if(status!=0) { - if (ppc->nsevnsta = SOFT_ALARM; - ppc->nsev = VALID_ALARM; - } + recGblSetSevr(ppc,SOFT_ALARM,VALID_ALARM); } } } } if(ppc->cmd>0){ + ppc->scmd=ppc->cmd; status=(*pdset->cmd_pc)(ppc); ppc->cmd=CTR_READ; } @@ -277,15 +272,7 @@ static void monitor(ppc) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=ppc->stat; - sevr=ppc->sevr; - nsta=ppc->nsta; - nsev=ppc->nsev; - /*set current stat and sevr*/ - ppc->stat = nsta; - ppc->sevr = nsev; - ppc->nsta = 0; - ppc->nsev = 0; + recGblResetSevr(ppc,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; @@ -301,7 +288,9 @@ static void monitor(ppc) monitor_mask |= (DBE_VALUE | DBE_LOG); db_post_events(ppc,&ppc->val,monitor_mask); - db_post_events(ppc,&ppc->cmd,monitor_mask); - + if (ppc->scmd != ppc->cmd) { + db_post_events(ppc,&ppc->scmd,monitor_mask); + ppc->scmd=ppc->cmd; + } return; } diff --git a/src/rec/recPulseDelay.c b/src/rec/recPulseDelay.c index 4a939bab1..9e4fad26c 100644 --- a/src/rec/recPulseDelay.c +++ b/src/rec/recPulseDelay.c @@ -29,7 +29,7 @@ * * Modification Log: * ----------------- - * .01 mm-dd-yy iii Comment + * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -219,15 +219,7 @@ static void monitor(ppd) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=ppd->stat; - sevr=ppd->sevr; - nsta=ppd->nsta; - nsev=ppd->nsev; - /*set current stat and sevr*/ - ppd->stat = nsta; - ppd->sevr = nsev; - ppd->nsta = 0; - ppd->nsev = 0; + recGblResetSevr(ppd,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; @@ -243,8 +235,14 @@ static void monitor(ppd) monitor_mask |= (DBE_VALUE | DBE_LOG); db_post_events(ppd,&ppd->val,monitor_mask); - db_post_events(ppd,&ppd->dly,monitor_mask); - db_post_events(ppd,&ppd->wide,monitor_mask); + if(ppd->odly != ppd->dly){ + db_post_events(ppd,&ppd->dly,monitor_mask); + ppd->odly=ppd->dly; + } + if(ppd->owid != ppd->wide){ + db_post_events(ppd,&ppd->wide,monitor_mask); + ppd->owid=ppd->wide; + } return; } diff --git a/src/rec/recPulseTrain.c b/src/rec/recPulseTrain.c index b39973da2..d54716f2d 100644 --- a/src/rec/recPulseTrain.c +++ b/src/rec/recPulseTrain.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 10-24-91 jba New device support changes + * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -164,10 +165,7 @@ static long process(paddr) &ppt->sgv,&options,&nRequest); ppt->pact = FALSE; if(status!=0) { - if (ppt->nsevnsta = LINK_ALARM; - ppt->nsev = VALID_ALARM; - } + recGblSetSevr(ppt,LINK_ALARM,VALID_ALARM); } } if(status=0){ @@ -179,11 +177,8 @@ static long process(paddr) status=(*pdset->write_pt)(ppt); ppt->dcy=save; if(status!=0) { - if (ppt->nsevnsta = WRITE_ALARM; - ppt->nsev = VALID_ALARM; - } - } + recGblSetSevr(ppt,WRITE_ALARM,VALID_ALARM); + } } ppt->osgv=ppt->sgv; } @@ -294,15 +289,7 @@ static void monitor(ppt) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=ppt->stat; - sevr=ppt->sevr; - nsta=ppt->nsta; - nsev=ppt->nsev; - /*set current stat and sevr*/ - ppt->stat = nsta; - ppt->sevr = nsev; - ppt->nsta = 0; - ppt->nsev = 0; + recGblResetSevr(ppt,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; @@ -318,8 +305,13 @@ static void monitor(ppt) monitor_mask |= (DBE_VALUE | DBE_LOG); db_post_events(ppt,&ppt->val,monitor_mask); - db_post_events(ppt,&ppt->per,monitor_mask); - db_post_events(ppt,&ppt->dcy,monitor_mask); - + if(ppt->oper != ppt->per){ + db_post_events(ppt,&ppt->per,monitor_mask); + ppt->oper=ppt->per; + } + if(ppt->odcy != ppt->dcy){ + db_post_events(ppt,&ppt->dcy,monitor_mask); + ppt->odcy=ppt->dcy; + } return; } diff --git a/src/rec/recSel.c b/src/rec/recSel.c index 7c0e7c748..1d0329309 100644 --- a/src/rec/recSel.c +++ b/src/rec/recSel.c @@ -33,6 +33,7 @@ * .01 11-16-89 lrd fixed select algorithms not to compare against * the previous value * .02 10-12-90 mrk changes for new record support + * .03 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -125,10 +126,7 @@ static long process(paddr) psel->pact = TRUE; if(fetch_values(psel)==0) { if(do_sel(psel)!=0) { - if(psel->nsevnsta = CALC_ALARM; - psel->nsev = VALID_ALARM; - } + recGblSetSevr(psel,CALC_ALARM,VALID_ALARM); } } @@ -224,11 +222,7 @@ static void alarm(psel) /* undefined condition */ if(psel->udf ==TRUE){ - if (psel->nsevnsta = UDF_ALARM; - psel->nsev = VALID_ALARM; - return; - } + if(recGblSetSevr(psel,UDF_ALARM,VALID_ALARM)) return; } /* if difference is not > hysterisis use lalm not val */ ftemp = psel->lalm - psel->val; @@ -236,40 +230,27 @@ static void alarm(psel) if (ftemp < psel->hyst) val=psel->lalm; /* alarm condition hihi */ - if (psel->nsevhhsv){ - if (val > psel->hihi){ - psel->lalm = val; - psel->nsta = HIHI_ALARM; - psel->nsev = psel->hhsv; - return; - } + if (val > psel->hihi && recGblSetSevr(psel,HIHI_ALARM,psel->hhsv)){ + psel->lalm = val; + return; } + /* alarm condition lolo */ - if (psel->nsevllsv){ - if (val < psel->lolo){ - psel->lalm = val; - psel->nsta = LOLO_ALARM; - psel->nsev = psel->llsv; - return; - } + if (val < psel->lolo && recGblSetSevr(psel,LOLO_ALARM,psel->llsv)){ + psel->lalm = val; + return; } + /* alarm condition high */ - if (psel->nsevhsv){ - if (val > psel->high){ - psel->lalm = val; - psel->nsta = HIGH_ALARM; - psel->nsev =psel->hsv; - return; - } + if (val > psel->high && recGblSetSevr(psel,HIGH_ALARM,psel->hsv)){ + psel->lalm = val; + return; } - /* alarm condition lolo */ - if (psel->nsevlsv){ - if (val < psel->low){ - psel->lalm = val; - psel->nsta = LOW_ALARM; - psel->nsev = psel->lsv; - return; - } + + /* alarm condition low */ + if (val < psel->low && recGblSetSevr(psel,LOW_ALARM,psel->lsv)){ + psel->lalm = val; + return; } return; } @@ -284,16 +265,8 @@ static void monitor(psel) double *pprev; int i; - /* get previous stat and sevr and new stat and sevr*/ - stat=psel->stat; - sevr=psel->sevr; - nsta=psel->nsta; - nsev=psel->nsev; - /*set current stat and sevr*/ - psel->stat = nsta; - psel->sevr = nsev; - psel->nsta = 0; - psel->nsev = 0; + /* get peevious stat and sevr and new stat and sevr*/ + recGblResetSevr(psel,stat,sevr,nsta,nsev); monitor_mask = 0; @@ -417,10 +390,7 @@ struct selRecord *psel; nRequest=1; if(dbGetLink(&(psel->nvl.value.db_link),psel,DBR_USHORT, &(psel->seln),&options,&nRequest)!=NULL) { - if (psel->nsevnsta = LINK_ALARM; - psel->nsev = VALID_ALARM; - } + recGblSetSevr(psel,LINK_ALARM,VALID_ALARM); return(-1); } } @@ -430,10 +400,7 @@ struct selRecord *psel; nRequest=1; status=dbGetLink(&plink->value.db_link,psel,DBR_DOUBLE,pvalue,&options,&nRequest); if(status!=0) { - if(psel->nsevnsev=VALID_ALARM; - psel->nsta=LINK_ALARM; - } + recGblSetSevr(psel,LINK_ALARM,VALID_ALARM); return(-1); } } @@ -445,10 +412,7 @@ struct selRecord *psel; nRequest=1; status = dbGetLink(&plink->value.db_link,psel,DBR_DOUBLE,pvalue,&options,&nRequest); if(status!=0) { - if(psel->nsevnsev=VALID_ALARM; - psel->nsta=LINK_ALARM; - } + recGblSetSevr(psel,LINK_ALARM,VALID_ALARM); return(-1); } } diff --git a/src/rec/recState.c b/src/rec/recState.c index b4e08ae82..74f4545e2 100644 --- a/src/rec/recState.c +++ b/src/rec/recState.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 10-10-90 mrk extensible record and device support + * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -121,15 +122,7 @@ static void monitor(pstate) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pstate->stat; - sevr=pstate->sevr; - nsta=pstate->nsta; - nsev=pstate->nsev; - /*set current stat and sevr*/ - pstate->stat = nsta; - pstate->sevr = nsev; - pstate->nsta = 0; - pstate->nsev = 0; + recGblResetSevr(pstate,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; diff --git a/src/rec/recSteppermotor.c b/src/rec/recSteppermotor.c index e2cf8c0b1..06238fd6a 100644 --- a/src/rec/recSteppermotor.c +++ b/src/rec/recSteppermotor.c @@ -63,6 +63,7 @@ * .21 10-15-90 mrk extensible record and device support * .22 10-24-91 jba bug fix to alarms + * .23 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -237,8 +238,8 @@ static long get_control_double(paddr,pcd) { struct steppermotorRecord *psm=(struct steppermotorRecord *)paddr->precord; - pcd->upper_ctrl_limit = psm->hopr; - pcd->lower_ctrl_limit = psm->lopr; + pcd->upper_ctrl_limit = psm->drvh; + pcd->lower_ctrl_limit = psm->drvl; return(0); } @@ -264,42 +265,25 @@ static void alarm(psm) deviation = psm->val - psm->rbv; /* alarm condition hihi */ - if (psm->nsevhhsv){ - if (deviation > psm->hihi){ - psm->nsta = HIHI_ALARM; - psm->nsev = psm->hhsv; - return; - } + if (deviation > psm->hihi && recGblSetSevr(psm,HIHI_ALARM,psm->hhsv)){ + return; } /* alarm condition lolo */ - if (psm->nsevllsv){ - if (deviation < psm->lolo){ - psm->nsta = LOLO_ALARM; - psm->nsev = psm->llsv; - return; - } + if (deviation < psm->lolo && recGblSetSevr(psm,LOLO_ALARM,psm->llsv)){ + return; } /* alarm condition high */ - if (psm->nsevhsv){ - if (deviation > psm->high){ - psm->nsta = HIGH_ALARM; - psm->nsev =psm->hsv; - return; - } + if (deviation > psm->high && recGblSetSevr(psm,HIGH_ALARM,psm->hsv)){ + return; } - /* alarm condition lolo */ - if (psm->nsevlsv){ - if (deviation < psm->low){ - psm->nsta = LOW_ALARM; - psm->nsev = psm->lsv; - return; - } + /* alarm condition low */ + if (deviation < psm->low && recGblSetSevr(psm,LOW_ALARM,psm->lsv)){ + return; } return; - } static void monitor(psm) @@ -465,23 +449,12 @@ psm_data->accel /* alarm conditions for limit switches */ if ((psm->ccw == 0) || (psm->cw == 0)){ /* limit violation */ - if (psm->nsevhlsv) { - psm->nsta = HW_LIMIT_ALARM; - psm->nsev = psm->hlsv; - } + recGblSetSevr(psm,HW_LIMIT_ALARM,psm->hlsv); } /* get previous stat and sevr and new stat and sevr*/ - stat=psm->stat; - sevr=psm->sevr; - nsta=psm->nsta; - nsev=psm->nsev; - /*set current stat and sevr*/ - psm->stat = nsta; - psm->sevr = nsev; - psm->nsta = 0; - psm->nsev = 0; + recGblResetSevr(psm,stat,sevr,nsta,nsev); /* anyone waiting for an event on this record */ if (psm->mlis.count!=0 && (stat!=nsta || sevr!=nsev) ){ @@ -533,7 +506,7 @@ struct steppermotorRecord *psm; { int acceleration,velocity; short card,channel; - short status; + short status=0; /* the motor number is the card number */ card = psm->out.value.vmeio.card; @@ -554,10 +527,7 @@ struct steppermotorRecord *psm; /* initialize the motor */ /* set mode - first command checks card present */ if (sm_driver(psm->dtyp,card,channel,SM_MODE,psm->mode,0) < 0){ - if(psm->nsev < VALID_ALARM) { - psm->nsta = WRITE_ALARM; - psm->nsev = VALID_ALARM; - } + recGblSetSevr(psm,WRITE_ALARM,VALID_ALARM); psm->init = 1; return; } @@ -590,10 +560,7 @@ struct steppermotorRecord *psm; status = sm_driver(psm->dtyp,card,channel,SM_READ,0,0); } if (status < 0){ - if (psm->nsev < VALID_ALARM) { - psm->nsta = WRITE_ALARM; - psm->nsev = VALID_ALARM; - } + recGblSetSevr(psm,WRITE_ALARM,VALID_ALARM); return; } }else if (psm->mode == VELOCITY){ @@ -669,10 +636,7 @@ struct steppermotorRecord *psm; long nRequest=1; if(dbGetLink(&(psm->dol.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)){ - if (psm->nsev < VALID_ALARM) { - psm->nsta = LINK_ALARM; - psm->nsev = VALID_ALARM; - } + recGblSetSevr(psm,LINK_ALARM,VALID_ALARM); return; } else psm->udf = FALSE; } @@ -722,10 +686,7 @@ struct steppermotorRecord *psm; /* move motor */ if (sm_driver(psm->dtyp,card,channel,SM_MOVE,psm->rval-psm->rrbv,0) < 0){ - if (psm->nsev < VALID_ALARM) { - psm->nsta = WRITE_ALARM; - psm->nsev = VALID_ALARM; - } + recGblSetSevr(psm,WRITE_ALARM,VALID_ALARM); return; } psm->movn = 1; @@ -777,10 +738,7 @@ struct steppermotorRecord *psm; long nRequest=1; if(dbGetLink(&(psm->dol.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)) { - if (psm->nsev < VALID_ALARM) { - psm->nsta = LINK_ALARM; - psm->nsev = VALID_ALARM; - } + recGblSetSevr(psm,LINK_ALARM,VALID_ALARM); return; } else psm->udf=FALSE; } @@ -817,10 +775,7 @@ struct steppermotorRecord *psm; /*the last arg of next call is check for direction */ if(sm_driver(psm->dtyp,card,channel,SM_MOTION,1,(psm->val < 0))){ - if (psm->nsev < VALID_ALARM) { - psm->stat = WRITE_ALARM; - psm->sevr = VALID_ALARM; - } + recGblSetSevr(psm,WRITE_ALARM,VALID_ALARM); return; } psm->cvel = 0; @@ -868,10 +823,7 @@ short moving; reset = psm->init; if (reset == 0) psm->init = 1; if(dbGetLink(&(psm->rdbl.value.db_link),psm,DBR_FLOAT,&new_pos,&options,&nRequest)){ - if (psm->nsev < VALID_ALARM) { - psm->nsta = READ_ALARM; - psm->nsev = VALID_ALARM; - } + recGblSetSevr(psm,READ_ALARM,VALID_ALARM); psm->init = reset; return; } diff --git a/src/rec/recStringin.c b/src/rec/recStringin.c index 0a54b9d53..6d76bd9ca 100644 --- a/src/rec/recStringin.c +++ b/src/rec/recStringin.c @@ -29,7 +29,7 @@ * * Modification Log: * ----------------- - * .01 mm-dd-yy iii Comment + * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ @@ -169,15 +169,7 @@ static void monitor(pstringin) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pstringin->stat; - sevr=pstringin->sevr; - nsta=pstringin->nsta; - nsev=pstringin->nsev; - /*set current stat and sevr*/ - pstringin->stat = nsta; - pstringin->sevr = nsev; - pstringin->nsta = 0; - pstringin->nsev = 0; + recGblResetSevr(pstringin,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; diff --git a/src/rec/recStringout.c b/src/rec/recStringout.c index 9a7a96e51..c4dfbc089 100644 --- a/src/rec/recStringout.c +++ b/src/rec/recStringout.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 10-24-91 jba Removed unused code + * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ @@ -148,10 +149,7 @@ static long process(paddr) DBR_STRING,pstringout->val,&options,&nRequest); pstringout->pact = FALSE; if(!status==0){ - if(pstringout->nsev < VALID_ALARM) { - pstringout->nsev = VALID_ALARM; - pstringout->nsta = LINK_ALARM; - } + recGblSetSevr(pstringout,LINK_ALARM,VALID_ALARM); } else pstringout->udf=FALSE; } } @@ -194,15 +192,7 @@ static void monitor(pstringout) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pstringout->stat; - sevr=pstringout->sevr; - nsta=pstringout->nsta; - nsev=pstringout->nsev; - /*set current stat and sevr*/ - pstringout->stat = nsta; - pstringout->sevr = nsev; - pstringout->nsta = 0; - pstringout->nsev = 0; + recGblResetSevr(pstringout,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0; diff --git a/src/rec/recSub.c b/src/rec/recSub.c index 3d7c9548b..bbad24e83 100644 --- a/src/rec/recSub.c +++ b/src/rec/recSub.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 10-10-90 mrk Made changes for new record support + * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -244,11 +245,7 @@ static void alarm(psub) /* undefined condition */ if(psub->udf == TRUE) { - if (psub->nsevnsta = UDF_ALARM; - psub->nsev = VALID_ALARM; - return; - } + if(recGblSetSevr(psub,UDF_ALARM,VALID_ALARM)) return; } /* if difference is not > hysterisis use lalm not val */ ftemp = psub->lalm - psub->val; @@ -256,42 +253,27 @@ static void alarm(psub) if (ftemp < psub->hyst) val=psub->lalm; /* alarm condition hihi */ - if (psub->nsevhhsv){ - if (val > psub->hihi){ - psub->lalm = val; - psub->nsta = HIHI_ALARM; - psub->nsev = psub->hhsv; - return; - } + if (val > psub->hihi && recGblSetSevr(psub,HIHI_ALARM,psub->hhsv)){ + psub->lalm = val; + return; } /* alarm condition lolo */ - if (psub->nsevllsv){ - if (val < psub->lolo){ - psub->lalm = val; - psub->nsta = LOLO_ALARM; - psub->nsev = psub->llsv; - return; - } + if (val < psub->lolo && recGblSetSevr(psub,LOLO_ALARM,psub->llsv)){ + psub->lalm = val; + return; } /* alarm condition high */ - if (psub->nsevhsv){ - if (val > psub->high){ - psub->lalm = val; - psub->nsta = HIGH_ALARM; - psub->nsev =psub->hsv; - return; - } + if (val > psub->high && recGblSetSevr(psub,HIGH_ALARM,psub->hsv)){ + psub->lalm = val; + return; } - /* alarm condition lolo */ - if (psub->nsevlsv){ - if (val < psub->low){ - psub->lalm = val; - psub->nsta = LOW_ALARM; - psub->nsev = psub->lsv; - return; - } + + /* alarm condition low */ + if (val < psub->low && recGblSetSevr(psub,LOW_ALARM,psub->lsv)){ + psub->lalm = val; + return; } return; } @@ -307,15 +289,7 @@ static void monitor(psub) int i; /* get previous stat and sevr and new stat and sevr*/ - stat=psub->stat; - sevr=psub->sevr; - nsta=psub->nsta; - nsev=psub->nsev; - /*set current stat and sevr*/ - psub->stat = nsta; - psub->sevr = nsev; - psub->nsta = 0; - psub->nsev = 0; + recGblResetSevr(psub,stat,sevr,nsta,nsev); monitor_mask = 0; @@ -375,10 +349,7 @@ struct subRecord *psub; status=dbGetLink(&plink->value.db_link,psub,DBR_DOUBLE, pvalue,&options,&nRequest); if(status!=0) { - if(psub->nsevnsev=VALID_ALARM; - psub->nsta=LINK_ALARM; - } + recGblSetSevr(psub,LINK_ALARM,VALID_ALARM); return(-1); } } @@ -395,18 +366,12 @@ struct subRecord *psub; /* pointer to subroutine record */ /* call the subroutine */ psubroutine = (FUNCPTR)(psub->sadr); if(psubroutine==NULL) { - if(psub->nsevnsta = BAD_SUB_ALARM; - psub->nsev = VALID_ALARM; - } + recGblSetSevr(psub,BAD_SUB_ALARM,VALID_ALARM); return(0); } status = psubroutine(psub); if(status < 0){ - if (psub->nsevbrsv){ - psub->nsta = SOFT_ALARM; - psub->nsev = psub->brsv; - } + recGblSetSevr(psub,SOFT_ALARM,psub->brsv); } else psub->udf = FALSE; return(status); } diff --git a/src/rec/recWaveform.c b/src/rec/recWaveform.c index 9bf2ccdbf..a9a01bd07 100644 --- a/src/rec/recWaveform.c +++ b/src/rec/recWaveform.c @@ -48,6 +48,7 @@ * .09 07-26-90 lrd fixed the N-to-1 character waveformion * value was not initialized * .10 10-11-90 mrk Made changes for new record support + * .11 11-11-91 jba Moved set and reset of alarm stat and sevr to macros */ #include @@ -294,15 +295,7 @@ static void monitor(pwf) short stat,sevr,nsta,nsev; /* get previous stat and sevr and new stat and sevr*/ - stat=pwf->stat; - sevr=pwf->sevr; - nsta=pwf->nsta; - nsev=pwf->nsev; - /*set current stat and sevr*/ - pwf->stat = nsta; - pwf->sevr = nsev; - pwf->nsta = 0; - pwf->nsev = 0; + recGblResetSevr(pwf,stat,sevr,nsta,nsev); /* Flags which events to fire on the value field */ monitor_mask = 0;