Subject: |
[Merge] lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base |
From: |
Dirk Zimoch <[email protected]> |
To: |
[email protected] |
Date: |
Thu, 27 May 2010 15:25:46 -0000 |
Dirk Zimoch has proposed merging lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base.
Requested reviews:
EPICS Core Developers (epics-core)
* Bugfix: writing to aai/aao via db link crashed ioc. Memory allocation / device support init_record moved to pass 0.
* Soft device support for aai and aao added.
* Simulation mode fixed. SIOL link added. (sim handling is done in devsup!)
* Bugfix: writing to aai/aao modified NELM. Modify NORD instead.
* Hashing added to minimize monitor updates (like in waveform record)
Discussion:
Add features like RVAL->VAL conversion, scaling, smoothing, alarm limits?
--
https://code.launchpad.net/~dirk.zimoch/epics-base/fix-aai-and-aao/+merge/26193
Your team EPICS Core Developers is requested to review the proposed merge of lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base.
=== modified file 'src/dev/softDev/Makefile'
--- src/dev/softDev/Makefile 2008-09-24 22:40:37 +0000
+++ src/dev/softDev/Makefile 2010-05-27 15:25:46 +0000
@@ -12,6 +12,8 @@
DBD += devSoft.dbd
+LIBSRCS += devAaiSoft.c
+LIBSRCS += devAaoSoft.c
LIBSRCS += devAiSoft.c
LIBSRCS += devAiSoftRaw.c
LIBSRCS += devAoSoft.c
=== added file 'src/dev/softDev/devAaiSoft.c'
--- src/dev/softDev/devAaiSoft.c 1970-01-01 00:00:00 +0000
+++ src/dev/softDev/devAaiSoft.c 2010-05-27 15:25:46 +0000
@@ -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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#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;
+}
=== added file 'src/dev/softDev/devAaoSoft.c'
--- src/dev/softDev/devAaoSoft.c 1970-01-01 00:00:00 +0000
+++ src/dev/softDev/devAaoSoft.c 2010-05-27 15:25:46 +0000
@@ -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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#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;
+}
=== modified file 'src/dev/softDev/devSoft.dbd'
--- src/dev/softDev/devSoft.dbd 2008-09-24 22:40:37 +0000
+++ src/dev/softDev/devSoft.dbd 2010-05-27 15:25:46 +0000
@@ -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")
=== modified file 'src/misc/base.dbd'
--- src/misc/base.dbd 2008-08-14 20:41:05 +0000
+++ src/misc/base.dbd 2010-05-27 15:25:46 +0000
@@ -8,6 +8,8 @@
include "menuConvert.dbd"
# Record types
+include "aaiRecord.dbd"
+include "aaoRecord.dbd"
include "aiRecord.dbd"
include "aoRecord.dbd"
include "aSubRecord.dbd"
=== modified file 'src/rec/aaiRecord.c'
--- src/rec/aaiRecord.c 2009-07-08 18:14:11 +0000
+++ src/rec/aaiRecord.c 2010-05-27 15:25:46 +0000
@@ -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 <[email protected]>
+ * Date: 27-MAY-2010
*/
#include <stddef.h>
@@ -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 "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 @@
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);
+ /* must have dset defined */
+ 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->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;
}
- 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");
- return S_dev_noDSET;
+
+ /* 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,13 @@
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 +178,14 @@
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 +197,7 @@
{
aaiRecord *prec = (aaiRecord *)paddr->precord;
- *no_elements = prec->nelm;
+ *no_elements = prec->nord;
*offset = 0;
return 0;
}
@@ -187,7 +206,9 @@
{
aaiRecord *prec = (aaiRecord *)paddr->precord;
- prec->nelm = nNew;
+ prec->nord = nNew;
+ if (prec->nord > prec->nelm)
+ prec->nord = prec->nelm;
return 0;
}
@@ -204,7 +225,7 @@
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 +234,7 @@
{
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 +245,7 @@
{
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 +255,35 @@
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 +300,25 @@
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;
}
=== modified file 'src/rec/aaiRecord.dbd'
--- src/rec/aaiRecord.dbd 2002-07-12 21:35:43 +0000
+++ src/rec/aaiRecord.dbd 2010-05-27 15:25:46 +0000
@@ -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 @@
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)
+ }
}
=== modified file 'src/rec/aaoRecord.c'
--- src/rec/aaoRecord.c 2009-07-08 18:14:11 +0000
+++ src/rec/aaoRecord.c 2010-05-27 15:25:46 +0000
@@ -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 <[email protected]>
+ * Date: 27-MAY-2010
*/
#include <stddef.h>
@@ -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 @@
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,15 @@
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 +178,15 @@
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);
+ printf("cvt_dbaddr\n");
+ paddr->pfield = prec->bptr;
paddr->no_elements = prec->nelm;
paddr->field_type = prec->ftvl;
paddr->field_size = dbValueSize(prec->ftvl);
@@ -175,7 +198,8 @@
{
aaoRecord *prec = (aaoRecord *)paddr->precord;
- *no_elements = prec->nelm;
+ printf("get_array_info\n");
+ *no_elements = prec->nord;
*offset = 0;
return 0;
}
@@ -184,7 +208,10 @@
{
aaoRecord *prec = (aaoRecord *)paddr->precord;
- prec->nelm = nNew;
+ printf("put_array_info\n");
+ prec->nord = nNew;
+ if (prec->nord > prec->nelm)
+ prec->nord = prec->nelm;
return 0;
}
@@ -210,7 +237,7 @@
{
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 +248,7 @@
{
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 +258,35 @@
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 +306,20 @@
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, INVALID_ALARM);
+ return pdset->write_aao(prec);
}
- status = -1;
- recGblSetSevr(prec, SIMM_ALARM, INVALID_ALARM);
- return status;
+ recGblSetSevr(prec, SOFT_ALARM, INVALID_ALARM);
+ return -1;
}
=== modified file 'src/rec/aaoRecord.dbd'
--- src/rec/aaoRecord.dbd 2002-07-12 21:35:43 +0000
+++ src/rec/aaoRecord.dbd 2010-05-27 15:25:46 +0000
@@ -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 @@
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)
+ }
}
- Replies:
- [Merge] lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base Dirk Zimoch
- Re: [Merge] lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base Ralph Lange
- Navigate by Date:
- Prev:
[Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch
- Next:
[Merge] lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base Dirk Zimoch
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
[Merge] lp:~dirk.zimoch/epics-base/named-soft-events into lp:epics-base Dirk Zimoch
- Next:
[Merge] lp:~dirk.zimoch/epics-base/fix-aai-and-aao into lp:epics-base Dirk Zimoch
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
<2010>
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|