Change the timestamp of PV
Closed this issue · 7 comments
Can I change the PV timestamp to an arbitrary value before PV update is posted?
I'm trying to use pscapy as a softIOC proxy between real IOCs with MRF EVR timestamped PVs and other CA clients. In this scenario I would like to keep the source PV timestamp and slap it onto pcaspy PV.
Not in the public API. The timestamp is updated each time setParam
is called. But you can update it after setParam
and before updatePVs
.
self.pvDB[reason].time = my_new_time
my_new_time
can be manipulated
>>> ts = pcaspy.cas.epicsTimeStamp()
>>> ts.secPastEpoch
905179260
>>> ts.secPastEpoch = 905179220
Thanks for the help.
I overloaded the setParam(self, reason, value)
and added this code to the reason of interest:
ts = epicsTimeStamp()
ts.secPastEpoch = 905179220
ts.nsec = 0
self.pvDB[reason].time = ts
I need to do the exact same thing for exactly the same reason (bridge from epics -> older stuff). It would be nice if this was more official, not hackish as it is.
I have in mind adding such an API setParamTimestamp(reason, timestamp)
in analog to setParamStatus
. But I couldn't decide on two things, so I left it out.
- timestamp takes epicsTimeStamp instance or a double number as returned from
time.time()
? - What is the epoch time used? time.time() is surely using UNIX epoch January 1, 1970 . epicsTimeStamp as returned from epics library uses EPICS epoch January 1, 1990. This is important because this input has to be converted to EPICS epoch if it is not.
I would like to hear your opinions on this.
How about allowing both, epicsTimeStamp and time.time() double, as arguments? The serParamTimestamp method would check for the type and assume epoch accordingly, depending on the timestamp data type.
I'm fine either way, as long as it's documented. It s/b easy to switch from time.time() -> epicsTimeStamp.
With the 0.8 release the pcaspy.Driver.setParam
takes a keyword argument timestamp
. It should be of pcaspy.cas.epicsTimeStamp
type.
And there are helper methods fromPosixTimeStamp
to convert from a POSIX timestamp.