05-11-2016 11:31 AM
Hello,
I tried searching for this but I wasn't able to find anything. Can anyone provide the recipe for calculating a time stamp from the time data node? Is it a relative time stamp or is it based on some other epoch?
Thanks,
Bob
05-11-2016 12:04 PM
Looks like it's the value of the millisecond timer when the event occurs.
05-11-2016 12:08 PM
When I tried to use the time conversion functions built into LabVIEW I got a screwy date of 1920s. When I print the value of the time functions, the numeric data is a much larger number than the one I get from the event structure. Is there some sort of setting for the time or epoch?
05-11-2016 12:36 PM
Here's a thread on the topic:
http://forums.ni.com/t5/LabVIEW/millisecond-timer-value/td-p/781796
I don't do much with millisecond timing but the gist I get is that the number itself is rather arbitrary and intended to compare to another millisecond timer reading to determine a specific timeframe.
05-11-2016 12:36 PM
You can not convert that to a timestamp because the base reference time (millisecond zero) is undefined.
If you need a timestamp the put the Get Date Time Now primitive in the event case that needs it.
05-11-2016 12:40 PM
I don't do much with millisecond timing but the gist I get is that the number itself is rather arbitrary and intended to compare to another millisecond timer reading to determine a specific timeframe.
Be careful when you use this in comparisons because the value of the millisecond timer wraps from (2^32)-1 to 0.
05-11-2016 12:43 PM
Thanks for the information. I was beginning to think it might be something like that. It was obvious that I wasn't getting a consistent time stamp conversion and it was updating in large chunks. It will be much easier to use the Get Date Time Now function.
05-11-2016 01:37 PM
How accurate do you need to be?
The timestamp should be generated at the instant the event occurs, but the timestamp is not directly related to the time of day.
The event case may not execute for sometime after the event occurs depending on how responsive your code is. So a Get Time in that case is not going to be the time the event actually occurred.
But if you took another millisecond timer value and a Get Time in the event case and set them up so they occure nearly the same time. You can use the difference between the event's timestamp, and the event case's grab of the time stamp to adjust the Get Time function's returned value.
05-11-2016 02:18 PM
I only need to generate a timestamp that is approximate, it does not have to be very precise. So if it is off even by 1 second, I don't really care, I just need a value to pass to my sub VI.
05-12-2016 01:52 AM
RF gave you the answer -
Note that in many cases, event structures are pretty much always available to respond to events, so the time of the event and the time of handling it will be within the same second. If this isn't the case for you, that means the code taking place inside the event structure takes a long time to execute and that can often mean it shouldn't be there (certainly if the event structure is used for UI handling).
If the event structure isn't used for UI interaction and you're using user-defined events, I would suggest encoding the time information as part of the event data and setting it at the source, rather than relying on the event handling mechanism to get the time.