diff --git a/src/std/dev/devAaiSoft.c b/src/std/dev/devAaiSoft.c index 31626bacb..ab6476ea9 100644 --- a/src/std/dev/devAaiSoft.c +++ b/src/std/dev/devAaiSoft.c @@ -78,16 +78,16 @@ static long init_record(aaiRecord *prec) static long read_aai(aaiRecord *prec) { long nRequest = prec->nelm; + long status = dbGetLink(prec->simm == menuYesNoYES ? &prec->siol : + &prec->inp, prec->ftvl, prec->bptr, 0, &nRequest); - dbGetLink(prec->simm == menuYesNoYES ? &prec->siol : &prec->inp, - prec->ftvl, prec->bptr, 0, &nRequest); - if (nRequest > 0) { + if (!status && nRequest > 0) { prec->nord = nRequest; - prec->udf=FALSE; - if (prec->tsel.type == CONSTANT && + prec->udf = FALSE; + + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } - - return 0; + return status; } diff --git a/src/std/dev/devAaoSoft.c b/src/std/dev/devAaoSoft.c index a88d61140..dd96d10c0 100644 --- a/src/std/dev/devAaoSoft.c +++ b/src/std/dev/devAaoSoft.c @@ -52,7 +52,7 @@ epicsExportAddress(dset,devAaoSoft); static long init_record(aaoRecord *prec) { - if (prec->out.type == CONSTANT) { + if (dbLinkIsConstant(&prec->out)) { prec->nord = 0; } return 0; diff --git a/src/std/dev/devAiSoft.c b/src/std/dev/devAiSoft.c index ccd713d75..ba669f4c9 100644 --- a/src/std/dev/devAiSoft.c +++ b/src/std/dev/devAiSoft.c @@ -51,10 +51,9 @@ epicsExportAddress(dset, devAiSoft); static long init_record(aiRecord *prec) { - if (prec->inp.type == CONSTANT) { - if (recGblInitConstantLink(&prec->inp, DBF_DOUBLE, &prec->val)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->inp, DBF_DOUBLE, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -62,9 +61,6 @@ static long read_ai(aiRecord *prec) { double val; - if (prec->inp.type == CONSTANT) - return 2; - if (!dbGetLink(&prec->inp, DBR_DOUBLE, &val, 0, 0)) { /* Apply smoothing algorithm */ @@ -76,7 +72,7 @@ static long read_ai(aiRecord *prec) prec->udf = FALSE; prec->dpvt = &devAiSoft; /* Any non-zero value */ - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } else { diff --git a/src/std/dev/devAiSoftRaw.c b/src/std/dev/devAiSoftRaw.c index fa9d869ed..1ec289b38 100644 --- a/src/std/dev/devAiSoftRaw.c +++ b/src/std/dev/devAiSoftRaw.c @@ -50,16 +50,15 @@ epicsExportAddress(dset, devAiSoftRaw); static long init_record(aiRecord *prec) { - if (prec->inp.type == CONSTANT) { - recGblInitConstantLink(&prec->inp, DBF_LONG, &prec->rval); - } + recGblInitConstantLink(&prec->inp, DBF_LONG, &prec->rval); + return 0; } static long read_ai(aiRecord *prec) { if (!dbGetLink(&prec->inp, DBR_LONG, &prec->rval, 0, 0) && - prec->tsel.type == CONSTANT && + dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); diff --git a/src/std/dev/devBiDbState.c b/src/std/dev/devBiDbState.c index c0d7120b2..b0670c6db 100644 --- a/src/std/dev/devBiDbState.c +++ b/src/std/dev/devBiDbState.c @@ -66,7 +66,7 @@ static long read_bi(biRecord *prec) prec->udf = FALSE; } - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); diff --git a/src/std/dev/devBiSoft.c b/src/std/dev/devBiSoft.c index 4b0ee854a..a9364debc 100644 --- a/src/std/dev/devBiSoft.c +++ b/src/std/dev/devBiSoft.c @@ -48,19 +48,16 @@ epicsExportAddress(dset, devBiSoft); static long init_record(biRecord *prec) { - if (prec->inp.type == CONSTANT) { - if (recGblInitConstantLink(&prec->inp, DBF_ENUM, &prec->val)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->inp, DBF_ENUM, &prec->val)) + prec->udf = FALSE; return 0; } static long read_bi(biRecord *prec) { if (!dbGetLink(&prec->inp, DBR_USHORT, &prec->val, 0, 0)) { - if (prec->inp.type != CONSTANT) - prec->udf = FALSE; - if (prec->tsel.type == CONSTANT && + prec->udf = FALSE; + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } diff --git a/src/std/dev/devBiSoftRaw.c b/src/std/dev/devBiSoftRaw.c index 3f40bade8..2d8dc25e5 100644 --- a/src/std/dev/devBiSoftRaw.c +++ b/src/std/dev/devBiSoftRaw.c @@ -48,16 +48,14 @@ epicsExportAddress(dset, devBiSoftRaw); static long init_record(biRecord *prec) { - if (prec->inp.type == CONSTANT) { - recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval); - } + recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval); return 0; } static long read_bi(biRecord *prec) { if (!dbGetLink(&prec->inp, DBR_ULONG, &prec->rval, 0, 0) && - prec->tsel.type == CONSTANT && + dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); diff --git a/src/std/dev/devEventSoft.c b/src/std/dev/devEventSoft.c index 09987cb5b..c9a5f273e 100644 --- a/src/std/dev/devEventSoft.c +++ b/src/std/dev/devEventSoft.c @@ -48,10 +48,8 @@ epicsExportAddress(dset, devEventSoft); static long init_record(eventRecord *prec) { - if (prec->inp.type == CONSTANT) { - if (recGblInitConstantLink(&prec->inp, DBF_STRING, &prec->val)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->inp, DBF_STRING, &prec->val)) + prec->udf = FALSE; return 0; } @@ -60,7 +58,7 @@ static long read_event(eventRecord *prec) long status; char newEvent[MAX_STRING_SIZE]; - if (prec->inp.type != CONSTANT) { + if (!dbLinkIsConstant(&prec->inp)) { status = dbGetLink(&prec->inp, DBR_STRING, newEvent, 0, 0); if (status) return status; if (strcmp(newEvent, prec->val) != 0) { @@ -69,7 +67,7 @@ static long read_event(eventRecord *prec) } } prec->udf = FALSE; - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); return 0; diff --git a/src/std/dev/devHistogramSoft.c b/src/std/dev/devHistogramSoft.c index 21a09b52e..60e6e3ddd 100644 --- a/src/std/dev/devHistogramSoft.c +++ b/src/std/dev/devHistogramSoft.c @@ -52,10 +52,9 @@ epicsExportAddress(dset,devHistogramSoft); static long init_record(histogramRecord *prec) { - if (prec->svl.type == CONSTANT) { - if(recGblInitConstantLink(&prec->svl,DBF_DOUBLE,&prec->sgnl)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->svl,DBF_DOUBLE,&prec->sgnl)) + prec->udf = FALSE; + return 0; } diff --git a/src/std/dev/devLiSoft.c b/src/std/dev/devLiSoft.c index 3deea8493..0752b4f30 100644 --- a/src/std/dev/devLiSoft.c +++ b/src/std/dev/devLiSoft.c @@ -48,10 +48,9 @@ epicsExportAddress(dset, devLiSoft); static long init_record(longinRecord *prec) { - if (prec->inp.type == CONSTANT) { - if (recGblInitConstantLink(&prec->inp, DBF_LONG, &prec->val)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->inp, DBF_LONG, &prec->val)) + prec->udf = FALSE; + return 0; } @@ -61,7 +60,7 @@ static long read_longin(longinRecord *prec) status = dbGetLink(&prec->inp, DBR_LONG, &prec->val, 0, 0); if (!status && - prec->tsel.type == CONSTANT && + dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); return status; diff --git a/src/std/dev/devLsiSoft.c b/src/std/dev/devLsiSoft.c index a5547cba8..aadd48f0d 100644 --- a/src/std/dev/devLsiSoft.c +++ b/src/std/dev/devLsiSoft.c @@ -29,7 +29,7 @@ static long read_string(lsiRecord *prec) long status = dbGetLinkLS(&prec->inp, prec->val, prec->sizv, &prec->len); if (!status && - prec->tsel.type == CONSTANT && + dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); diff --git a/src/std/dev/devMbbiDirectSoft.c b/src/std/dev/devMbbiDirectSoft.c index ccbc7efe7..27dd2eb1f 100644 --- a/src/std/dev/devMbbiDirectSoft.c +++ b/src/std/dev/devMbbiDirectSoft.c @@ -48,19 +48,17 @@ epicsExportAddress(dset, devMbbiDirectSoft); static long init_record(mbbiDirectRecord *prec) { - if (prec->inp.type == CONSTANT) { - if (recGblInitConstantLink(&prec->inp, DBF_ENUM, &prec->val)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->inp, DBF_ENUM, &prec->val)) + prec->udf = FALSE; + return 0; } static long read_mbbi(mbbiDirectRecord *prec) { if (!dbGetLink(&prec->inp, DBR_USHORT, &prec->val, 0, 0)) { - if (prec->inp.type != CONSTANT) - prec->udf = FALSE; - if (prec->tsel.type == CONSTANT && + prec->udf = FALSE; + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } diff --git a/src/std/dev/devMbbiDirectSoftRaw.c b/src/std/dev/devMbbiDirectSoftRaw.c index 3824cdc14..2509ed392 100644 --- a/src/std/dev/devMbbiDirectSoftRaw.c +++ b/src/std/dev/devMbbiDirectSoftRaw.c @@ -48,11 +48,12 @@ epicsExportAddress(dset, devMbbiDirectSoftRaw); static long init_record(mbbiDirectRecord *prec) { - if (prec->inp.type == CONSTANT) { - recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval); - } - /*to preserve old functionality*/ - if (prec->nobt == 0) prec->mask = 0xffffffff; + recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval); + + /* Preserve old functionality */ + if (prec->nobt == 0) + prec->mask = 0xffffffff; + prec->mask <<= prec->shft; return 0; } @@ -61,7 +62,7 @@ static long read_mbbi(mbbiDirectRecord *prec) { if (!dbGetLink(&prec->inp, DBR_LONG, &prec->rval, 0, 0)) { prec->rval &= prec->mask; - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } diff --git a/src/std/dev/devMbbiSoft.c b/src/std/dev/devMbbiSoft.c index 210699fa6..406e8b6ec 100644 --- a/src/std/dev/devMbbiSoft.c +++ b/src/std/dev/devMbbiSoft.c @@ -48,19 +48,18 @@ epicsExportAddress(dset, devMbbiSoft); static long init_record(mbbiRecord *prec) { - if (prec->inp.type == CONSTANT) { - if (recGblInitConstantLink(&prec->inp, DBF_ENUM, &prec->val)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->inp, DBF_ENUM, &prec->val)) + prec->udf = FALSE; + return 0; } static long read_mbbi(mbbiRecord *prec) { if (!dbGetLink(&prec->inp, DBR_USHORT, &prec->val, 0, 0)) { - if (prec->inp.type != CONSTANT) - prec->udf = FALSE; - if (prec->tsel.type == CONSTANT && + prec->udf = FALSE; + + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } diff --git a/src/std/dev/devMbbiSoftRaw.c b/src/std/dev/devMbbiSoftRaw.c index 4d5b57cb9..ffe0b00f7 100644 --- a/src/std/dev/devMbbiSoftRaw.c +++ b/src/std/dev/devMbbiSoftRaw.c @@ -48,11 +48,12 @@ epicsExportAddress(dset, devMbbiSoftRaw); static long init_record(mbbiRecord *prec) { - if (prec->inp.type == CONSTANT) { - recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval); - } - /*to preserve old functionality*/ - if (prec->nobt == 0) prec->mask = 0xffffffff; + recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval); + + /* Preserve old functionality*/ + if (prec->nobt == 0) + prec->mask = 0xffffffff; + prec->mask <<= prec->shft; return 0; } @@ -61,7 +62,7 @@ static long read_mbbi(mbbiRecord *prec) { if (!dbGetLink(&prec->inp, DBR_LONG, &prec->rval, 0, 0)) { prec->rval &= prec->mask; - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } diff --git a/src/std/dev/devSASoft.c b/src/std/dev/devSASoft.c index 049fa644e..84c31c5a6 100644 --- a/src/std/dev/devSASoft.c +++ b/src/std/dev/devSASoft.c @@ -48,10 +48,16 @@ epicsExportAddress(dset, devSASoft); static long init_record(subArrayRecord *prec) { - if (prec->inp.type == CONSTANT) { - prec->nord = 0; + long nelm = prec->nelm; + long status = dbLoadLinkArray(&prec->inp, prec->ftvl, prec->bptr, &nelm); + + if (!status && nelm > 0) { + prec->nord = nelm; + prec->udf = FALSE; } - return 0; + else + prec->nord = 0; + return status; } static long read_sa(subArrayRecord *prec) @@ -62,7 +68,7 @@ static long read_sa(subArrayRecord *prec) if (nRequest > prec->malm) nRequest = prec->malm; - if (prec->inp.type == CONSTANT) + if (dbLinkIsConstant(&prec->inp)) nRequest = prec->nord; else dbGetLink(&prec->inp, prec->ftvl, prec->bptr, 0, &nRequest); @@ -81,7 +87,7 @@ static long read_sa(subArrayRecord *prec) prec->nord = ecount; if (nRequest > 0 && - prec->tsel.type == CONSTANT && + dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); diff --git a/src/std/dev/devSiSoft.c b/src/std/dev/devSiSoft.c index 044a41afb..a969185b7 100644 --- a/src/std/dev/devSiSoft.c +++ b/src/std/dev/devSiSoft.c @@ -50,10 +50,8 @@ epicsExportAddress(dset, devSiSoft); static long init_record(stringinRecord *prec) { - if (prec->inp.type == CONSTANT) { - if (recGblInitConstantLink(&prec->inp, DBF_STRING, prec->val)) - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->inp, DBF_STRING, prec->val)) + prec->udf = FALSE; return 0; } @@ -63,9 +61,9 @@ static long read_stringin(stringinRecord *prec) status = dbGetLink(&prec->inp, DBR_STRING, prec->val, 0, 0); if (!status) { - if (prec->inp.type != CONSTANT) + if (!dbLinkIsConstant(&prec->inp)) prec->udf = FALSE; - if (prec->tsel.type == CONSTANT && + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } diff --git a/src/std/dev/devWfSoft.c b/src/std/dev/devWfSoft.c index 9093344d7..35ddf73b6 100644 --- a/src/std/dev/devWfSoft.c +++ b/src/std/dev/devWfSoft.c @@ -68,7 +68,9 @@ static long read_wf(waveformRecord *prec) if (!status && nRequest > 0) { prec->nord = nRequest; - if (prec->tsel.type == CONSTANT && + prec->udf = FALSE; + + if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) dbGetTimeStamp(&prec->inp, &prec->time); } diff --git a/src/std/rec/aSubRecord.c b/src/std/rec/aSubRecord.c index 2e0785087..02461c135 100644 --- a/src/std/rec/aSubRecord.c +++ b/src/std/rec/aSubRecord.c @@ -121,22 +121,17 @@ static long init_record(aSubRecord *prec, int pass) } /* Initialize the Subroutine Name Link */ - if (prec->subl.type == CONSTANT) { - recGblInitConstantLink(&prec->subl, DBF_STRING, prec->snam); - } + recGblInitConstantLink(&prec->subl, DBF_STRING, prec->snam); /* Initialize Input Links */ for (i = 0; i < NUM_ARGS; i++) { struct link *plink = &(&prec->inpa)[i]; + short dbr = (&prec->fta)[i]; + long n = (&prec->noa)[i]; - if (plink->type == CONSTANT) { - short dbr = (&prec->fta)[i]; - long n = (&prec->noa)[i]; - - dbLoadLinkArray(plink, dbr, (&prec->a)[i], &n); - if (n > 0) - (&prec->nea)[i] = n; - } + dbLoadLinkArray(plink, dbr, (&prec->a)[i], &n); + if (n > 0) + (&prec->nea)[i] = n; } /* Call the user initialization routine if there is one */ diff --git a/src/std/rec/aaiRecord.c b/src/std/rec/aaiRecord.c index 9e1286704..612b2d8c5 100644 --- a/src/std/rec/aaiRecord.c +++ b/src/std/rec/aaiRecord.c @@ -140,9 +140,7 @@ static long init_record(aaiRecord *prec, int pass) return 0; } - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); - } + recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); /* must have read_aai function defined */ if (pdset->number < 5 || pdset->read_aai == NULL) { diff --git a/src/std/rec/aaoRecord.c b/src/std/rec/aaoRecord.c index 83a73328e..b547a4c00 100644 --- a/src/std/rec/aaoRecord.c +++ b/src/std/rec/aaoRecord.c @@ -140,9 +140,7 @@ static long init_record(aaoRecord *prec, int pass) return 0; } - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); - } + recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); /* must have write_aao function defined */ if (pdset->number < 5 || pdset->write_aao == NULL) { diff --git a/src/std/rec/aiRecord.c b/src/std/rec/aiRecord.c index b13c856f8..9d20cab0d 100644 --- a/src/std/rec/aiRecord.c +++ b/src/std/rec/aiRecord.c @@ -111,13 +111,8 @@ static long init_record(void *precord,int pass) if (pass==0) return(0); - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); - } - - if (prec->siol.type == CONSTANT) { - recGblInitConstantLink(&prec->siol,DBF_DOUBLE,&prec->sval); - } + recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); + recGblInitConstantLink(&prec->siol,DBF_DOUBLE,&prec->sval); if(!(pdset = (aidset *)(prec->dset))) { recGblRecordError(S_dev_noDSET,(void *)prec,"ai: init_record"); diff --git a/src/std/rec/aoRecord.c b/src/std/rec/aoRecord.c index 28b0c3c0c..a32c5bb55 100644 --- a/src/std/rec/aoRecord.c +++ b/src/std/rec/aoRecord.c @@ -110,19 +110,15 @@ static long init_record(aoRecord *prec, int pass) if (pass==0) return(0); - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); - } + recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); if(!(pdset = (struct aodset *)(prec->dset))) { recGblRecordError(S_dev_noDSET,(void *)prec,"ao: init_record"); return(S_dev_noDSET); } /* get the initial value if dol is a constant*/ - if (prec->dol.type == CONSTANT) { - if(recGblInitConstantLink(&prec->dol,DBF_DOUBLE,&prec->val)) - prec->udf = isnan(prec->val); - } + if (recGblInitConstantLink(&prec->dol,DBF_DOUBLE,&prec->val)) + prec->udf = isnan(prec->val); /* must have write_ao function defined */ if ((pdset->number < 6) || (pdset->write_ao ==NULL)) { @@ -189,8 +185,8 @@ static long process(aoRecord *prec) /* fetch value and convert*/ if (prec->pact == FALSE) { - if ((prec->dol.type != CONSTANT) - && (prec->omsl == menuOmslclosed_loop)) { + if (!dbLinkIsConstant(&prec->dol) && + prec->omsl == menuOmslclosed_loop) { status = fetch_value(prec, &value); } else { diff --git a/src/std/rec/boRecord.c b/src/std/rec/boRecord.c index d0ed38146..24b842d87 100644 --- a/src/std/rec/boRecord.c +++ b/src/std/rec/boRecord.c @@ -132,43 +132,40 @@ static void myCallbackFunc(CALLBACK *arg) static long init_record(boRecord *prec,int pass) { - struct bodset *pdset; - long status=0; + struct bodset *pdset = (struct bodset *) prec->dset; + unsigned short ival = 0; + long status = 0; myCallback *pcallback; - if (pass==0) return(0); + if (pass == 0) + return 0; - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + + if (!pdset) { + recGblRecordError(S_dev_noDSET, prec, "bo: init_record"); + return S_dev_noDSET; } - if(!(pdset = (struct bodset *)(prec->dset))) { - recGblRecordError(S_dev_noDSET,(void *)prec,"bo: init_record"); - return(S_dev_noDSET); - } /* must have write_bo functions defined */ - if( (pdset->number < 5) || (pdset->write_bo == NULL) ) { - recGblRecordError(S_dev_missingSup,(void *)prec,"bo: init_record"); - return(S_dev_missingSup); + if ((pdset->number < 5) || (pdset->write_bo == NULL)) { + recGblRecordError(S_dev_missingSup, prec, "bo: init_record"); + return S_dev_missingSup; } + /* get the initial value */ - if (prec->dol.type == CONSTANT) { - unsigned short ival = 0; - - if(recGblInitConstantLink(&prec->dol,DBF_USHORT,&ival)) { - if (ival == 0) prec->val = 0; - else prec->val = 1; - prec->udf = FALSE; - } + if (recGblInitConstantLink(&prec->dol, DBF_USHORT, &ival)) { + prec->val = !!ival; + prec->udf = FALSE; } - pcallback = (myCallback *)(calloc(1,sizeof(myCallback))); - prec->rpvt = (void *)pcallback; - callbackSetCallback(myCallbackFunc,&pcallback->callback); - callbackSetUser(pcallback,&pcallback->callback); - pcallback->precord = (struct dbCommon *)prec; + pcallback = (myCallback *) calloc(1, sizeof(myCallback)); + prec->rpvt = pcallback; + callbackSetCallback(myCallbackFunc, &pcallback->callback); + callbackSetUser(pcallback, &pcallback->callback); + pcallback->precord = (struct dbCommon *) prec; - if( pdset->init_record ) { + if (pdset->init_record) { status=(*pdset->init_record)(prec); if(status==0) { if(prec->rval==0) prec->val = 0; @@ -202,7 +199,8 @@ static long process(boRecord *prec) return(S_dev_missingSup); } if (!prec->pact) { - if ((prec->dol.type != CONSTANT) && (prec->omsl == menuOmslclosed_loop)){ + if (!dbLinkIsConstant(&prec->dol) && + prec->omsl == menuOmslclosed_loop) { unsigned short val; prec->pact = TRUE; diff --git a/src/std/rec/calcRecord.c b/src/std/rec/calcRecord.c index a83ee073a..b479b779b 100644 --- a/src/std/rec/calcRecord.c +++ b/src/std/rec/calcRecord.c @@ -100,9 +100,7 @@ static long init_record(calcRecord *prec, int pass) plink = &prec->inpa; pvalue = &prec->a; for (i = 0; i < CALCPERFORM_NARGS; i++, plink++, pvalue++) { - if (plink->type == CONSTANT) { - recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); - } + recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); } if (postfix(prec->calc, prec->rpcl, &error_number)) { recGblRecordError(S_db_badField, (void *)prec, diff --git a/src/std/rec/calcoutRecord.c b/src/std/rec/calcoutRecord.c index c62b3f446..217c2abf0 100644 --- a/src/std/rec/calcoutRecord.c +++ b/src/std/rec/calcoutRecord.c @@ -25,6 +25,7 @@ #include "dbDefs.h" #include "dbAccess.h" #include "dbEvent.h" +#include "dbLink.h" #include "dbScan.h" #include "cantProceed.h" #include "epicsMath.h" @@ -141,42 +142,57 @@ static long init_record(calcoutRecord *prec, int pass) epicsEnum16 *plinkValid; short error_number; calcoutDSET *pcalcoutDSET; - - DBADDR dbaddr; - DBADDR *pAddr = &dbaddr; rpvtStruct *prpvt; if (pass == 0) { prec->rpvt = (rpvtStruct *) callocMustSucceed(1, sizeof(rpvtStruct), "calcoutRecord"); return 0; } + if (!(pcalcoutDSET = (calcoutDSET *)prec->dset)) { recGblRecordError(S_dev_noDSET, (void *)prec, "calcout:init_record"); return S_dev_noDSET; } + /* must have write defined */ if ((pcalcoutDSET->number < 5) || (pcalcoutDSET->write ==NULL)) { recGblRecordError(S_dev_missingSup, (void *)prec, "calcout:init_record"); return S_dev_missingSup; } + prpvt = prec->rpvt; plink = &prec->inpa; pvalue = &prec->a; plinkValid = &prec->inav; + for (i = 0; i <= CALCPERFORM_NARGS; i++, plink++, pvalue++, plinkValid++) { - if (plink->type == CONSTANT) { - /* Don't InitConstantLink the .OUT link */ - if (i < CALCPERFORM_NARGS) { - recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); - } + /* Don't InitConstantLink the .OUT link */ + if (i < CALCPERFORM_NARGS) { + recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); + } + + if (dbLinkIsConstant(plink)) { *plinkValid = calcoutINAV_CON; - } else if (!dbNameToAddr(plink->value.pv_link.pvname, pAddr)) { - /* PV resides on this ioc */ + } + else if (dbLinkIsVolatile(plink)) { + int conn = dbIsLinkConnected(plink); + + if (conn) + *plinkValid = calcoutINAV_EXT; + else { + /* Monitor for connection */ + *plinkValid = calcoutINAV_EXT_NC; + prpvt->caLinkStat = CA_LINKS_NOT_OK; + } + } + else { + /* PV must reside on this ioc */ *plinkValid = calcoutINAV_LOC; - } else { - /* pv is not on this ioc. Callback later for connection stat */ - *plinkValid = calcoutINAV_EXT_NC; - prpvt->caLinkStat = CA_LINKS_NOT_OK; + + if (!dbIsLinkConnected(plink)) { + errlogPrintf("calcout: %s.INP%c in no-vo disco state\n", + prec->name, i+'A'); + } } } @@ -298,8 +314,6 @@ static long special(DBADDR *paddr, int after) { calcoutRecord *prec = (calcoutRecord *)paddr->precord; rpvtStruct *prpvt = prec->rpvt; - DBADDR dbaddr; - DBADDR *pAddr = &dbaddr; short error_number; int fieldIndex = dbGetFieldIndex(paddr); int lnkIndex; @@ -347,23 +361,35 @@ static long special(DBADDR *paddr, int after) plink = &prec->inpa + lnkIndex; pvalue = &prec->a + lnkIndex; plinkValid = &prec->inav + lnkIndex; - if (plink->type == CONSTANT) { - if (fieldIndex != calcoutRecordOUT) { - recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); - db_post_events(prec, pvalue, DBE_VALUE); - } + + if (fieldIndex != calcoutRecordOUT) + recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); + if (dbLinkIsConstant(plink)) { + db_post_events(prec, pvalue, DBE_VALUE); *plinkValid = calcoutINAV_CON; - } else if (!dbNameToAddr(plink->value.pv_link.pvname, pAddr)) { - /* if the PV resides on this ioc */ + } else if (dbLinkIsVolatile(plink)) { + int conn = dbIsLinkConnected(plink); + + if (conn) + *plinkValid = calcoutINAV_EXT; + else { + /* Monitor for connection */ + *plinkValid = calcoutINAV_EXT_NC; + /* DO_CALLBACK, if not already scheduled */ + if (!prpvt->cbScheduled) { + callbackRequestDelayed(&prpvt->checkLinkCb, .5); + prpvt->cbScheduled = 1; + prpvt->caLinkStat = CA_LINKS_NOT_OK; + } + } + } + else { + /* PV must reside on this ioc */ *plinkValid = calcoutINAV_LOC; - } else { - /* pv is not on this ioc. Callback later for connection stat */ - *plinkValid = calcoutINAV_EXT_NC; - /* DO_CALLBACK, if not already scheduled */ - if (!prpvt->cbScheduled) { - callbackRequestDelayed(&prpvt->checkLinkCb, .5); - prpvt->cbScheduled = 1; - prpvt->caLinkStat = CA_LINKS_NOT_OK; + + if (!dbIsLinkConnected(plink)) { + errlogPrintf("calcout: %s.INP%c in no-vo diso state\n", + prec->name, lnkIndex); } } db_post_events(prec, plinkValid, DBE_VALUE); @@ -706,9 +732,9 @@ static void checkLinks(calcoutRecord *prec) plinkValid = &prec->inav; for (i = 0; itype == CA_LINK) { + if (dbLinkIsVolatile(plink) == 1) { caLink = 1; - stat = dbCaIsLinkConnected(plink); + stat = dbIsLinkConnected(plink); if (!stat && (*plinkValid == calcoutINAV_EXT_NC)) { caLinkNc = 1; } diff --git a/src/std/rec/dfanoutRecord.c b/src/std/rec/dfanoutRecord.c index 15d06fb3c..d25093d4f 100644 --- a/src/std/rec/dfanoutRecord.c +++ b/src/std/rec/dfanoutRecord.c @@ -95,24 +95,27 @@ static void push_values(dfanoutRecord *); static long init_record(dfanoutRecord *prec, int pass) { - if (pass==0) return(0); + if (pass==0) + return 0; + + recGblInitConstantLink(&prec->sell, DBF_USHORT, &prec->seln); - recGblInitConstantLink(&prec->sell,DBF_USHORT,&prec->seln); /* get the initial value dol is a constant*/ - if(recGblInitConstantLink(&prec->dol,DBF_DOUBLE,&prec->val)) - prec->udf = isnan(prec->val); - return(0); + if (recGblInitConstantLink(&prec->dol, DBF_DOUBLE, &prec->val)) + prec->udf = isnan(prec->val); + + return 0; } static long process(dfanoutRecord *prec) { long status=0; - if (!prec->pact - && (prec->dol.type != CONSTANT) - && (prec->omsl == menuOmslclosed_loop)){ - status = dbGetLink(&(prec->dol),DBR_DOUBLE,&(prec->val),0,0); - if(prec->dol.type!=CONSTANT && RTN_SUCCESS(status)) + if (!prec->pact && + !dbLinkIsConstant(&prec->dol) && + prec->omsl == menuOmslclosed_loop) { + status = dbGetLink(&prec->dol, DBR_DOUBLE, &prec->val, 0, 0); + if (!dbLinkIsConstant(&prec->dol) && !status) prec->udf = isnan(prec->val); } prec->pact = TRUE; diff --git a/src/std/rec/eventRecord.c b/src/std/rec/eventRecord.c index a7f9c82a9..35fd32192 100644 --- a/src/std/rec/eventRecord.c +++ b/src/std/rec/eventRecord.c @@ -100,13 +100,8 @@ static long init_record(eventRecord *prec, int pass) if (pass==0) return(0); - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); - } - - if (prec->siol.type == CONSTANT) { - recGblInitConstantLink(&prec->siol,DBF_STRING,&prec->sval); - } + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + recGblInitConstantLink(&prec->siol, DBF_STRING, &prec->sval); prec->epvt = eventNameToHandle(prec->val); diff --git a/src/std/rec/fanoutRecord.c b/src/std/rec/fanoutRecord.c index e2bec291c..7897fbc6f 100644 --- a/src/std/rec/fanoutRecord.c +++ b/src/std/rec/fanoutRecord.c @@ -106,8 +106,7 @@ static long process(fanoutRecord *prec) case fanoutSELM_All: plink = &prec->lnk0; for (i = 0; i < NLINKS; i++, plink++) { - if (plink->type != CONSTANT) - dbScanFwdLink(plink); + dbScanFwdLink(plink); } break; @@ -134,7 +133,7 @@ static long process(fanoutRecord *prec) break; plink = &prec->lnk0; for (i = 0; i < NLINKS; i++, seln >>= 1, plink++) { - if (seln & 1 && plink->type != CONSTANT) + if (seln & 1) dbScanFwdLink(plink); } break; diff --git a/src/std/rec/histogramRecord.c b/src/std/rec/histogramRecord.c index 74b2fcd17..643c4fa68 100644 --- a/src/std/rec/histogramRecord.c +++ b/src/std/rec/histogramRecord.c @@ -183,13 +183,8 @@ static long init_record(histogramRecord *prec, int pass) wdogInit(prec); - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); - } - - if (prec->siol.type == CONSTANT) { - recGblInitConstantLink(&prec->siol, DBF_DOUBLE, &prec->sval); - } + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + recGblInitConstantLink(&prec->siol, DBF_DOUBLE, &prec->sval); /* must have device support defined */ pdset = (struct histogramdset *) prec->dset; diff --git a/src/std/rec/longinRecord.c b/src/std/rec/longinRecord.c index bd224ac1d..91d7e2193 100644 --- a/src/std/rec/longinRecord.c +++ b/src/std/rec/longinRecord.c @@ -98,35 +98,36 @@ static long readValue(longinRecord *prec); static long init_record(longinRecord *prec, int pass) { - struct longindset *pdset; - long status; + struct longindset *pdset = (struct longindset *) prec->dset; - if (pass==0) return(0); + if (pass==0) + return(0); - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + recGblInitConstantLink(&prec->siol, DBF_LONG, &prec->sval); + + if (!pdset) { + recGblRecordError(S_dev_noDSET, prec, "longin: init_record"); + return S_dev_noDSET; } - if (prec->siol.type == CONSTANT) { - recGblInitConstantLink(&prec->siol,DBF_LONG,&prec->sval); - } - - if(!(pdset = (struct longindset *)(prec->dset))) { - recGblRecordError(S_dev_noDSET,(void *)prec,"longin: init_record"); - return(S_dev_noDSET); - } /* must have read_longin function defined */ - if( (pdset->number < 5) || (pdset->read_longin == NULL) ) { - recGblRecordError(S_dev_missingSup,(void *)prec,"longin: init_record"); - return(S_dev_missingSup); + if ((pdset->number < 5) || (pdset->read_longin == NULL)) { + recGblRecordError(S_dev_missingSup, prec, "longin: init_record"); + return S_dev_missingSup; } - if( pdset->init_record ) { - if((status=(*pdset->init_record)(prec))) return(status); + + if (pdset->init_record) { + long status = pdset->init_record(prec); + + if (status) + return status; } + prec->mlst = prec->val; prec->alst = prec->val; prec->lalm = prec->val; - return(0); + return 0; } static long process(longinRecord *prec) diff --git a/src/std/rec/longoutRecord.c b/src/std/rec/longoutRecord.c index afdf90ea8..5d35df634 100644 --- a/src/std/rec/longoutRecord.c +++ b/src/std/rec/longoutRecord.c @@ -95,33 +95,38 @@ static void convert(longoutRecord *prec, epicsInt32 value); static long init_record(longoutRecord *prec, int pass) { - struct longoutdset *pdset; - long status=0; + struct longoutdset *pdset = (struct longoutdset *) prec->dset; - if (pass==0) return(0); - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); - } - if(!(pdset = (struct longoutdset *)(prec->dset))) { - recGblRecordError(S_dev_noDSET,(void *)prec,"longout: init_record"); - return(S_dev_noDSET); + if (pass==0) + return 0; + + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + + if (!pdset) { + recGblRecordError(S_dev_noDSET, prec, "longout: init_record"); + return S_dev_noDSET; } + /* must have write_longout functions defined */ - if( (pdset->number < 5) || (pdset->write_longout == NULL) ) { - recGblRecordError(S_dev_missingSup,(void *)prec,"longout: init_record"); - return(S_dev_missingSup); + if ((pdset->number < 5) || (pdset->write_longout == NULL)) { + recGblRecordError(S_dev_missingSup, prec, "longout: init_record"); + return S_dev_missingSup; } - if (prec->dol.type == CONSTANT) { - if(recGblInitConstantLink(&prec->dol,DBF_LONG,&prec->val)) - prec->udf=FALSE; - } - if( pdset->init_record ) { - if((status=(*pdset->init_record)(prec))) return(status); + + if (recGblInitConstantLink(&prec->dol, DBF_LONG, &prec->val)) + prec->udf=FALSE; + + if (pdset->init_record) { + long status = pdset->init_record(prec); + + if (status) + return status; } + prec->mlst = prec->val; prec->alst = prec->val; prec->lalm = prec->val; - return(0); + return 0; } static long process(longoutRecord *prec) @@ -137,11 +142,10 @@ static long process(longoutRecord *prec) return(S_dev_missingSup); } if (!prec->pact) { - if((prec->dol.type != CONSTANT) - && (prec->omsl == menuOmslclosed_loop)) { - status = dbGetLink(&(prec->dol),DBR_LONG, - &value,0,0); - if (prec->dol.type!=CONSTANT && RTN_SUCCESS(status)) + if (!dbLinkIsConstant(&prec->dol) && + prec->omsl == menuOmslclosed_loop) { + status = dbGetLink(&prec->dol, DBR_LONG, &value, 0, 0); + if (!dbLinkIsConstant(&prec->dol) && !status) prec->udf=FALSE; } else { diff --git a/src/std/rec/mbbiDirectRecord.c b/src/std/rec/mbbiDirectRecord.c index 1d603ab5a..cc1170b7e 100644 --- a/src/std/rec/mbbiDirectRecord.c +++ b/src/std/rec/mbbiDirectRecord.c @@ -114,11 +114,8 @@ static long init_record(mbbiDirectRecord *prec, int pass) return S_dev_missingSup; } - if (prec->siml.type == CONSTANT) - recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); - - if (prec->siol.type == CONSTANT) - recGblInitConstantLink(&prec->siol, DBF_USHORT, &prec->sval); + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + recGblInitConstantLink(&prec->siol, DBF_USHORT, &prec->sval); /* Initialize MASK if the user set NOBT instead */ if (prec->mask == 0 && prec->nobt <= 32) diff --git a/src/std/rec/mbbiRecord.c b/src/std/rec/mbbiRecord.c index bfc4fdba6..bd344f307 100644 --- a/src/std/rec/mbbiRecord.c +++ b/src/std/rec/mbbiRecord.c @@ -131,11 +131,8 @@ static long init_record(mbbiRecord *prec, int pass) return S_dev_missingSup; } - if (prec->siml.type == CONSTANT) - recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); - - if (prec->siol.type == CONSTANT) - recGblInitConstantLink(&prec->siol, DBF_USHORT, &prec->sval); + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + recGblInitConstantLink(&prec->siol, DBF_USHORT, &prec->sval); /* Initialize MASK if the user set NOBT instead */ if (prec->mask == 0 && prec->nobt <= 32) diff --git a/src/std/rec/mbboDirectRecord.c b/src/std/rec/mbboDirectRecord.c index ae43bdcf2..fb36a0a3b 100644 --- a/src/std/rec/mbboDirectRecord.c +++ b/src/std/rec/mbboDirectRecord.c @@ -116,12 +116,9 @@ static long init_record(mbboDirectRecord *prec, int pass) return S_dev_missingSup; } - if (prec->siml.type == CONSTANT) - recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); - - if (prec->dol.type == CONSTANT) - if (recGblInitConstantLink(&prec->dol, DBF_USHORT, &prec->val)) - prec->udf = FALSE; + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + if (recGblInitConstantLink(&prec->dol, DBF_USHORT, &prec->val)) + prec->udf = FALSE; /* Initialize MASK if the user set NOBT instead */ if (prec->mask == 0 && prec->nobt <= 32) @@ -175,7 +172,7 @@ static long process(mbboDirectRecord *prec) } if (!pact) { - if (prec->dol.type != CONSTANT && + if (!dbLinkIsConstant(&prec->dol) && prec->omsl == menuOmslclosed_loop) { epicsUInt16 val; diff --git a/src/std/rec/mbboRecord.c b/src/std/rec/mbboRecord.c index ffb6f1eed..9d00a6d5e 100644 --- a/src/std/rec/mbboRecord.c +++ b/src/std/rec/mbboRecord.c @@ -136,12 +136,9 @@ static long init_record(mbboRecord *prec, int pass) return S_dev_missingSup; } - if (prec->siml.type == CONSTANT) - recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); - - if (prec->dol.type == CONSTANT) - if (recGblInitConstantLink(&prec->dol, DBF_USHORT, &prec->val)) - prec->udf = FALSE; + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + if (recGblInitConstantLink(&prec->dol, DBF_USHORT, &prec->val)) + prec->udf = FALSE; /* Initialize MASK if the user set NOBT instead */ if (prec->mask == 0 && prec->nobt <= 32) @@ -206,7 +203,7 @@ static long process(mbboRecord *prec) } if (!pact) { - if (prec->dol.type != CONSTANT && + if (!dbLinkIsConstant(&prec->dol) && prec->omsl == menuOmslclosed_loop) { epicsUInt16 val; diff --git a/src/std/rec/printfRecord.c b/src/std/rec/printfRecord.c index 977349ae8..f8419e4ad 100644 --- a/src/std/rec/printfRecord.c +++ b/src/std/rec/printfRecord.c @@ -46,7 +46,7 @@ VALTYPE val; \ int ok; \ \ - if (plink->type == CONSTANT) \ + if (dbLinkIsConstant(plink)) \ ok = recGblInitConstantLink(plink++, DBRTYPE, &val); \ else \ ok = ! dbGetLink(plink++, DBRTYPE, &val, 0, 0); \ @@ -113,7 +113,7 @@ static void doPrintf(printfRecord *prec) epicsInt16 i; int ok; - if (plink->type == CONSTANT) + if (dbLinkIsConstant(plink)) ok = recGblInitConstantLink(plink++, DBR_SHORT, &i); else ok = ! dbGetLink(plink++, DBR_SHORT, &i, 0, 0); @@ -203,8 +203,8 @@ static void doPrintf(printfRecord *prec) } break; - case 's': - if (flags & F_LONG && plink->type != CONSTANT) { + case 's': /* FIXME: const strings are now supported */ + if (flags & F_LONG && !dbLinkIsConstant(plink)) { long n = vspace + 1; if (precision && n > precision) @@ -252,7 +252,7 @@ static void doPrintf(printfRecord *prec) char val[MAX_STRING_SIZE]; int ok; - if (plink->type == CONSTANT) + if (dbLinkIsConstant(plink)) ok = recGblInitConstantLink(plink++, DBR_STRING, val); else ok = ! dbGetLink(plink++, DBR_STRING, val, 0, 0); diff --git a/src/std/rec/selRecord.c b/src/std/rec/selRecord.c index b9f385173..37456feff 100644 --- a/src/std/rec/selRecord.c +++ b/src/std/rec/selRecord.c @@ -92,22 +92,19 @@ static long init_record(selRecord *prec, int pass) int i; double *pvalue; - if (pass==0) return(0); + if (pass==0) + return 0; /* get seln initial value if nvl is a constant*/ - if (prec->nvl.type == CONSTANT ) { - recGblInitConstantLink(&prec->nvl,DBF_USHORT,&prec->seln); - } + recGblInitConstantLink(&prec->nvl, DBF_USHORT, &prec->seln); plink = &prec->inpa; pvalue = &prec->a; - for(i=0; itype==CONSTANT) { - recGblInitConstantLink(plink,DBF_DOUBLE,pvalue); - } + for (i=0; icallback); prec->dpvt = pseqRecPvt; - if (prec->sell.type == CONSTANT) - recGblInitConstantLink(&prec->sell, DBF_USHORT, &prec->seln); + recGblInitConstantLink(&prec->sell, DBF_USHORT, &prec->seln); grp = (linkGrp *) &prec->dly0; for (index = 0; index < NUM_LINKS; index++, grp++) { - if (grp->dol.type == CONSTANT) - recGblInitConstantLink(&grp->dol, DBF_DOUBLE, &grp->dov); + recGblInitConstantLink(&grp->dol, DBF_DOUBLE, &grp->dov); } prec->oldn = prec->seln; @@ -150,8 +148,7 @@ static long process(seqRecord *prec) lmask = (1 << NUM_LINKS) - 1; else { /* Get SELN value */ - if (prec->sell.type != CONSTANT) - dbGetLink(&prec->sell, DBR_USHORT, &prec->seln, 0, 0); + dbGetLink(&prec->sell, DBR_USHORT, &prec->seln, 0, 0); if (prec->selm == seqSELM_Specified) { int grpn = prec->seln + prec->offs; @@ -185,7 +182,8 @@ static long process(seqRecord *prec) pgrp = (linkGrp *) &prec->dly0; for (i = 0; lmask; lmask >>= 1) { if ((lmask & 1) && - (pgrp->lnk.type != CONSTANT || pgrp->dol.type != CONSTANT)) { + (!dbLinkIsConstant(&pgrp->lnk) || + !dbLinkIsConstant(&pgrp->dol))) { pcb->grps[i++] = pgrp; } pgrp++; diff --git a/src/std/rec/stringinRecord.c b/src/std/rec/stringinRecord.c index 00988223c..474b24324 100644 --- a/src/std/rec/stringinRecord.c +++ b/src/std/rec/stringinRecord.c @@ -95,33 +95,33 @@ static long readValue(stringinRecord *); static long init_record(stringinRecord *prec, int pass) { STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val)); - struct stringindset *pdset; - long status; + struct stringindset *pdset = (struct stringindset *) prec->dset; - if (pass==0) return(0); + if (pass==0) + return 0; - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + recGblInitConstantLink(&prec->siol, DBF_STRING, prec->sval); + + if (!pdset) { + recGblRecordError(S_dev_noDSET, prec, "stringin: init_record"); + return S_dev_noDSET; } - if (prec->siol.type == CONSTANT) { - recGblInitConstantLink(&prec->siol,DBF_STRING,prec->sval); - } - - if(!(pdset = (struct stringindset *)(prec->dset))) { - recGblRecordError(S_dev_noDSET,(void *)prec,"stringin: init_record"); - return(S_dev_noDSET); - } /* must have read_stringin function defined */ - if( (pdset->number < 5) || (pdset->read_stringin == NULL) ) { - recGblRecordError(S_dev_missingSup,(void *)prec,"stringin: init_record"); - return(S_dev_missingSup); + if ((pdset->number < 5) || (pdset->read_stringin == NULL)) { + recGblRecordError(S_dev_missingSup, prec, "stringin: init_record"); + return S_dev_missingSup; } - if( pdset->init_record ) { - if((status=(*pdset->init_record)(prec))) return(status); + + if (pdset->init_record) { + long status = pdset->init_record(prec); + + if (status) + return status; } - strcpy(prec->oval,prec->val); - return(0); + strcpy(prec->oval, prec->val); + return 0; } /* diff --git a/src/std/rec/stringoutRecord.c b/src/std/rec/stringoutRecord.c index 1bd376176..dbb368a59 100644 --- a/src/std/rec/stringoutRecord.c +++ b/src/std/rec/stringoutRecord.c @@ -97,34 +97,37 @@ static long writeValue(stringoutRecord *); static long init_record(stringoutRecord *prec, int pass) { STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val)); - struct stringoutdset *pdset; - long status=0; + struct stringoutdset *pdset = (struct stringoutdset *) prec->dset; - if (pass==0) return(0); + if (pass==0) + return 0; - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); + recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm); + + if (!pdset) { + recGblRecordError(S_dev_noDSET, prec, "stringout: init_record"); + return S_dev_noDSET; } - if(!(pdset = (struct stringoutdset *)(prec->dset))) { - recGblRecordError(S_dev_noDSET,(void *)prec,"stringout: init_record"); - return(S_dev_noDSET); - } /* must have write_stringout functions defined */ - if( (pdset->number < 5) || (pdset->write_stringout == NULL) ) { - recGblRecordError(S_dev_missingSup,(void *)prec,"stringout: init_record"); - return(S_dev_missingSup); + if ((pdset->number < 5) || (pdset->write_stringout == NULL)) { + recGblRecordError(S_dev_missingSup, prec, "stringout: init_record"); + return S_dev_missingSup; } + /* get the initial value dol is a constant*/ - if (prec->dol.type == CONSTANT){ - if(recGblInitConstantLink(&prec->dol,DBF_STRING,prec->val)) - prec->udf=FALSE; + if (recGblInitConstantLink(&prec->dol, DBF_STRING, prec->val)) + prec->udf = FALSE; + + if (pdset->init_record) { + long status = pdset->init_record(prec); + + if(status) + return status; } - if( pdset->init_record ) { - if((status=(*pdset->init_record)(prec))) return(status); - } - strcpy(prec->oval,prec->val); - return(0); + + strcpy(prec->oval, prec->val); + return 0; } static long process(stringoutRecord *prec) @@ -138,13 +141,13 @@ static long process(stringoutRecord *prec) recGblRecordError(S_dev_missingSup,(void *)prec,"write_stringout"); return(S_dev_missingSup); } - if (!prec->pact - && (prec->dol.type != CONSTANT) - && (prec->omsl == menuOmslclosed_loop)) { - status = dbGetLink(&(prec->dol), - DBR_STRING,prec->val,0,0); - if(prec->dol.type!=CONSTANT && RTN_SUCCESS(status)) prec->udf=FALSE; - } + if (!prec->pact && + !dbLinkIsConstant(&prec->dol) && + prec->omsl == menuOmslclosed_loop) { + status = dbGetLink(&prec->dol, DBR_STRING, prec->val, 0, 0); + if (!dbLinkIsConstant(&prec->dol) && !status) + prec->udf=FALSE; + } if(prec->udf == TRUE ){ recGblSetSevr(prec,UDF_ALARM,prec->udfs); diff --git a/src/std/rec/subRecord.c b/src/std/rec/subRecord.c index f8808a849..9cb3ae683 100644 --- a/src/std/rec/subRecord.c +++ b/src/std/rec/subRecord.c @@ -101,9 +101,7 @@ static long init_record(subRecord *prec, int pass) plink = &prec->inpa; pvalue = &prec->a; for (i = 0; i < INP_ARG_MAX; i++, plink++, pvalue++) { - if (plink->type == CONSTANT) { - recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); - } + recGblInitConstantLink(plink, DBF_DOUBLE, pvalue); } if (prec->inam[0]) { diff --git a/src/std/rec/waveformRecord.c b/src/std/rec/waveformRecord.c index c6ca2a04a..71e19014a 100644 --- a/src/std/rec/waveformRecord.c +++ b/src/std/rec/waveformRecord.c @@ -111,9 +111,7 @@ static long init_record(waveformRecord *prec, int pass) return 0; } - if (prec->siml.type == CONSTANT) { - recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); - } + recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm); /* must have dset defined */ if (!(pdset = (struct wfdset *)(prec->dset))) { @@ -313,7 +311,7 @@ static long readValue(waveformRecord *prec) return (*pdset->read_wf)(prec); } - status = dbGetLink(&(prec->siml), DBR_ENUM, &(prec->simm),0,0); + status = dbGetLink(&prec->siml, DBR_ENUM, &prec->simm, 0, 0); if (status) return status; @@ -329,9 +327,9 @@ static long readValue(waveformRecord *prec) if (prec->simm == menuYesNoYES){ long nRequest = prec->nelm; - status = dbGetLink(&(prec->siol), prec->ftvl, prec->bptr, 0, &nRequest); + status = dbGetLink(&prec->siol, prec->ftvl, prec->bptr, 0, &nRequest); /* nord set only for db links: needed for old db_access */ - if (prec->siol.type != CONSTANT) { + if (!dbLinkIsConstant(&prec->siol)) { prec->nord = nRequest; db_post_events(prec, &prec->nord, DBE_VALUE | DBE_LOG); if (status == 0)