04-24-2019 11:26 AM
Hi,
I read out a time value from a device in form of an array of having 8 bytes:
(104, 250, 124, 127, 195, 250, 212, 1)
I would like to convert this to a human readable format.
In Delphi there is a command converting filetime to systemtime, and I am wondering how can I do it in LabVIEW.
Probably sth similar to this one:
Thanks,
MOJO
04-24-2019 03:29 PM
Your question has no answer. 8 u8 numbers can be manipulated many ways to represent a time, but if you don't know the "rules" (how the originator meant them to be used), it's pretty hopeless.
Two representations:
If you know what your bytes represent (and the correct byte order), you can express it as a Date and Time.
Bob Schor
04-25-2019 02:29 PM - edited 04-25-2019 02:34 PM
Thank you for your answer.
It is your first mentioned option, the windows file creation. A 64bit value in 100 nanoseconds from 1601.
I figured out the solution on my own. I hope it will help all of you.
The value comes out of a sensor/device of Inficon company.
This is how I do the conversion to a timestamp:
i) 8 x 8byte array to hexadecimal string
(104, 250, 124, 127, 195, 250, 212, 1) -> (68, FA, 7C, 7F, C3, FA, D4, 1)
ii) turn values (width 2!)
(68, FA, 7C, 7F, C3, FA, D4, 1) -> (01, D4, FA, C3, 7F, 7C, FA, 68)
iii) use hex string to number to get the filetime
(01, D4, FA, C3, 7F, 7C, FA, 68) -> 132006006665050728
Filetime to seconds from 1904 for further LabVIEW processing is described by TBD, see his post here:
https://forums.ni.com/t5/LabVIEW/convert-64bit-UTC-time-since-1-jan-1601-to-current-time-labview
Regards,
MOJO
04-25-2019 03:26 PM - edited 04-25-2019 03:28 PM
@MOJO_FZJ wrote:
Thank you for your answer.
It is your first mentioned option, the windows file creation. A 64bit value in 100 nanoseconds from 1601.
I figured out the solution on my own. I hope it will help all of you.
The value comes out of a sensor/device of Inficon company.
This is how I do the conversion to a timestamp:
i) 8 x 8byte array to hexadecimal string
(104, 250, 124, 127, 195, 250, 212, 1) -> (68, FA, 7C, 7F, C3, FA, D4, 1)
ii) turn values (width 2!)
(68, FA, 7C, 7F, C3, FA, D4, 1) -> (01, D4, FA, C3, 7F, 7C, FA, 68)
iii) use hex string to number to get the filetime
(01, D4, FA, C3, 7F, 7C, FA, 68) -> 132006006665050728
Filetime to seconds from 1904 for further LabVIEW processing is described by TBD, see his post here:
https://forums.ni.com/t5/LabVIEW/convert-64bit-UTC-time-since-1-jan-1601-to-current-time-labview
Regards,
MOJO
Good find, but no need to convert to hex string. Just use Reverse 1D Array, and Byte Array to String, then use the functions from that link
04-26-2019 04:10 AM
04-26-2019 05:26 AM
Great, thank you GerdW! KUDO!
UnflattenFrom Stringis a bit magic to me, but your code is much more elegant than my solution with number/string conversion functions.