Experimental Physics and Industrial Control System
Hi Ralph,
Ralph Lange wrote:
As the VxWorks strftime() does not support "%s" (seconds since the
epoch), is there another reasonable way to get this number from the
timestamp of a record into the value field of the same (or another) record?
Interesting question; I can't think of any _reasonable_ ways that don't
involve writing some C code -- there is an unreasonable way to do it
without coding, but it would be quite a sight to see!
The simplest way is to use a subroutine record, the TSEL link of the
record should point to the TIME field of the record whose timestamp you
want to know. The subroutine code is just:
void timeSubroutine(subRecord *prec) {
recGblGetTimeStamp(prec);
prec->val = prec->time.secPastEpoch;
}
If you want the full nanosecond accuracy, or need to adjust the epoch
you could use some variant of this code:
void timeSubroutine(subRecord *prec) {
epicsTimeStamp epoch = {0, 0}; /* Jeff won't like this! */
recGblGetTimeStamp(prec);
prec->val = epicsTimeDiffInSeconds(&prec->time, &epoch);
}
Of course you could also do this within an ai device support instead,
but the subroutine record code can be used in as many record instances
as you need.
- Andrew
--
The right to be heard does not automatically include
the right to be taken seriously. -- Hubert H. Humphrey
- References:
- Accessing Date and Time information David Dudley
- Re: Accessing Date and Time information Andrew Johnson
- Re: Accessing Date and Time information Ralph Lange
- Navigate by Date:
- Prev:
Re: problem using streams with asyn for Agilent E5810A Ethernet->GPIB Rodney R. Porter
- Next:
Re: problem using streams with asyn for Agilent E5810A Ethernet->GPIB Dirk Zimoch
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
<2007>
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
- Navigate by Thread:
- Prev:
Re: Accessing Date and Time information Ralph Lange
- Next:
date format Graham Waters
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
<2007>
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025