Adjust record and device support for array constants

This commit is contained in:
Andrew Johnson
2016-08-10 12:53:39 -05:00
parent 519208833f
commit fb785e45c7
5 changed files with 25 additions and 15 deletions

View File

@@ -52,8 +52,11 @@ epicsExportAddress(dset,devAaiSoft);
static long init_record(aaiRecord *prec)
{
long nRequest = prec->nelm;
if (prec->inp.type == CONSTANT) {
prec->nord = 0;
dbLoadLinkArray(&prec->inp, prec->ftvl, prec->bptr, &nRequest);
prec->nord = (nRequest > 0) ? nRequest : 0;
}
return 0;
}

View File

@@ -49,22 +49,23 @@ epicsExportAddress(dset, devWfSoft);
static long init_record(waveformRecord *prec)
{
if (prec->inp.type == CONSTANT) {
prec->nord = 0;
}
return 0;
long nelm = prec->nelm;
long status = dbLoadLinkArray(&prec->inp, prec->ftvl, prec->bptr, &nelm);
prec->nord = !status && (nelm > 0) ? nelm : 0;
return status;
}
static long read_wf(waveformRecord *prec)
{
long nRequest = prec->nelm;
long status = dbGetLink(&prec->inp, prec->ftvl, prec->bptr, 0, &nRequest);
dbGetLink(&prec->inp, prec->ftvl, prec->bptr, 0, &nRequest);
if (nRequest > 0) {
if (!status && nRequest > 0) {
prec->nord = nRequest;
if (prec->tsel.type == CONSTANT &&
prec->tse == epicsTimeEventDeviceTime)
dbGetTimeStamp(&prec->inp, &prec->time);
}
return 0;
return status;
}

View File

@@ -130,8 +130,12 @@ static long init_record(aSubRecord *prec, int pass)
struct link *plink = &(&prec->inpa)[i];
if (plink->type == CONSTANT) {
if ((&prec->noa)[i] < 2)
recGblInitConstantLink(plink, (&prec->fta)[i], (&prec->a)[i]);
short dbr = (&prec->fta)[i];
long n = (&prec->noa)[i];
dbLoadLinkArray(plink, dbr, (&prec->a)[i], &n);
if (n > 0)
(&prec->nea)[i] = n;
}
}

View File

@@ -8,6 +8,7 @@
#include <string.h>
#include "dbAccess.h"
#include "dbTest.h"
#include "dbUnitTest.h"
#include "errlog.h"
@@ -45,16 +46,16 @@ static void testGetPutArray(void)
testAbort("Failed to find record wfrec");
memcpy(&save, &addr, sizeof(save));
testDiag("Fetch initial value");
testDiag("Fetch initial value of %s", prec->name);
dbScanLock(addr.precord);
testOk1(prec->nord==0);
testOk(prec->nord==3, "prec->nord==3 (got %d)", prec->nord);
nreq = NELEMENTS(data);
if(dbGet(&addr, DBF_DOUBLE, &data, NULL, &nreq, NULL))
testFail("dbGet fails");
else {
testOk(nreq==0, "nreq==0 (got %ld)", nreq);
testOk(nreq==3, "nreq==3 (got %ld)", nreq);
}
dbScanUnlock(addr.precord);
@@ -101,10 +102,10 @@ static void testGetPutArray(void)
testAbort("Failed to find record wfrec1");
memcpy(&save, &addr, sizeof(save));
testDiag("Fetch initial value");
testDiag("Fetch initial value of %s", prec->name);
dbScanLock(addr.precord);
testOk1(prec->nord==0);
testOk(prec->nord==0, "prec->nord==0 (got %d)", prec->nord);
nreq = NELEMENTS(data);
if(dbGet(&addr, DBF_DOUBLE, &data, NULL, &nreq, NULL))

View File

@@ -1,6 +1,7 @@
record(waveform, "wfrec") {
field(NELM, "10")
field(FTVL, "LONG")
field(INP, [1, 2, 3])
}
record(waveform, "wfrec1") {
field(NELM, "1")