Repository navigation
Adding Continuous Acquisition Chart Multiple Samples example in NI-DMM - #2220
NI-velmurugan wants to merge 20 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #2220 +/- ##
===========================================
- Coverage 88.12% 75.18% -12.94%
===========================================
Files 88 42 -46
Lines 22830 6633 -16197
===========================================
- Hits 20118 4987 -15131
+ Misses 2712 1646 -1066
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The plotting approach in this example follows the existing gRPC Device Server example continuous-acquire-graph-multiple-points.py , which displays the continuous data with matplotlib. |
|
@jarnoldNI, the PR is ready for your review. |
Can you post a screenshot of what the plot looks like? |
Thanks for pointing that out. I've attached screenshots of the plot below with additional details for clarity: Screenshot 1: Shows the plot generated with Python example. Please let me know if there's any other information you'd like me to include.
|
|
@ni-jfitzger, I’ve addressed the comments you mentioned. Could you please take a look and let me know if you have any additional suggestions? |
| # The last fetch only takes the samples still needed to reach total_samples | ||
| samples_in_this_fetch = samples_to_fetch | ||
| if total_samples is not None: | ||
| samples_in_this_fetch = min(samples_to_fetch, total_samples - samples_fetched) |
There was a problem hiding this comment.
I think this is unnecessary.
This is a continuous acquisition, so I would view samples_to_fetch as a minimum. It should be fine to fetch more samples than needed on the last acquisition.
The only reason I would consider this worth doing is if we were managing a buffer that we need to avoid overflowing.
There was a problem hiding this comment.
Agreed, I removed the clamp. samples_to_fetch is now a minimum, and the last fetch may return more samples than total_samples needs.
Following your buffer point, each iteration now calls read_status() and fetches max(samples_to_fetch, backlog), capped at 100,000, the per-call maximum for a continuous acquisition. The driver docs say a growing backlog eventually overwrites data and raises an error. Fetching the whole backlog lets the chart catch up if plotting is slower than acquisition.
There was a problem hiding this comment.
Now, you've got me thinking about buffer allocation and looking at the C Example.
The LabVIEW Example uses a single constant value for samples__to_fetch.
The C Example has a preallocated buffer that it fetches into on every iteration of the loop, avoiding allocation of a fresh buffer every time.
Our Python implementation of fetch_multi_point is allocating a fresh buffer on every iteration, of the size samples_to_fetch. If we're concerned about keeping up with the fetch backlog, this isn't very efficient.
@marcoskirsch what are your thoughts?
|
|
||
| def _update_chart(plt, axes, line, measurements, new_samples, samples_fetched): | ||
| measurements.extend(new_samples) | ||
| samples_fetched += len(new_samples) |
There was a problem hiding this comment.
samples_fetched += len(new_samples)
This statement should happen before _update_chart is called. There's no reason for this function to handle updating that value.
There was a problem hiding this comment.
I moved samples_fetched += len(new_samples) into the main loop, before the _update_chart call. _update_chart now only draws the chart and no longer returns a value.
marcoskirsch
left a comment
There was a problem hiding this comment.
I do not think this is an appropriate example. Examples should teach clients how to use the driver API, not how to use a third party plotting library.


- [ ] I've added tests applicable for this pull requestWhat does this Pull Request accomplish?
This PR adds
nidmm_cont_acq_chart_multiple_samples.py, a Python adaptation of the LabVIEWCont Acq & Chart Multiple Samples.viWhat testing has been done?