New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interpretation of Time and FineTime values should be specified #10
Comments
Do you have a suggestion of how to fix this Stefan? I am guessing this may not have an impact in the API code itself but more in the Magenta Book? |
Yes, this should not affect the API code, only the specification in the Magenta Book. I suggest to specify an epoch (e.g. CCSDS epoch 1958-01-01T00:00:00), a time scale in which the epoch is given (e.g. TAI), a time scale in which the time value is given (e.g. TAI or UTC) and a time unit (e.g. seconds) for Please note that the popular |
So we could specify Java epoch, in UTC, UTC as a time scale and milliseconds as the unit (for Time). And that would be ok? But we should put a note in about the inherent problem with the Java time functions? I want this to be as Java normal as possible but still correct. |
This sounds like a good solution to me. |
Following the proposed solution for Time, the MAL type FineTime can also be defined as: Future implementations must take this RID into consideration when using Time or FineTime. |
I suggest the MAL Java API to unambiguously define the interpretation of Time and FineTime values. Time and FineTime are stored as simple integer or long values at the moment, their interpretation is up to the user of the MAL Java API. However, different components might employ different interpretations, making it error-prone and tedious to use them together.
For example: The ESA MAL implementation assigns
new Date().getTime()
to a newly generated MAL message timestamp. This time value needs to be interpreted in the framework of the UTC scale (i.e. with leap second correction) counting from the Java epoch1970-01-01T00:00:00 UTC
. The DLR implementation of the MAL/SPP binding counts from the same epoch, but using TAI time scale. This means there is a difference of 27 seconds between those two interpretations of the same value for today. One interpretation counts the apparent elapsed milliseconds since the Java epoch, the other the real elapsed seconds.To elaborate more on that, I even think handling time values the way Java usually tends to handle them (apparent elapsed milliseconds since the Java epoch) is not compliant with the MAL Blue Book. The book states that Time represents an absolute time (4.3.16). Java time values are ambiguous, however: There are time stamps that cannot be displayed as the correct absolute time string. Take the time value
94694399000
for example. It is not possible to tell if I meant to express1972-12-31T23:59:59.000
or1972-12-31T23:59:60.000
with this value. So even when not employing two different interpretations of a time value it is easy to handle them in a non-MAL-compliant way.It is difficult to get time values and their interpretation right. Often there are implicit assumptions that are not communicated between users of different components, giving rise to subtle bugs. In order to prevent these issues in the first place, I suggest the interpretation of time values to be specified.
The text was updated successfully, but these errors were encountered: