From 7256130470eb9cfa59f4cacbf21c487f8034c5ae Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Apr 2008 21:05:59 +0000 Subject: [PATCH] Added ai support; renamed source file. --- src/dev/softDev/devTimestamp.c | 65 ++++++++++++++++++++++++++++++++ src/dev/softDev/devTimestampSI.c | 46 ---------------------- 2 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 src/dev/softDev/devTimestamp.c delete mode 100644 src/dev/softDev/devTimestampSI.c diff --git a/src/dev/softDev/devTimestamp.c b/src/dev/softDev/devTimestamp.c new file mode 100644 index 000000000..573af236d --- /dev/null +++ b/src/dev/softDev/devTimestamp.c @@ -0,0 +1,65 @@ +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* Id$ */ +/* + * Device support for EPICS time stamps + * + * Original Author: Eric Norum + */ + +#include "dbDefs.h" +#include "epicsTime.h" +#include "alarm.h" +#include "devSup.h" +#include "recGbl.h" +#include "epicsExport.h" + +#include "aiRecord.h" +#include "stringinRecord.h" + +static long read_ai(aiRecord *prec) +{ + recGblGetTimeStamp(prec); + prec->val = prec->time.secPastEpoch + (double)prec->time.nsec * 1e-9; + prec->udf = FALSE; + return 2; +} + +struct { + dset common; + DEVSUPFUN read_write; + DEVSUPFUN special_linconv; +} devTimestampAI = { + {6, NULL, NULL, NULL, NULL}, read_ai, NULL +}; +epicsExportAddress(dset, devTimestampAI); + + +static long read_stringin (stringinRecord *prec) +{ + int len; + + recGblGetTimeStamp(prec); + len = epicsTimeToStrftime(prec->val, sizeof prec->val, + prec->inp.value.instio.string, &prec->time); + if (len >= sizeof prec->val) { + prec->udf = TRUE; + recGblSetSevr(prec, UDF_ALARM, INVALID_ALARM); + return -1; + } + prec->udf = FALSE; + return 0; +} + +struct { + dset common; + DEVSUPFUN read_stringin; +} devTimestampSI = { + {5, NULL, NULL, NULL, NULL}, read_stringin +}; +epicsExportAddress(dset, devTimestampSI); diff --git a/src/dev/softDev/devTimestampSI.c b/src/dev/softDev/devTimestampSI.c deleted file mode 100644 index e9f167d4b..000000000 --- a/src/dev/softDev/devTimestampSI.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Stringin device support for EPICS time stamps - * - * $Id$ - */ - -#include -#include -#include -#include -#include -#include -#include - -static long -read_stringin (struct stringinRecord *psi) -{ - int l; - - recGblGetTimeStamp(psi); - l = epicsTimeToStrftime(psi->val, sizeof psi->val, psi->inp.value.instio.string, &psi->time); - if (l >= sizeof psi->val) { - psi->udf = 1; - recGblSetSevr(psi,UDF_ALARM,INVALID_ALARM); - return -1; - } - psi->udf = 0; - return 0; -} - -struct { - long number; - DEVSUPFUN dev_report; - DEVSUPFUN init; - DEVSUPFUN init_record; /*returns: (0,2)=>(success,success no convert)*/ - DEVSUPFUN get_ioint_info; - DEVSUPFUN read_stringin;/*(0)=>(success ) */ -} devTimestampSI = { - 6, - NULL, - NULL, - NULL, - NULL, - read_stringin -}; -epicsExportAddress(dset,devTimestampSI);