Add simple device support for converting time to nicely-formatted string.
This commit is contained in:
@@ -47,6 +47,8 @@ LIBSRCS += devMbboSoftCallback.c
|
||||
LIBSRCS += devMbboDirectSoftCallback.c
|
||||
LIBSRCS += devSoSoftCallback.c
|
||||
|
||||
LIBSRCS += devTimestampSI.c
|
||||
|
||||
LIBRARY_IOC += softDevIoc
|
||||
softDevIoc_LIBS += recIoc asIoc dbIoc registryIoc dbStaticIoc ca Com
|
||||
softDevIoc_RCS_WIN32 = softDevIoc.rc
|
||||
|
||||
@@ -32,3 +32,4 @@ device(mbbo,CONSTANT,devMbboSoftCallback,"Async Soft Channel")
|
||||
device(mbboDirect,CONSTANT,devMbboDirectSoftCallback,"Async Soft Channel")
|
||||
device(stringout,CONSTANT,devSoSoftCallback,"Async Soft Channel")
|
||||
|
||||
device(stringin,INST_IO,devTimestampSI,"Soft Timestamp")
|
||||
|
||||
46
src/dev/softDev/devTimestampSI.c
Normal file
46
src/dev/softDev/devTimestampSI.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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);
|
||||
Reference in New Issue
Block a user