Clean-up of aai and waveform record sources

This commit is contained in:
Andrew Johnson
2018-10-26 17:05:40 -05:00
parent 2efe56c6d1
commit 23d9176772
2 changed files with 56 additions and 49 deletions
+20 -17
View File
@@ -106,7 +106,6 @@ static long init_record(struct dbCommon *pcommon, int pass)
{
struct aaiRecord *prec = (struct aaiRecord *)pcommon;
struct aaidset *pdset = (struct aaidset *)(prec->dset);
long status;
/* must have dset defined */
if (!pdset) {
@@ -119,11 +118,7 @@ static long init_record(struct dbCommon *pcommon, int pass)
prec->nelm = 1;
if (prec->ftvl > DBF_ENUM)
prec->ftvl = DBF_UCHAR;
if (prec->nelm == 1) {
prec->nord = 1;
} else {
prec->nord = 0;
}
prec->nord = (prec->nelm == 1);
/* we must call pdset->init_record in pass 0
because it may set prec->bptr which must
@@ -131,8 +126,10 @@ static long init_record(struct dbCommon *pcommon, int pass)
*/
if (pdset->init_record) {
long status = pdset->init_record(prec);
/* init_record may set the bptr to point to the data */
if ((status = pdset->init_record(prec)))
if (status)
return status;
}
if (!prec->bptr) {
@@ -142,7 +139,7 @@ static long init_record(struct dbCommon *pcommon, int pass)
}
return 0;
}
recGblInitSimm(pcommon, &prec->sscn, &prec->oldsimm, &prec->simm, &prec->siml);
/* must have read_aai function defined */
@@ -167,9 +164,10 @@ static long process(struct dbCommon *pcommon)
}
status = readValue(prec); /* read the new value */
if (!pact && prec->pact) return 0;
prec->pact = TRUE;
if (!pact && prec->pact)
return 0;
prec->pact = TRUE;
prec->udf = FALSE;
recGblGetTimeStampSimm(prec, prec->simm, &prec->siol);
@@ -187,17 +185,19 @@ static long special(DBADDR *paddr, int after)
int special_type = paddr->special;
switch(special_type) {
case(SPC_MOD):
case SPC_MOD:
if (dbGetFieldIndex(paddr) == aaiRecordSIMM) {
if (!after)
recGblSaveSimm(prec->sscn, &prec->oldsimm, prec->simm);
else
recGblCheckSimm((dbCommon *)prec, &prec->sscn, prec->oldsimm, prec->simm);
return(0);
recGblCheckSimm((dbCommon *)prec, &prec->sscn, prec->oldsimm,
prec->simm);
return 0;
}
default:
recGblDbaddrError(S_db_badChoice, paddr, "aai: special");
return(S_db_badChoice);
return S_db_badChoice;
}
}
@@ -357,11 +357,14 @@ static long readValue(aaiRecord *prec)
if (prec->sdly >= 0) {
CALLBACK *pvt = prec->simpvt;
if (!pvt) {
pvt = calloc(1, sizeof(CALLBACK)); /* very lazy allocation of callback structure */
if (!pvt) { /* very lazy allocation of callback structure */
pvt = calloc(1, sizeof(CALLBACK));
prec->simpvt = pvt;
}
if (pvt) callbackRequestProcessCallbackDelayed(pvt, prec->prio, prec, prec->sdly);
if (pvt)
callbackRequestProcessCallbackDelayed(pvt, prec->prio, prec,
prec->sdly);
prec->pact = TRUE;
return 0;
}
+36 -32
View File
@@ -97,18 +97,14 @@ static long init_record(struct dbCommon *pcommon, int pass)
struct waveformRecord *prec = (struct waveformRecord *)pcommon;
struct wfdset *pdset;
if (pass == 0){
if (pass == 0) {
if (prec->nelm <= 0)
prec->nelm = 1;
if (prec->ftvl > DBF_ENUM)
prec->ftvl = DBF_UCHAR;
prec->bptr = callocMustSucceed(prec->nelm, dbValueSize(prec->ftvl),
"waveform calloc failed");
if (prec->nelm == 1) {
prec->nord = 1;
} else {
prec->nord = 0;
}
prec->nord = (prec->nelm == 1);
return 0;
}
@@ -124,16 +120,18 @@ static long init_record(struct dbCommon *pcommon, int pass)
recGblRecordError(S_dev_missingSup,(void *)prec,"wf: init_record");
return S_dev_missingSup;
}
if (! pdset->init_record) return 0;
if (!pdset->init_record)
return 0;
return (*pdset->init_record)(prec);
return pdset->init_record(prec);
}
static long process(struct dbCommon *pcommon)
{
struct waveformRecord *prec = (struct waveformRecord *)pcommon;
struct wfdset *pdset = (struct wfdset *)(prec->dset);
unsigned char pact=prec->pact;
unsigned char pact=prec->pact;
long status;
if ((pdset==NULL) || (pdset->read_wf==NULL)) {
prec->pact=TRUE;
@@ -141,13 +139,14 @@ static long process(struct dbCommon *pcommon)
return S_dev_missingSup;
}
if (pact && prec->busy) return 0;
if (pact && prec->busy)
return 0;
readValue(prec); /* read the new value */
if (!pact && prec->pact) return 0;
status = readValue(prec); /* read the new value */
if (!pact && prec->pact)
return 0;
prec->udf = FALSE;
prec->pact = TRUE;
recGblGetTimeStampSimm(prec, prec->simm, &prec->siol);
monitor(prec);
@@ -156,26 +155,27 @@ static long process(struct dbCommon *pcommon)
recGblFwdLink(prec);
prec->pact=FALSE;
return 0;
return status;
}
static long special(DBADDR *paddr, int after)
{
waveformRecord *prec = (waveformRecord *)(paddr->precord);
int special_type = paddr->special;
int special_type = paddr->special;
switch(special_type) {
case(SPC_MOD):
case SPC_MOD:
if (dbGetFieldIndex(paddr) == waveformRecordSIMM) {
if (!after)
recGblSaveSimm(prec->sscn, &prec->oldsimm, prec->simm);
else
recGblCheckSimm((dbCommon *)prec, &prec->sscn, prec->oldsimm, prec->simm);
return(0);
recGblCheckSimm((dbCommon *)prec, &prec->sscn, prec->oldsimm,
prec->simm);
return 0;
}
default:
recGblDbaddrError(S_db_badChoice, paddr, "waveform: special");
return(S_db_badChoice);
return S_db_badChoice;
}
}
@@ -325,15 +325,17 @@ static void monitor(waveformRecord *prec)
db_post_events(prec, &prec->val, monitor_mask);
}
}
static long readValue(waveformRecord *prec)
{
struct wfdset *pdset = (struct wfdset *) prec->dset;
long status = 0;
if (!prec->pact) {
status = recGblGetSimm((dbCommon *)prec, &prec->sscn, &prec->oldsimm, &prec->simm, &prec->siml);
if (status) return status;
status = recGblGetSimm((dbCommon *)prec, &prec->sscn, &prec->oldsimm,
&prec->simm, &prec->siml);
if (status)
return status;
}
switch (prec->simm) {
@@ -348,27 +350,29 @@ static long readValue(waveformRecord *prec)
case menuYesNoYES: {
long nRequest = prec->nelm;
epicsUInt32 nord = prec->nord;
recGblSetSevr(prec, SIMM_ALARM, prec->sims);
if (prec->pact || (prec->sdly < 0.)) {
if (prec->pact || (prec->sdly < 0)) {
status = dbGetLink(&prec->siol, prec->ftvl, prec->bptr, 0, &nRequest);
if (status == 0)
prec->udf = FALSE;
if (!dbLinkIsConstant(&prec->siol)) {
if (nRequest != prec->nord) {
prec->nord = nRequest;
if (nord != prec->nord)
db_post_events(prec, &prec->nord, DBE_VALUE | DBE_LOG);
db_post_events(prec, &prec->nord, DBE_VALUE | DBE_LOG);
}
prec->pact = FALSE;
} else { /* !prec->pact && delay >= 0. */
}
else { /* !prec->pact && delay >= 0 */
CALLBACK *pvt = prec->simpvt;
if (!pvt) {
pvt = calloc(1, sizeof(CALLBACK)); /* very lazy allocation of callback structure */
if (!pvt) { /* very lazy allocation of callback structure */
pvt = calloc(1, sizeof(CALLBACK));
prec->simpvt = pvt;
}
if (pvt) callbackRequestProcessCallbackDelayed(pvt, prec->prio, prec, prec->sdly);
if (pvt)
callbackRequestProcessCallbackDelayed(pvt, prec->prio, prec,
prec->sdly);
prec->pact = TRUE;
}
break;