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: "Nariyoshi, Pedro via Tech-talk" <tech-talk at aps.anl.gov>
To: Andrew Johnson <anj at anl.gov>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Mon, 28 Nov 2022 16:52:35 +0000

Thank you for the detailed asnwer, Andrew, it has been very helpful.

I'll get working at it.


Pedro Nariyoshi

Software Controls Engineer

Facility for Rare Isotope Beams

Michigan State University

640 South Shaw Lane

East Lansing, MI 48824, USA

Tel. 517-908-7352

Email: nariyosh at frib.msu.edu

1633986722804





From: Andrew Johnson <anj at anl.gov>
Sent: Wednesday, November 23, 2022 2:48 PM
To: Nariyoshi, Pedro; tech-talk at aps.anl.gov
Subject: Re: Convert ai record into timestamp
 
[EXTERNAL] This email originated from outside of FRIB

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.

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

Navigate by Date:
Prev: Re: Illegal field value PV: oms:m1 motor_init_record_com(): card does not exist! motorOMS st.cmd error Kevin Peterson via Tech-talk
Next: Re: Problem downloading from sequenzer repo Andrew Johnson 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: Re: Convert ai record into timestamp Andrew Johnson via Tech-talk
Next: CSS Phoebus - Making certain points "invisible" on the plot Wang, Andrew 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 ·