diff --git a/src/std/dev/Makefile b/src/std/dev/Makefile index a118f7057..79eb6cb0c 100644 --- a/src/std/dev/Makefile +++ b/src/std/dev/Makefile @@ -21,8 +21,10 @@ dbRecStd_SRCS += devAoSoft.c dbRecStd_SRCS += devAoSoftRaw.c dbRecStd_SRCS += devBiSoft.c dbRecStd_SRCS += devBiSoftRaw.c +dbRecStd_SRCS += devBiDbState.c dbRecStd_SRCS += devBoSoft.c dbRecStd_SRCS += devBoSoftRaw.c +dbRecStd_SRCS += devBoDbState.c dbRecStd_SRCS += devCalcoutSoft.c dbRecStd_SRCS += devEventSoft.c dbRecStd_SRCS += devHistogramSoft.c diff --git a/src/std/dev/devBiDbState.c b/src/std/dev/devBiDbState.c new file mode 100644 index 000000000..54d929373 --- /dev/null +++ b/src/std/dev/devBiDbState.c @@ -0,0 +1,92 @@ +/*************************************************************************\ +* Copyright (c) 2010 Brookhaven National Laboratory. +* Copyright (c) 2010 Helmholtz-Zentrum Berlin +* fuer Materialien und Energie GmbH. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: Ralph Lange + */ + +#include "errlog.h" +#include "dbState.h" +#include "devSup.h" +#include "recGbl.h" +#include "dbLink.h" +#include "dbAccessDefs.h" +#include "epicsExport.h" +#include "biRecord.h" + +#define DEVSUPNAME "devBiDbState" + +static long add_record (struct dbCommon *pdbc) +{ + biRecord *prec = (biRecord *) pdbc; + + if (INST_IO != prec->inp.type) { + recGblRecordError(S_db_badField, (void *) prec, DEVSUPNAME ": Illegal INP field"); + return(S_db_badField); + } + + if (!(prec->dpvt = dbStateFind(prec->inp.value.instio.string)) && + prec->inp.value.instio.string && + '\0' != *prec->inp.value.instio.string) { + errlogSevPrintf(errlogInfo, DEVSUPNAME ": Creating new db state '%s'\n", + prec->inp.value.instio.string); + prec->dpvt = dbStateCreate(prec->inp.value.instio.string); + } + return 0; +} + +static long del_record (struct dbCommon *pdbc) +{ + biRecord *prec = (biRecord *) pdbc; + prec->dpvt = NULL; + return 0; +} + +static struct dsxt myDsxt = { + add_record, + del_record +}; + +static long init(int pass) +{ + if (pass == 0) + devExtend(&myDsxt); + return 0; +} + +static long read_bi(biRecord *prec) +{ + if (prec->dpvt) { + prec->val = dbStateGet(prec->dpvt); + prec->udf = FALSE; + } + + if (prec->tsel.type == CONSTANT && + prec->tse == epicsTimeEventDeviceTime) + dbGetTimeStamp(&prec->inp, &prec->time); + + return 2; +} + +static struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_bi; +} devBiDbState = { + 5, + NULL, + init, + NULL, + NULL, + read_bi +}; + +epicsExportAddress(dset, devBiDbState); diff --git a/src/std/dev/devBoDbState.c b/src/std/dev/devBoDbState.c new file mode 100644 index 000000000..b2e8c493f --- /dev/null +++ b/src/std/dev/devBoDbState.c @@ -0,0 +1,86 @@ +/*************************************************************************\ +* Copyright (c) 2010 Brookhaven National Laboratory. +* Copyright (c) 2010 Helmholtz-Zentrum Berlin +* fuer Materialien und Energie GmbH. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: Ralph Lange + */ + +#include "errlog.h" +#include "dbState.h" +#include "devSup.h" +#include "recGbl.h" +#include "dbAccessDefs.h" +#include "epicsExport.h" +#include "boRecord.h" + +#define DEVSUPNAME "devBoDbState" + +static long add_record (struct dbCommon *pdbc) +{ + boRecord *prec = (boRecord *) pdbc; + + if (INST_IO != prec->out.type) { + recGblRecordError(S_db_badField, (void *) prec, DEVSUPNAME ": Illegal OUT field"); + return(S_db_badField); + } + + if (!(prec->dpvt = dbStateFind(prec->out.value.instio.string)) && + prec->out.value.instio.string && + '\0' != *prec->out.value.instio.string) { + errlogSevPrintf(errlogInfo, DEVSUPNAME ": Creating new db state '%s'\n", + prec->out.value.instio.string); + prec->dpvt = dbStateCreate(prec->out.value.instio.string); + } + return 0; +} + +static long del_record (struct dbCommon *pdbc) +{ + boRecord *prec = (boRecord *) pdbc; + prec->dpvt = NULL; + return 0; +} + +static struct dsxt myDsxt = { + add_record, + del_record +}; + +static long init(int pass) +{ + if (pass == 0) + devExtend(&myDsxt); + return 0; +} + +static long write_bo(boRecord *prec) +{ + if (prec->val) + dbStateSet(prec->dpvt); + else + dbStateClear(prec->dpvt); + return 0; +} + +static struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_bo; +} devBoDbState = { + 5, + NULL, + init, + NULL, + NULL, + write_bo +}; + +epicsExportAddress(dset, devBoDbState); diff --git a/src/std/dev/devSoft.dbd b/src/std/dev/devSoft.dbd index 5f90aba86..8178bfef1 100644 --- a/src/std/dev/devSoft.dbd +++ b/src/std/dev/devSoft.dbd @@ -44,3 +44,6 @@ device(longin, INST_IO,devLiGeneralTime,"General Time") device(stringin,INST_IO,devSiGeneralTime,"General Time") device(stringout,INST_IO,devSoStdio,"stdio") + +device(bi, INST_IO, devBiDbState, "Db State") +device(bo, INST_IO, devBoDbState, "Db State")