diff --git a/src/rec/dfanoutRecord.c b/src/rec/dfanoutRecord.c index a2fa3ef7e..18b116795 100644 --- a/src/rec/dfanoutRecord.c +++ b/src/rec/dfanoutRecord.c @@ -10,27 +10,29 @@ * ----------------- * .01 1994 mhb Started with longout record to make the data fanout * .02 May 10, 96 jt Bug Fix + * .03 11SEP2000 mrk LONG=>DOUBLE, add SELL,SELN,SELM */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "recGbl.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "dfanoutRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ @@ -44,7 +46,7 @@ static long process(); #define get_array_info NULL #define put_array_info NULL static long get_units(); -#define get_precision NULL +static long get_precision(); #define get_enum_str NULL #define get_enum_strs NULL #define put_enum_str NULL @@ -73,40 +75,38 @@ struct rset dfanoutRSET={ get_alarm_double }; -static void alarm(); +static void checkAlarms(); static void monitor(); static void push_values(); #define OUT_ARG_MAX 8 -static long init_record(pdfanout,pass) - struct dfanoutRecord *pdfanout; - int pass; +static long init_record(struct dfanoutRecord *pdfanout, int pass) { if (pass==0) return(0); + recGblInitConstantLink(&pdfanout->sell,DBF_USHORT,&pdfanout->seln); /* get the initial value dol is a constant*/ - if (pdfanout->dol.type == CONSTANT){ - if(recGblInitConstantLink(&pdfanout->dol,DBF_LONG,&pdfanout->val)) + if(recGblInitConstantLink(&pdfanout->dol,DBF_DOUBLE,&pdfanout->val)) pdfanout->udf=FALSE; - } return(0); } -static long process(pdfanout) - struct dfanoutRecord *pdfanout; +static long process(struct dfanoutRecord *pdfanout) { - long status=0; + long status=0; if (!pdfanout->pact && pdfanout->omsl == CLOSED_LOOP){ - status = dbGetLink(&(pdfanout->dol),DBR_LONG,&(pdfanout->val),0,0); - if(pdfanout->dol.type!=CONSTANT && RTN_SUCCESS(status)) pdfanout->udf=FALSE; + status = dbGetLink(&(pdfanout->dol),DBR_DOUBLE,&(pdfanout->val),0,0); + if(pdfanout->dol.type!=CONSTANT && RTN_SUCCESS(status)) + pdfanout->udf=FALSE; } pdfanout->pact = TRUE; recGblGetTimeStamp(pdfanout); /* Push out the data to all the forward links */ - alarm(pdfanout); + dbGetLink(&(pdfanout->sell),DBR_USHORT,&(pdfanout->seln),0,0); + checkAlarms(pdfanout); push_values(pdfanout); monitor(pdfanout); recGblFwdLink(pdfanout); @@ -114,56 +114,73 @@ static long process(pdfanout) return(status); } -static long get_units(paddr,units) - struct dbAddr *paddr; - char *units; +static long get_units(struct dbAddr *paddr,char *units) { - struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; strncpy(units,pdfanout->egu,DB_UNITS_SIZE); return(0); } -static long get_graphic_double(paddr,pgd) - struct dbAddr *paddr; - struct dbr_grDouble *pgd; +static long get_precision(struct dbAddr *paddr,long *precision) { - struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + int fieldIndex = dbGetFieldIndex(paddr); - if(paddr->pfield==(void *)&pdfanout->val - || paddr->pfield==(void *)&pdfanout->hihi - || paddr->pfield==(void *)&pdfanout->high - || paddr->pfield==(void *)&pdfanout->low - || paddr->pfield==(void *)&pdfanout->lolo){ + if(fieldIndex == dfanoutRecordVAL + || fieldIndex == dfanoutRecordHIHI + || fieldIndex == dfanoutRecordHIGH + || fieldIndex == dfanoutRecordLOW + || fieldIndex == dfanoutRecordLOLO + || fieldIndex == dfanoutRecordHOPR + || fieldIndex == dfanoutRecordLOPR) { + *precision = pdfanout->prec; + } else { + recGblGetPrec(paddr,precision); + } + return(0); +} + +static long get_graphic_double(struct dbAddr *paddr,struct dbr_grDouble *pgd) +{ + struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + int fieldIndex = dbGetFieldIndex(paddr); + + if(fieldIndex == dfanoutRecordVAL + || fieldIndex == dfanoutRecordHIHI + || fieldIndex == dfanoutRecordHIGH + || fieldIndex == dfanoutRecordLOW + || fieldIndex == dfanoutRecordLOLO + || fieldIndex == dfanoutRecordHOPR + || fieldIndex == dfanoutRecordLOPR) { pgd->upper_disp_limit = pdfanout->hopr; pgd->lower_disp_limit = pdfanout->lopr; } else recGblGetGraphicDouble(paddr,pgd); return(0); } -static long get_control_double(paddr,pcd) - struct dbAddr *paddr; - struct dbr_ctrlDouble *pcd; +static long get_control_double(struct dbAddr *paddr,struct dbr_ctrlDouble *pcd) { - struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + int fieldIndex = dbGetFieldIndex(paddr); - if(paddr->pfield==(void *)&pdfanout->val - || paddr->pfield==(void *)&pdfanout->hihi - || paddr->pfield==(void *)&pdfanout->high - || paddr->pfield==(void *)&pdfanout->low - || paddr->pfield==(void *)&pdfanout->lolo){ + if(fieldIndex == dfanoutRecordVAL + || fieldIndex == dfanoutRecordHIHI + || fieldIndex == dfanoutRecordHIGH + || fieldIndex == dfanoutRecordLOW + || fieldIndex == dfanoutRecordLOLO) { pcd->upper_ctrl_limit = pdfanout->hopr; pcd->lower_ctrl_limit = pdfanout->lopr; } else recGblGetControlDouble(paddr,pcd); return(0); } -static long get_alarm_double(paddr,pad) - struct dbAddr *paddr; - struct dbr_alDouble *pad; +static long get_alarm_double(struct dbAddr *paddr,struct dbr_alDouble *pad) { - struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord; + int fieldIndex = dbGetFieldIndex(paddr); - if(paddr->pfield==(void *)&pdfanout->val){ + + if(fieldIndex == dfanoutRecordVAL) { pad->upper_alarm_limit = pdfanout->hihi; pad->upper_warning_limit = pdfanout->high; pad->lower_warning_limit = pdfanout->low; @@ -172,8 +189,7 @@ static long get_alarm_double(paddr,pad) return(0); } -static void alarm(pdfanout) - struct dfanoutRecord *pdfanout; +static void checkAlarms(struct dfanoutRecord *pdfanout) { double val; double hyst, lalm, hihi, high, low, lolo; @@ -217,12 +233,11 @@ static void alarm(pdfanout) return; } -static void monitor(pdfanout) - struct dfanoutRecord *pdfanout; +static void monitor(struct dfanoutRecord *pdfanout) { unsigned short monitor_mask; - long delta; + double delta; monitor_mask = recGblResetAlarms(pdfanout); /* check for value change */ @@ -250,16 +265,45 @@ static void monitor(pdfanout) } return; } - -static void push_values(pdfanout) -struct dfanoutRecord *pdfanout; + +static void push_values(struct dfanoutRecord *pdfanout) { - struct link *plink; /* structure of the link field */ - int i; - long status; + struct link *plink; /* structure of the link field */ + int i; + long status; + unsigned short state; + switch (pdfanout->selm){ + case (dfanoutSELM_All): for(i=0, plink=&(pdfanout->outa); ival),1); + status=dbPutLink(plink,DBR_DOUBLE,&(pdfanout->val),1); if(status) recGblSetSevr(pdfanout,LINK_ALARM,MAJOR_ALARM); } + break; + case (dfanoutSELM_Specified): + if(pdfanout->seln>OUT_ARG_MAX) { + recGblSetSevr(pdfanout,SOFT_ALARM,INVALID_ALARM); + break; + } + if(pdfanout->seln==0) break; + plink=&(pdfanout->outa); + plink += (pdfanout->seln -1); + status=dbPutLink(plink,DBR_DOUBLE,&(pdfanout->val),1); + if(status) recGblSetSevr(pdfanout,LINK_ALARM,MAJOR_ALARM); + break; + case (dfanoutSELM_Mask): + if(pdfanout->seln==0) break; + for(i=0, plink=&(pdfanout->outa), state=pdfanout->seln; + i>=1) { + if(state&1) { + status=dbPutLink(plink,DBR_DOUBLE,&(pdfanout->val),1); + if(status) recGblSetSevr(pdfanout,LINK_ALARM,MAJOR_ALARM); + } + } + break; + default: + recGblSetSevr(pdfanout,SOFT_ALARM,INVALID_ALARM); + } + } diff --git a/src/rec/dfanoutRecord.dbd b/src/rec/dfanoutRecord.dbd index 608f5a144..25b0d264a 100644 --- a/src/rec/dfanoutRecord.dbd +++ b/src/rec/dfanoutRecord.dbd @@ -1,10 +1,31 @@ +menu(dfanoutSELM) { + choice(dfanoutSELM_All,"All") + choice(dfanoutSELM_Specified,"Specified") + choice(dfanoutSELM_Mask,"Mask") +} recordtype(dfanout) { include "dbCommon.dbd" - field(VAL,DBF_LONG) { + field(VAL,DBF_DOUBLE) { prompt("Desired Output") asl(ASL0) pp(TRUE) } + field(SELM,DBF_MENU) { + prompt("Select Mechanism") + promptgroup(GUI_LINKS) + interest(1) + menu(dfanoutSELM) + } + field(SELN,DBF_USHORT) { + prompt("Link Selection") + interest(1) + initial("1") + } + field(SELL,DBF_INLINK) { + prompt("Link Selection Loc") + promptgroup(GUI_LINKS) + interest(1) + } field(OUTA,DBF_OUTLINK) { prompt("Output Spec A") promptgroup(GUI_OUTPUT) @@ -62,35 +83,40 @@ recordtype(dfanout) { interest(1) size(16) } - field(HOPR,DBF_LONG) { + field(PREC,DBF_SHORT) { + prompt("Display Precision") + promptgroup(GUI_DISPLAY) + interest(1) + } + field(HOPR,DBF_DOUBLE) { prompt("High Operating Range") promptgroup(GUI_DISPLAY) interest(1) } - field(LOPR,DBF_LONG) { + field(LOPR,DBF_DOUBLE) { prompt("Low Operating Range") promptgroup(GUI_DISPLAY) interest(1) } - field(HIHI,DBF_LONG) { + field(HIHI,DBF_DOUBLE) { prompt("Hihi Alarm Limit") promptgroup(GUI_ALARMS) pp(TRUE) interest(1) } - field(LOLO,DBF_LONG) { + field(LOLO,DBF_DOUBLE) { prompt("Lolo Alarm Limit") promptgroup(GUI_ALARMS) pp(TRUE) interest(1) } - field(HIGH,DBF_LONG) { + field(HIGH,DBF_DOUBLE) { prompt("High Alarm Limit") promptgroup(GUI_ALARMS) pp(TRUE) interest(1) } - field(LOW,DBF_LONG) { + field(LOW,DBF_DOUBLE) { prompt("Low Alarm Limit") promptgroup(GUI_ALARMS) pp(TRUE) @@ -124,45 +150,34 @@ recordtype(dfanout) { interest(1) menu(menuAlarmSevr) } - field(HYST,DBF_LONG) { + field(HYST,DBF_DOUBLE) { prompt("Alarm Deadband") promptgroup(GUI_ALARMS) interest(1) } - field(ADEL,DBF_LONG) { + field(ADEL,DBF_DOUBLE) { prompt("Archive Deadband") promptgroup(GUI_DISPLAY) interest(1) } - field(MDEL,DBF_LONG) { + field(MDEL,DBF_DOUBLE) { prompt("Monitor Deadband") promptgroup(GUI_DISPLAY) interest(1) } - field(LALM,DBF_LONG) { + field(LALM,DBF_DOUBLE) { prompt("Last Value Alarmed") special(SPC_NOMOD) interest(3) } - field(ALST,DBF_LONG) { + field(ALST,DBF_DOUBLE) { prompt("Last Value Archived") special(SPC_NOMOD) interest(3) } - field(MLST,DBF_LONG) { + field(MLST,DBF_DOUBLE) { prompt("Last Val Monitored") special(SPC_NOMOD) interest(3) } - field(IVOA,DBF_MENU) { - prompt("INVALID output action") - promptgroup(GUI_OUTPUT) - interest(2) - menu(menuIvoa) - } - field(IVOV,DBF_LONG) { - prompt("INVALID output value") - promptgroup(GUI_OUTPUT) - interest(2) - } }