Minimize work done in readLocked() routine
Move post-I/O work back to the read_xx routines.
This commit is contained in:
@@ -56,42 +56,48 @@ static long init_record(aiRecord *prec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long readLocked(struct link *pinp, void *dummy)
|
||||
{
|
||||
aiRecord *prec = (aiRecord *) pinp->precord;
|
||||
struct aivt {
|
||||
double val;
|
||||
long status = dbGetLink(pinp, DBR_DOUBLE, &val, 0, 0);
|
||||
epicsTimeStamp *ptime;
|
||||
};
|
||||
|
||||
if (status) return status;
|
||||
static long readLocked(struct link *pinp, void *vvt)
|
||||
{
|
||||
struct aivt *pvt = (struct aivt *) vvt;
|
||||
long status = dbGetLink(pinp, DBR_DOUBLE, &pvt->val, 0, 0);
|
||||
|
||||
/* Apply smoothing algorithm */
|
||||
if (prec->smoo != 0.0 && prec->dpvt && finite(prec->val))
|
||||
prec->val = val * (1.00 - prec->smoo) + (prec->val * prec->smoo);
|
||||
else
|
||||
prec->val = val;
|
||||
if (!status && pvt->ptime)
|
||||
dbGetTimeStamp(pinp, pvt->ptime);
|
||||
|
||||
prec->udf = FALSE;
|
||||
prec->dpvt = &devAiSoft; /* Any non-zero value */
|
||||
|
||||
if (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime)
|
||||
dbGetTimeStamp(pinp, &prec->time);
|
||||
|
||||
return 0;
|
||||
return status;
|
||||
}
|
||||
|
||||
static long read_ai(aiRecord *prec)
|
||||
{
|
||||
long status;
|
||||
struct aivt vt;
|
||||
|
||||
if (dbLinkIsConstant(&prec->inp))
|
||||
return 2;
|
||||
|
||||
status = dbLinkDoLocked(&prec->inp, readLocked, NULL);
|
||||
if (status == S_db_noLSET)
|
||||
status = readLocked(&prec->inp, NULL);
|
||||
vt.ptime = (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime) ? &prec->time : NULL;
|
||||
|
||||
if (status)
|
||||
status = dbLinkDoLocked(&prec->inp, readLocked, &vt);
|
||||
if (status == S_db_noLSET)
|
||||
status = readLocked(&prec->inp, &vt);
|
||||
|
||||
if (!status) {
|
||||
/* Apply smoothing algorithm */
|
||||
if (prec->smoo != 0.0 && prec->dpvt && finite(prec->val))
|
||||
prec->val = vt.val * (1.0 - prec->smoo) + (prec->val * prec->smoo);
|
||||
else
|
||||
prec->val = vt.val;
|
||||
|
||||
prec->udf = FALSE;
|
||||
prec->dpvt = &devAiSoft; /* Any non-zero value */
|
||||
}
|
||||
else
|
||||
prec->dpvt = NULL;
|
||||
|
||||
return 2;
|
||||
|
||||
@@ -60,14 +60,15 @@ static long init_record(mbbiRecord *prec)
|
||||
static long readLocked(struct link *pinp, void *dummy)
|
||||
{
|
||||
mbbiRecord *prec = (mbbiRecord *) pinp->precord;
|
||||
long status = dbGetLink(pinp, DBR_LONG, &prec->rval, 0, 0);
|
||||
|
||||
if (!dbGetLink(pinp, DBR_LONG, &prec->rval, 0, 0)) {
|
||||
prec->rval &= prec->mask;
|
||||
if (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime)
|
||||
dbGetTimeStamp(pinp, &prec->time);
|
||||
}
|
||||
return 0;
|
||||
if (status) return status;
|
||||
|
||||
if (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime)
|
||||
dbGetTimeStamp(pinp, &prec->time);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static long read_mbbi(mbbiRecord *prec)
|
||||
@@ -77,5 +78,8 @@ static long read_mbbi(mbbiRecord *prec)
|
||||
if (status == S_db_noLSET)
|
||||
status = readLocked(&prec->inp, NULL);
|
||||
|
||||
if (!status)
|
||||
prec->rval &= prec->mask;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ static long init_record(stringinRecord *prec)
|
||||
{
|
||||
if (recGblInitConstantLink(&prec->inp, DBF_STRING, prec->val))
|
||||
prec->udf = FALSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -59,13 +60,12 @@ static long readLocked(struct link *pinp, void *dummy)
|
||||
stringinRecord *prec = (stringinRecord *) pinp->precord;
|
||||
long status = dbGetLink(pinp, DBR_STRING, prec->val, 0, 0);
|
||||
|
||||
if (!status) {
|
||||
if (!dbLinkIsConstant(pinp))
|
||||
prec->udf = FALSE;
|
||||
if (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime)
|
||||
dbGetTimeStamp(pinp, &prec->time);
|
||||
}
|
||||
if (status) return status;
|
||||
|
||||
if (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime)
|
||||
dbGetTimeStamp(pinp, &prec->time);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -76,5 +76,8 @@ static long read_stringin(stringinRecord *prec)
|
||||
if (status == S_db_noLSET)
|
||||
status = readLocked(&prec->inp, NULL);
|
||||
|
||||
if (!status && !dbLinkIsConstant(&prec->inp))
|
||||
prec->udf = FALSE;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -60,29 +60,40 @@ static long init_record(waveformRecord *prec)
|
||||
return status;
|
||||
}
|
||||
|
||||
static long readLocked(struct link *pinp, void *dummy)
|
||||
struct wfrt {
|
||||
long nRequest;
|
||||
epicsTimeStamp *ptime;
|
||||
};
|
||||
|
||||
static long readLocked(struct link *pinp, void *vrt)
|
||||
{
|
||||
waveformRecord *prec = (waveformRecord *) pinp->precord;
|
||||
long nRequest = prec->nelm;
|
||||
long status = dbGetLink(pinp, prec->ftvl, prec->bptr, 0, &nRequest);
|
||||
struct wfrt *prt = (struct wfrt *) vrt;
|
||||
long status = dbGetLink(pinp, prec->ftvl, prec->bptr, 0, &prt->nRequest);
|
||||
|
||||
if (!status && nRequest > 0) {
|
||||
prec->nord = nRequest;
|
||||
prec->udf = FALSE;
|
||||
if (!status && prt->ptime)
|
||||
dbGetTimeStamp(pinp, prt->ptime);
|
||||
|
||||
if (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime)
|
||||
dbGetTimeStamp(pinp, &prec->time);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static long read_wf(waveformRecord *prec)
|
||||
{
|
||||
long status = dbLinkDoLocked(&prec->inp, readLocked, NULL);
|
||||
long status;
|
||||
struct wfrt rt;
|
||||
|
||||
rt.nRequest = prec->nelm;
|
||||
rt.ptime = (dbLinkIsConstant(&prec->tsel) &&
|
||||
prec->tse == epicsTimeEventDeviceTime) ? &prec->time : NULL;
|
||||
|
||||
status = dbLinkDoLocked(&prec->inp, readLocked, &rt);
|
||||
if (status == S_db_noLSET)
|
||||
status = readLocked(&prec->inp, NULL);
|
||||
status = readLocked(&prec->inp, &rt);
|
||||
|
||||
if (!status && rt.nRequest > 0) {
|
||||
prec->nord = rt.nRequest;
|
||||
prec->udf = FALSE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user