Added ai support; renamed source file.

This commit is contained in:
Andrew Johnson
2008-04-25 21:05:59 +00:00
parent 81a56a5b9e
commit 7256130470
2 changed files with 65 additions and 46 deletions
+65
View File
@@ -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);
-46
View File
@@ -1,46 +0,0 @@
/*
* Stringin device support for EPICS time stamps
*
* $Id$
*/
#include <stdio.h>
#include <epicsTime.h>
#include <stringinRecord.h>
#include <alarm.h>
#include <devSup.h>
#include <recGbl.h>
#include <epicsExport.h>
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);