[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.