diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html
index 47f787c71..0db4e9849 100644
--- a/documentation/RELEASE_NOTES.html
+++ b/documentation/RELEASE_NOTES.html
@@ -11,6 +11,13 @@
Changes between 3.14.11 and 3.14.12
+Record Types aai and aao
+Fixed bug in memory allocation that caused crashes when linking other records
+to aai or aao.
+Fixed bug where NELM was modified instead of NORD.
+Added Soft Channel device support.
+Added SIOL link and proper simulation mode for Soft Channel support.
+Added MPST, APST and HASH fields for monitor on change support like in waveform record.
devLib cleanup
diff --git a/src/dev/softDev/Makefile b/src/dev/softDev/Makefile
index d3a475011..6c4f11cb0 100644
--- a/src/dev/softDev/Makefile
+++ b/src/dev/softDev/Makefile
@@ -12,6 +12,8 @@ include $(TOP)/configure/CONFIG
DBD += devSoft.dbd
+LIBSRCS += devAaiSoft.c
+LIBSRCS += devAaoSoft.c
LIBSRCS += devAiSoft.c
LIBSRCS += devAiSoftRaw.c
LIBSRCS += devAoSoft.c
diff --git a/src/dev/softDev/devAaiSoft.c b/src/dev/softDev/devAaiSoft.c
new file mode 100644
index 000000000..06f62b5d9
--- /dev/null
+++ b/src/dev/softDev/devAaiSoft.c
@@ -0,0 +1,87 @@
+/*************************************************************************\
+* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
+* National Laboratory.
+* Copyright (c) 2002 The Regents of the University of California, as
+* Operator of Los Alamos National Laboratory.
+* EPICS BASE is distributed subject to a Software License Agreement found
+* in file LICENSE that is included with this distribution.
+\*************************************************************************/
+
+/* $Id$
+ * devAaiSoft.c - Device Support Routines for soft Waveform Records
+ *
+ * Original Author: Bob Dalesio
+ * Current Author: Dirk Zimoch
+ * Date: 27-MAY-2010
+ */
+
+#include
+#include
+#include
+
+#include "alarm.h"
+#include "dbDefs.h"
+#include "dbAccess.h"
+#include "recGbl.h"
+#include "devSup.h"
+#include "cantProceed.h"
+#include "menuYesNo.h"
+#include "aaiRecord.h"
+#include "epicsExport.h"
+
+/* Create the dset for devAaiSoft */
+static long init_record();
+static long read_aai();
+
+struct {
+ long number;
+ DEVSUPFUN report;
+ DEVSUPFUN init;
+ DEVSUPFUN init_record;
+ DEVSUPFUN get_ioint_info;
+ DEVSUPFUN read_aai;
+} devAaiSoft = {
+ 5,
+ NULL,
+ NULL,
+ init_record,
+ NULL,
+ read_aai
+};
+epicsExportAddress(dset,devAaiSoft);
+
+static long init_record(aaiRecord *prec)
+{
+ /* INP must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
+ switch (prec->inp.type) {
+ case CONSTANT:
+ prec->nord = 0;
+ break;
+ case PV_LINK:
+ case DB_LINK:
+ case CA_LINK:
+ break;
+ default :
+ recGblRecordError(S_db_badField, (void *)prec,
+ "devAaiSoft (init_record) Illegal INP field");
+ return(S_db_badField);
+ }
+ return 0;
+}
+
+static long read_aai(aaiRecord *prec)
+{
+ long nRequest = prec->nelm;
+
+ dbGetLink(prec->simm == menuYesNoYES ? &prec->siol : &prec->inp,
+ prec->ftvl, prec->bptr, 0, &nRequest);
+ if (nRequest > 0) {
+ prec->nord = nRequest;
+ prec->udf=FALSE;
+ if (prec->tsel.type == CONSTANT &&
+ prec->tse == epicsTimeEventDeviceTime)
+ dbGetTimeStamp(&prec->inp, &prec->time);
+ }
+
+ return 0;
+}
diff --git a/src/dev/softDev/devAaoSoft.c b/src/dev/softDev/devAaoSoft.c
new file mode 100644
index 000000000..7f040d39e
--- /dev/null
+++ b/src/dev/softDev/devAaoSoft.c
@@ -0,0 +1,79 @@
+/*************************************************************************\
+* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
+* National Laboratory.
+* Copyright (c) 2002 The Regents of the University of California, as
+* Operator of Los Alamos National Laboratory.
+* EPICS BASE is distributed subject to a Software License Agreement found
+* in file LICENSE that is included with this distribution.
+\*************************************************************************/
+
+/* $Id$
+ * devAaoSoft.c - Device Support Routines for soft Waveform Records
+ *
+ * Original Author: Bob Dalesio
+ * Current Author: Dirk Zimoch
+ * Date: 27-MAY-2010
+ */
+
+#include
+#include
+#include
+
+#include "alarm.h"
+#include "dbDefs.h"
+#include "dbAccess.h"
+#include "recGbl.h"
+#include "devSup.h"
+#include "cantProceed.h"
+#include "menuYesNo.h"
+#include "aaoRecord.h"
+#include "epicsExport.h"
+
+/* Create the dset for devAaoSoft */
+static long init_record();
+static long write_aao();
+
+struct {
+ long number;
+ DEVSUPFUN report;
+ DEVSUPFUN init;
+ DEVSUPFUN init_record;
+ DEVSUPFUN get_ioint_info;
+ DEVSUPFUN read_aao;
+} devAaoSoft = {
+ 5,
+ NULL,
+ NULL,
+ init_record,
+ NULL,
+ write_aao
+};
+epicsExportAddress(dset,devAaoSoft);
+
+static long init_record(aaoRecord *prec)
+{
+ /* OUT must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
+ switch (prec->out.type) {
+ case CONSTANT:
+ prec->nord = 0;
+ break;
+ case PV_LINK:
+ case DB_LINK:
+ case CA_LINK:
+ break;
+ default :
+ recGblRecordError(S_db_badField, prec,
+ "devAaoSoft (init_record) Illegal OUT field");
+ return(S_db_badField);
+ }
+ return 0;
+}
+
+static long write_aao(aaoRecord *prec)
+{
+ long nRequest = prec->nord;
+ dbPutLink(prec->simm == menuYesNoYES ? &prec->siol : &prec->out,
+ prec->ftvl, prec->bptr, nRequest);
+
+ return 0;
+}
diff --git a/src/dev/softDev/devSoft.dbd b/src/dev/softDev/devSoft.dbd
index 28d235730..763ac47d5 100644
--- a/src/dev/softDev/devSoft.dbd
+++ b/src/dev/softDev/devSoft.dbd
@@ -1,3 +1,5 @@
+device(aai,CONSTANT,devAaiSoft,"Soft Channel")
+device(aao,CONSTANT,devAaoSoft,"Soft Channel")
device(ai,CONSTANT,devAiSoft,"Soft Channel")
device(ao,CONSTANT,devAoSoft,"Soft Channel")
device(bi,CONSTANT,devBiSoft,"Soft Channel")
diff --git a/src/misc/base.dbd b/src/misc/base.dbd
index 03408dbed..b7ea298e6 100644
--- a/src/misc/base.dbd
+++ b/src/misc/base.dbd
@@ -8,6 +8,8 @@ include "menuGlobal.dbd"
include "menuConvert.dbd"
# Record types
+include "aaiRecord.dbd"
+include "aaoRecord.dbd"
include "aiRecord.dbd"
include "aoRecord.dbd"
include "aSubRecord.dbd"
diff --git a/src/rec/aaiRecord.c b/src/rec/aaiRecord.c
index 008a4f3d5..5c88791c4 100644
--- a/src/rec/aaiRecord.c
+++ b/src/rec/aaiRecord.c
@@ -9,7 +9,6 @@
/* recAai.c - Record Support Routines for Array Analog In records */
/*
* Original Author: Dave Barker
- * Date: 10/24/93
*
* C E B A F
*
@@ -18,6 +17,8 @@
*
* Copyright SURA CEBAF 1993.
*
+ * Current Author: Dirk Zimoch
+ * Date: 27-MAY-2010
*/
#include
@@ -28,14 +29,17 @@
#include "dbDefs.h"
#include "epicsPrint.h"
+#include "epicsString.h"
#include "alarm.h"
#include "dbAccess.h"
-#include "dbScan.h"
#include "dbEvent.h"
+#include "dbFldTypes.h"
+#include "dbScan.h"
#include "devSup.h"
#include "errMdef.h"
#include "recSup.h"
#include "recGbl.h"
+#include "cantProceed.h"
#include "menuYesNo.h"
#define GEN_SIZE_OFFSET
#include "aaiRecord.h"
@@ -48,7 +52,7 @@
static long init_record(aaiRecord *, int);
static long process(aaiRecord *);
#define special NULL
-static long get_value(aaiRecord *, struct valueDes *);
+#define get_value NULL
static long cvt_dbaddr(DBADDR *);
static long get_array_info(DBADDR *, long *, long *);
static long put_array_info(DBADDR *, long);
@@ -84,43 +88,67 @@ rset aaiRSET={
epicsExportAddress(rset,aaiRSET);
struct aaidset { /* aai dset */
- long number;
- DEVSUPFUN dev_report;
- DEVSUPFUN init;
- DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
- DEVSUPFUN get_ioint_info;
- DEVSUPFUN read_aai; /*returns: (-1,0)=>(failure,success)*/
+ long number;
+ DEVSUPFUN dev_report;
+ DEVSUPFUN init;
+ DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
+ DEVSUPFUN get_ioint_info;
+ DEVSUPFUN read_aai; /*returns: (-1,0)=>(failure,success)*/
};
static void monitor(aaiRecord *);
static long readValue(aaiRecord *);
-
static long init_record(aaiRecord *prec, int pass)
{
- struct aaidset *pdset;
long status;
+ struct aaidset *pdset = (struct aaidset *)(prec->dset);
- if (pass == 0) {
- if (prec->nelm <= 0) prec->nelm = 1;
- return 0;
- }
- recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm);
/* must have dset defined */
- if (!(pdset = (struct aaidset *)(prec->dset))) {
- recGblRecordError(S_dev_noDSET, (void *)prec, "aai: init_record");
+ if (!pdset) {
+ recGblRecordError(S_dev_noDSET, prec, "aai: init_record");
return S_dev_noDSET;
}
+
+ if (pass == 0) {
+ if (prec->nelm <= 0)
+ prec->nelm = 1;
+ if (prec->ftvl > DBF_ENUM)
+ prec->ftvl = DBF_UCHAR;
+ if (prec->nelm == 1) {
+ prec->nord = 1;
+ } else {
+ prec->nord = 0;
+ }
+
+ /* we must call pdset->init_record in pass 0
+ because it may set prec->bptr which must
+ not change after links are established before pass 1
+ */
+
+ if (pdset->init_record) {
+ /* init_record may set the bptr to point to the data */
+ if ((status = pdset->init_record(prec)))
+ return status;
+ }
+ if (!prec->bptr) {
+ /* device support did not allocate memory so we must do it */
+ prec->bptr = callocMustSucceed(prec->nelm, dbValueSize(prec->ftvl),
+ "aai: buffer calloc failed");
+ }
+ return 0;
+ }
+
+ /* SIML must be a CONSTANT or a PV_LINK or a DB_LINK */
+ if (prec->siml.type == CONSTANT) {
+ recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
+ }
+
/* must have read_aai function defined */
if (pdset->number < 5 || pdset->read_aai == NULL) {
- recGblRecordError(S_dev_missingSup, (void *)prec, "aai: init_record");
+ recGblRecordError(S_dev_missingSup, prec, "aai: init_record");
return S_dev_missingSup;
}
- if (pdset->init_record) {
- /* init_record sets the bptr to point to the data */
- if ((status = pdset->init_record(prec)))
- return status;
- }
return 0;
}
@@ -132,14 +160,11 @@ static long process(aaiRecord *prec)
if (pdset == NULL || pdset->read_aai == NULL) {
prec->pact = TRUE;
- recGblRecordError(S_dev_missingSup, (void *)prec, "read_aai");
+ recGblRecordError(S_dev_missingSup, prec, "read_aai");
return S_dev_missingSup;
}
- if (pact) return 0;
-
status = readValue(prec); /* read the new value */
- /* check if device support set pact */
if (!pact && prec->pact) return 0;
prec->pact = TRUE;
@@ -151,22 +176,14 @@ static long process(aaiRecord *prec)
recGblFwdLink(prec);
prec->pact = FALSE;
- return 0;
-}
-
-static long get_value(aaiRecord *prec, struct valueDes *pvdes)
-{
- pvdes->no_elements = prec->nelm;
- pvdes->pvalue = prec->bptr;
- pvdes->field_type = prec->ftvl;
- return 0;
+ return status;
}
static long cvt_dbaddr(DBADDR *paddr)
{
aaiRecord *prec = (aaiRecord *)paddr->precord;
- paddr->pfield = (void *)(prec->bptr);
+ paddr->pfield = prec->bptr;
paddr->no_elements = prec->nelm;
paddr->field_type = prec->ftvl;
paddr->field_size = dbValueSize(prec->ftvl);
@@ -178,7 +195,7 @@ static long get_array_info(DBADDR *paddr, long *no_elements, long *offset)
{
aaiRecord *prec = (aaiRecord *)paddr->precord;
- *no_elements = prec->nelm;
+ *no_elements = prec->nord;
*offset = 0;
return 0;
}
@@ -187,7 +204,9 @@ static long put_array_info(DBADDR *paddr, long nNew)
{
aaiRecord *prec = (aaiRecord *)paddr->precord;
- prec->nelm = nNew;
+ prec->nord = nNew;
+ if (prec->nord > prec->nelm)
+ prec->nord = prec->nelm;
return 0;
}
@@ -204,7 +223,7 @@ static long get_precision(DBADDR *paddr, long *precision)
aaiRecord *prec = (aaiRecord *)paddr->precord;
*precision = prec->prec;
- if (paddr->pfield == (void *)prec->bptr) return 0;
+ if (paddr->pfield == prec->bptr) return 0;
recGblGetPrec(paddr, precision);
return 0;
}
@@ -213,7 +232,7 @@ static long get_graphic_double(DBADDR *paddr, struct dbr_grDouble *pgd)
{
aaiRecord *prec = (aaiRecord *)paddr->precord;
- if (paddr->pfield == (void *)prec->bptr) {
+ if (paddr->pfield == prec->bptr) {
pgd->upper_disp_limit = prec->hopr;
pgd->lower_disp_limit = prec->lopr;
} else recGblGetGraphicDouble(paddr, pgd);
@@ -224,7 +243,7 @@ static long get_control_double(DBADDR *paddr, struct dbr_ctrlDouble *pcd)
{
aaiRecord *prec = (aaiRecord *)paddr->precord;
- if (paddr->pfield == (void *)prec->bptr) {
+ if (paddr->pfield == prec->bptr) {
pcd->upper_ctrl_limit = prec->hopr;
pcd->lower_ctrl_limit = prec->lopr;
} else recGblGetControlDouble(paddr, pcd);
@@ -234,9 +253,35 @@ static long get_control_double(DBADDR *paddr, struct dbr_ctrlDouble *pcd)
static void monitor(aaiRecord *prec)
{
unsigned short monitor_mask;
+ unsigned int hash = 0;
monitor_mask = recGblResetAlarms(prec);
- monitor_mask |= (DBE_LOG | DBE_VALUE);
+
+ if (prec->mpst == aaiPOST_Always)
+ monitor_mask |= DBE_VALUE;
+ if (prec->apst == aaiPOST_Always)
+ monitor_mask |= DBE_LOG;
+
+ /* Calculate hash if we are interested in OnChange events. */
+ if ((prec->mpst == aaiPOST_OnChange) ||
+ (prec->apst == aaiPOST_OnChange)) {
+ hash = epicsMemHash(prec->bptr,
+ prec->nord * dbValueSize(prec->ftvl), 0);
+
+ /* Only post OnChange values if the hash is different. */
+ if (hash != prec->hash) {
+ if (prec->mpst == aaiPOST_OnChange)
+ monitor_mask |= DBE_VALUE;
+ if (prec->apst == aaiPOST_OnChange)
+ monitor_mask |= DBE_LOG;
+
+ /* Store hash for next process. */
+ prec->hash = hash;
+ /* Post HASH. */
+ db_post_events(prec, &prec->hash, DBE_VALUE);
+ }
+ }
+
if (monitor_mask)
db_post_events(prec, prec->bptr, monitor_mask);
}
@@ -253,21 +298,25 @@ static long readValue(aaiRecord *prec)
status = dbGetLink(&prec->siml, DBR_ENUM, &prec->simm, 0, 0);
if (status)
- return(status);
+ return status;
if (prec->simm == menuYesNoNO){
- /* Call dev support */
- status = pdset->read_aai(prec);
- return status;
+ return pdset->read_aai(prec);
}
+
if (prec->simm == menuYesNoYES){
- /* Simm processing split performed in devSup */
- /* Call dev support */
- status = pdset->read_aai(prec);
- return status;
+ /* Device suport is responsible for buffer
+ which might be read-only so we may not be
+ allowed to call dbGetLink on it.
+ Maybe also device support has an advanced
+ simulation mode.
+ Thus call device now.
+ */
+ recGblSetSevr(prec, SIMM_ALARM, prec->sims);
+ return pdset->read_aai(prec);
}
- status = -1;
- recGblSetSevr(prec, SIMM_ALARM, INVALID_ALARM);
- return status;
+
+ recGblSetSevr(prec, SOFT_ALARM, INVALID_ALARM);
+ return -1;
}
diff --git a/src/rec/aaiRecord.dbd b/src/rec/aaiRecord.dbd
index b7b84f66e..e94fecbac 100644
--- a/src/rec/aaiRecord.dbd
+++ b/src/rec/aaiRecord.dbd
@@ -7,6 +7,10 @@
# and higher are distributed subject to a Software License Agreement found
# in file LICENSE that is included with this distribution.
#*************************************************************************
+menu(aaiPOST) {
+ choice(aaiPOST_Always,"Always")
+ choice(aaiPOST_OnChange,"On Change")
+}
recordtype(aai) {
include "dbCommon.dbd"
field(VAL,DBF_NOACCESS) {
@@ -82,4 +86,25 @@ recordtype(aai) {
interest(2)
menu(menuAlarmSevr)
}
+ field(SIOL,DBF_INLINK) {
+ prompt("Sim Input Specifctn")
+ promptgroup(GUI_INPUTS)
+ interest(1)
+ }
+ field(MPST,DBF_MENU) {
+ prompt("Post Value Monitors")
+ promptgroup(GUI_DISPLAY)
+ interest(1)
+ menu(aaiPOST)
+ }
+ field(APST,DBF_MENU) {
+ prompt("Post Archive Monitors")
+ promptgroup(GUI_DISPLAY)
+ interest(1)
+ menu(aaiPOST)
+ }
+ field(HASH,DBF_ULONG) {
+ prompt("Hash of OnChange data.")
+ interest(3)
+ }
}
diff --git a/src/rec/aaoRecord.c b/src/rec/aaoRecord.c
index 954df058f..695f8e1b1 100644
--- a/src/rec/aaoRecord.c
+++ b/src/rec/aaoRecord.c
@@ -9,7 +9,6 @@
/* recAao.c - Record Support Routines for Array Analog Out records */
/*
* Original Author: Dave Barker
- * Date: 10/28/93
*
* C E B A F
*
@@ -18,6 +17,8 @@
*
* Copyright SURA CEBAF 1993.
*
+ * Current Author: Dirk Zimoch
+ * Date: 27-MAY-2010
*/
#include
@@ -28,14 +29,17 @@
#include "dbDefs.h"
#include "epicsPrint.h"
+#include "epicsString.h"
#include "alarm.h"
#include "dbAccess.h"
+#include "dbEvent.h"
#include "dbFldTypes.h"
#include "dbScan.h"
-#include "dbEvent.h"
#include "devSup.h"
+#include "errMdef.h"
#include "recSup.h"
#include "recGbl.h"
+#include "cantProceed.h"
#include "menuYesNo.h"
#define GEN_SIZE_OFFSET
#include "aaoRecord.h"
@@ -48,7 +52,7 @@
static long init_record(aaoRecord *, int);
static long process(aaoRecord *);
#define special NULL
-static long get_value(aaoRecord *, struct valueDes *);
+#define get_value NULL
static long cvt_dbaddr(DBADDR *);
static long get_array_info(DBADDR *, long *, long *);
static long put_array_info(DBADDR *, long);
@@ -84,43 +88,67 @@ rset aaoRSET={
epicsExportAddress(rset,aaoRSET);
struct aaodset { /* aao dset */
- long number;
- DEVSUPFUN dev_report;
- DEVSUPFUN init;
- DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
- DEVSUPFUN get_ioint_info;
- DEVSUPFUN write_aao; /*returns: (-1,0)=>(failure,success)*/
+ long number;
+ DEVSUPFUN dev_report;
+ DEVSUPFUN init;
+ DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
+ DEVSUPFUN get_ioint_info;
+ DEVSUPFUN write_aao; /*returns: (-1,0)=>(failure,success)*/
};
static void monitor(aaoRecord *);
static long writeValue(aaoRecord *);
-
static long init_record(aaoRecord *prec, int pass)
{
- struct aaodset *pdset;
long status;
+ struct aaodset *pdset = (struct aaodset *)(prec->dset);
- if (pass == 0) {
- if (prec->nelm <= 0) prec->nelm = 1;
- return 0;
- }
- recGblInitConstantLink(&prec->siml, DBF_USHORT, &prec->simm);
/* must have dset defined */
- if (!(pdset = (struct aaodset *)(prec->dset))) {
- recGblRecordError(S_dev_noDSET, (void *)prec, "aao: init_record");
+ if (!pdset) {
+ recGblRecordError(S_dev_noDSET, prec, "aao: init_record");
return S_dev_noDSET;
}
+
+ if (pass == 0) {
+ if (prec->nelm <= 0)
+ prec->nelm = 1;
+ if (prec->ftvl > DBF_ENUM)
+ prec->ftvl = DBF_UCHAR;
+ if (prec->nelm == 1) {
+ prec->nord = 1;
+ } else {
+ prec->nord = 0;
+ }
+
+ /* we must call pdset->init_record in pass 0
+ because it may set prec->bptr which must
+ not change after links are established before pass 1
+ */
+
+ if (pdset->init_record) {
+ /* init_record may set the bptr to point to the data */
+ if ((status = pdset->init_record(prec)))
+ return status;
+ }
+ if (!prec->bptr) {
+ /* device support did not allocate memory so we must do it */
+ prec->bptr = callocMustSucceed(prec->nelm, dbValueSize(prec->ftvl),
+ "aao: buffer calloc failed");
+ }
+ return 0;
+ }
+
+ /* SIML must be a CONSTANT or a PV_LINK or a DB_LINK */
+ if (prec->siml.type == CONSTANT) {
+ recGblInitConstantLink(&prec->siml,DBF_USHORT,&prec->simm);
+ }
+
/* must have write_aao function defined */
if (pdset->number < 5 || pdset->write_aao == NULL) {
- recGblRecordError(S_dev_missingSup, (void *)prec, "aao: init_record");
+ recGblRecordError(S_dev_missingSup, prec, "aao: init_record");
return S_dev_missingSup;
}
- if (pdset->init_record) {
- /* init records sets the bptr to point to the data */
- if ((status = pdset->init_record(prec)))
- return status;
- }
return 0;
}
@@ -132,13 +160,13 @@ static long process(aaoRecord *prec)
if (pdset == NULL || pdset->write_aao == NULL) {
prec->pact = TRUE;
- recGblRecordError(S_dev_missingSup, (void *)prec, "write_aao");
+ recGblRecordError(S_dev_missingSup, prec, "write_aao");
return S_dev_missingSup;
}
- if (pact) return 0;
-
status = writeValue(prec); /* write the data */
+ if (!pact && prec->pact) return 0;
+ prec->pact = TRUE;
prec->udf = FALSE;
recGblGetTimeStamp(prec);
@@ -148,22 +176,14 @@ static long process(aaoRecord *prec)
recGblFwdLink(prec);
prec->pact = FALSE;
- return 0;
-}
-
-static long get_value(aaoRecord *prec, struct valueDes *pvdes)
-{
- pvdes->no_elements = prec->nelm;
- pvdes->pvalue = prec->bptr;
- pvdes->field_type = prec->ftvl;
- return 0;
+ return status;
}
static long cvt_dbaddr(DBADDR *paddr)
{
aaoRecord *prec = (aaoRecord *)paddr->precord;
- paddr->pfield = (void *)(prec->bptr);
+ paddr->pfield = prec->bptr;
paddr->no_elements = prec->nelm;
paddr->field_type = prec->ftvl;
paddr->field_size = dbValueSize(prec->ftvl);
@@ -175,7 +195,7 @@ static long get_array_info(DBADDR *paddr, long *no_elements, long *offset)
{
aaoRecord *prec = (aaoRecord *)paddr->precord;
- *no_elements = prec->nelm;
+ *no_elements = prec->nord;
*offset = 0;
return 0;
}
@@ -184,7 +204,9 @@ static long put_array_info(DBADDR *paddr, long nNew)
{
aaoRecord *prec = (aaoRecord *)paddr->precord;
- prec->nelm = nNew;
+ prec->nord = nNew;
+ if (prec->nord > prec->nelm)
+ prec->nord = prec->nelm;
return 0;
}
@@ -210,7 +232,7 @@ static long get_graphic_double(DBADDR *paddr, struct dbr_grDouble *pgd)
{
aaoRecord *prec = (aaoRecord *)paddr->precord;
- if (paddr->pfield == (void *)prec->bptr) {
+ if (paddr->pfield == prec->bptr) {
pgd->upper_disp_limit = prec->hopr;
pgd->lower_disp_limit = prec->lopr;
} else recGblGetGraphicDouble(paddr,pgd);
@@ -221,7 +243,7 @@ static long get_control_double(DBADDR *paddr, struct dbr_ctrlDouble *pcd)
{
aaoRecord *prec = (aaoRecord *)paddr->precord;
- if(paddr->pfield==(void *)prec->bptr){
+ if(paddr->pfield == prec->bptr){
pcd->upper_ctrl_limit = prec->hopr;
pcd->lower_ctrl_limit = prec->lopr;
} else recGblGetControlDouble(paddr,pcd);
@@ -231,9 +253,35 @@ static long get_control_double(DBADDR *paddr, struct dbr_ctrlDouble *pcd)
static void monitor(aaoRecord *prec)
{
unsigned short monitor_mask;
+ unsigned int hash = 0;
monitor_mask = recGblResetAlarms(prec);
- monitor_mask |= (DBE_LOG | DBE_VALUE);
+
+ if (prec->mpst == aaoPOST_Always)
+ monitor_mask |= DBE_VALUE;
+ if (prec->apst == aaoPOST_Always)
+ monitor_mask |= DBE_LOG;
+
+ /* Calculate hash if we are interested in OnChange events. */
+ if ((prec->mpst == aaoPOST_OnChange) ||
+ (prec->apst == aaoPOST_OnChange)) {
+ hash = epicsMemHash(prec->bptr,
+ prec->nord * dbValueSize(prec->ftvl), 0);
+
+ /* Only post OnChange values if the hash is different. */
+ if (hash != prec->hash) {
+ if (prec->mpst == aaoPOST_OnChange)
+ monitor_mask |= DBE_VALUE;
+ if (prec->apst == aaoPOST_OnChange)
+ monitor_mask |= DBE_LOG;
+
+ /* Store hash for next process. */
+ prec->hash = hash;
+ /* Post HASH. */
+ db_post_events(prec, &prec->hash, DBE_VALUE);
+ }
+ }
+
if (monitor_mask)
db_post_events(prec, prec->bptr, monitor_mask);
}
@@ -253,17 +301,20 @@ static long writeValue(aaoRecord *prec)
return status;
if (prec->simm == menuYesNoNO) {
- /* Call dev support */
- status = pdset->write_aao(prec);
- return status;
+ return pdset->write_aao(prec);
}
if (prec->simm == menuYesNoYES) {
- /* Call dev support */
- status = pdset->write_aao(prec);
- return status;
+ /* Device suport is responsible for buffer
+ which might be write-only so we may not be
+ allowed to call dbPutLink on it.
+ Maybe also device support has an advanced
+ simulation mode.
+ Thus call device now.
+ */
+ recGblSetSevr(prec, SIMM_ALARM, prec->sims);
+ return pdset->write_aao(prec);
}
- status = -1;
- recGblSetSevr(prec, SIMM_ALARM, INVALID_ALARM);
- return status;
+ recGblSetSevr(prec, SOFT_ALARM, INVALID_ALARM);
+ return -1;
}
diff --git a/src/rec/aaoRecord.dbd b/src/rec/aaoRecord.dbd
index 1952f8f5b..60b9b773e 100644
--- a/src/rec/aaoRecord.dbd
+++ b/src/rec/aaoRecord.dbd
@@ -7,6 +7,10 @@
# and higher are distributed subject to a Software License Agreement found
# in file LICENSE that is included with this distribution.
#*************************************************************************
+menu(aaoPOST) {
+ choice(aaoPOST_Always,"Always")
+ choice(aaoPOST_OnChange,"On Change")
+}
recordtype(aao) {
include "dbCommon.dbd"
field(VAL,DBF_NOACCESS) {
@@ -82,4 +86,25 @@ recordtype(aao) {
interest(2)
menu(menuAlarmSevr)
}
+ field(SIOL,DBF_OUTLINK) {
+ prompt("Sim Output Specifctn")
+ promptgroup(GUI_INPUTS)
+ interest(1)
+ }
+ field(MPST,DBF_MENU) {
+ prompt("Post Value Monitors")
+ promptgroup(GUI_DISPLAY)
+ interest(1)
+ menu(aaoPOST)
+ }
+ field(APST,DBF_MENU) {
+ prompt("Post Archive Monitors")
+ promptgroup(GUI_DISPLAY)
+ interest(1)
+ menu(aaoPOST)
+ }
+ field(HASH,DBF_ULONG) {
+ prompt("Hash of OnChange data.")
+ interest(3)
+ }
}