EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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  <20222023  2024  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  <20222023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Convert ai record into timestamp
From: Andrew Johnson via Tech-talk <tech-talk at aps.anl.gov>
To: "Nariyoshi, Pedro" <nariyosh at frib.msu.edu>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Wed, 23 Nov 2022 13:48:35 -0600
Hi Pedro,

On 11/21/22 9:55 AM, Nariyoshi, Pedro via Tech-talk wrote:
I am working on a PV that once enabled gets automatically disabled after a certain time (e.g., 24 hours). I have set up a calcout that takes the ai soft timestamps and compares with the current POSIX time (and the timeout value) and automatically turns off the PV. This part is working fine, but I am having trouble to have the expiry time  (timestamp+timeout) be shown in a screen using the stringin soft timestamp. Seems like the TSEL field only accepts the TIME field of a PV, but not VAL, so I couldn't figure  out if there's just no simple way to achieve that or if I'm just missing something  obvious.
Pointing TSEL to anything other than a .TIME field implies the timestamp value should be fetched from an event system, with that TSEL link giving the event number that should be used to get the event timestamp. That isn't what you want to do, so it doesn't help you.

Currently I think the only way that you want is probably with a subroutine record subroutine (or an aSub subroutine, but I would use the simpler sub record myself). A double time_t value has less precision than an epicsTimeStamp, which is probably why we don't provide any device support for doing that kind of thing.

You might want to consider implementing all of your time calculations and even the string conversion inside a sub record C subroutine. It can call
dbGetTimestamp(&prec->inpa, &stamp)
to read the EPICS timestamp from the record pointed to by the INPA link say (don't point it to the .TIME field though), and you can use the record's DESC field to hold the output string that you convert using
epicsTimeToStrftime(&prec->desc, sizeof prec->desc, format, &stamp);
and then post that update with
db_post_events(prec, &prec->desc, DBE_VALUE|DBE_LOG);
You could also set the VAL field and/or any otherwise unused double A though L field for other outputs from the subroutine.

HTH,

- Andrew
-- 
Complexity comes for free, Simplicity you have to work for.

Replies:
Re: Convert ai record into timestamp Nariyoshi, Pedro via Tech-talk
References:
Convert ai record into timestamp Nariyoshi, Pedro via Tech-talk

Navigate by Date:
Prev: Re: Multiple pointers to /usr/lib/epics Michael Davidsaver via Tech-talk
Next: Illegal field value PV: oms:m1 motor_init_record_com(): card does not exist! motorOMS st.cmd error whitetiger1123 via Tech-talk
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  <20222023  2024 
Navigate by Thread:
Prev: Convert ai record into timestamp Nariyoshi, Pedro via Tech-talk
Next: Re: Convert ai record into timestamp Nariyoshi, Pedro via Tech-talk
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  <20222023  2024 
ANJ, 28 Nov 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·