Forum Home › Forums › Uncategorized Issues › datetime storage format in .DAT
- This topic has 2 replies, 2 voices, and was last updated 8 years, 3 months ago by
gianguido.
-
AuthorPosts
-
August 11, 2017 at 5:25 pm #2480
gianguido
ParticipantDear all!
I would like to use RapidSCADA as a “pure” Linux/Ubuntu installation, that is, without need of any Microsoft products or solutions at all, either runtime or for development. For that reason I am currently developing a Python interface to edit the data tables directly. All aspects are so far clear, with the exception of the datetime storage format.
For example, in ctrlcnl.dat the following timestamps (8 Bytes) can be extracted from different records:
[174] [143] [156] [225] [157] [213] [228] [64]
[53] [227] [189] [225] [157] [213] [228] [64]
[217] [244] [220] [225] [157] [213] [228] [64](all data in decimal representation 0-255)
My guess so far is that datetime must be in a 8-Byte format, probably with 4 Bytes for time with milliseconds and 4 Bytes for the date. The actual date is probably 21-11-2016 (as of the published examples) or near it and be represented by the sequence [157] [213] [228] [64]. I tried different codings (SQL, Unix, etc.) and algorithms, but I am not able to make sense out of it. Can you please tell the procedure to transform the given Byte sequence in a formatted day/time and back? An overall algorithm to YYYY, MM, DD, HH, MM, SS as integer would be perfect(!), the presentation strings can be easily built from them. Thank you!
August 12, 2017 at 10:57 am #2484
MikhailModeratorAugust 12, 2017 at 4:47 pm #2486gianguido
ParticipantThank you, Mikhail!
on the basis of your suggestions the following procedure with Python works.
1. read the 8-Byte sequence
2. use ‘struct.unpack’ to convert the binary string to double-precision float
3. build a datetime.timedelta object
4. add to datetime (1899,12,30)
5. format the output string as wished with strftime()the datetime.timedelta function operates on the date and the time concurrently, no need to treat their values separately.
-
AuthorPosts
- You must be logged in to reply to this topic.