[sources/ni] Added calculated timestamps based on NI box sampling rate to message format #363
+310
−26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, the NI source sends a batch of datapoints every message, specified by the BULK_READ configuration option, with only one timestamp. This forces the data_processing script to either do weird extrapolation or, in the current implementation, just average the points, reducing the effective sampling rate significantly. This PR adds a new array of relative timestamps to each message, giving each datapoint within the message a distinct timestamp that is computed relatively from the sample rate.
This allows us to expand each message to the actual sample rate rather than aggregating. This also allows it to be more accurate and less jittery than the system timestamp obtained from
time.time()
.To accompany these changes, an minimum viable product of a new data processing script is included to process the messages with the new timestamp list. The new data format is entirely backwards compatible with old tools and will behave identically with the old data_processing script, dashboard, etc. The new data_processing script allows us to take advantage of the increased accuracy and effective polling rate.
The new data_processing script does not have any fancy CLI or UI right now, does not support CAN, and you have to specify the name of the files in the script itself. Improving this is scheduled but out of scope for this PR.
relative_timestamps_nanoseconds
list, expanding processed logs back to the original sample rate of the NI sourcetime.time_ns()
and sample rate for timestamp calculations for better accuracy and no floating point errorThis PR closes #212 .
Developer Testing
Here's what I did to test my changes:
ai.read
will wait until it collects enough messages, guaranteeing the intervalnidaqmx
library should also raise an error in this situation.Reviewer Testing
Here's what you should do to quickly validate my changes:
This change is