-
Notifications
You must be signed in to change notification settings - Fork 0
Added NIScope EX Fetch Forever #99
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
Merged
DilmiWickramanayake
merged 47 commits into
main
from
users/DilmiWickramanayake/niscope_ex_fetch_forever
Jul 8, 2025
Merged
Changes from 44 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
b7abc39
Analog Input - Voltage and Thermocouple Single Task
aa6488a
Merge branch 'main' of https://github.com/ni/nipanel-python
6d2ec85
Merge branch 'main' of https://github.com/ni/nipanel-python
89d9c2e
Merge branch 'main' of https://github.com/ni/nipanel-python
871f6e1
add niscope
336d7b5
Rename
31e7f0c
Merge branch 'main' of https://github.com/ni/nipanel-python
5f7776f
Merge branch 'main' into users/DilmiWickramanayake/niscope_ex_fetch_f…
1b00959
Merge branch 'main' into users/DilmiWickramanayake/niscope_ex_fetch_f…
5534c9a
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
6083519
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
01a2e08
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
435aedd
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
8dbd7d0
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
b6e43c6
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
9643953
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
66808fb
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
afeb185
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
eb3da14
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
8b9cc4a
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
b27c77f
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
94a0afc
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
0d720c5
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
be1839f
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
4e7e158
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
c394513
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
fe6a780
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
498c199
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
c4d6d7d
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
414257d
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
5b7d789
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
742b685
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
e50dadc
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
838cd70
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
7338e2c
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
e99a548
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
93fede0
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
b2bfe84
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
5cdc785
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
a80d753
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
2056cf3
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
1fb809c
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
d30dcb5
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
98b3e18
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
29f10d9
Merge remote-tracking branch 'origin' into users/DilmiWickramanayake/…
62b1bbc
Merge remote-tracking branch 'origin' into users/DilmiWickramanayake/…
1403c96
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Prerequisites | ||
| =============== | ||
| Requires a Physical or Simulated Device. Refer to the [Getting Started Section](https://github.com/ni/nidaqmx-python/blob/master/README.rst) to learn how to create a simulated device. This example uses NI oscilloscopes/digitizers, which have the module numbering pattern _51xx_. One example is NI PXIe-5114. | ||
| ## Sample | ||
|
|
||
| This is a nipanel example that displays an interactive Streamlit app and updates and fetches data from device. | ||
|
|
||
| ### Feature | ||
|
|
||
| Script demonstrates NIScope waveform data getting continuously acquired. | ||
| - Supports various data types | ||
|
|
||
| ### Required Software | ||
|
|
||
| - Python 3.9 or later | ||
|
|
||
| ### Usage | ||
|
|
||
| Run `poetry run examples/niscope/niscope_ex_fetch_forever.py` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """Continuously acquires waveforms from NI-SCOPE, processes/scales them.""" | ||
|
|
||
| import time | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import hightime | ||
| import niscope | ||
| import numpy as np | ||
|
|
||
| import nipanel | ||
|
|
||
| panel_script_path = Path(__file__).with_name("niscope_ex_fetch_forever_panel.py") | ||
| panel = nipanel.create_panel(panel_script_path) | ||
|
|
||
| print(f"Panel URL: {panel.panel_url}") | ||
|
|
||
| resource_name = "Dev1" | ||
| channels = 0 | ||
| options = "" | ||
| length = 1000 | ||
| samples_per_fetch = 1000 | ||
|
|
||
| """Example fetch data from device (Dev1).""" | ||
| with niscope.Session(resource_name=resource_name, options=options) as session: | ||
| session.configure_vertical(range=2, coupling=niscope.VerticalCoupling.DC, enabled=True) | ||
| session.configure_horizontal_timing( | ||
| min_sample_rate=100000000, | ||
| min_num_pts=1000, | ||
| ref_position=50.0, | ||
| num_records=1000, | ||
| enforce_realtime=True, | ||
| ) | ||
| session.configure_trigger_software() | ||
|
|
||
| with session.initiate(): | ||
| wfm: np.ndarray[Any, np.dtype[np.int8]] = np.ndarray( | ||
| length * samples_per_fetch, dtype=np.int8 | ||
| ) | ||
| waveforms = session.channels[channels].fetch_into( | ||
| relative_to=niscope.FetchRelativeTo.READ_POINTER, | ||
| offset=0, | ||
| timeout=hightime.timedelta(seconds=5.0), | ||
| waveform=wfm, | ||
| ) | ||
| try: | ||
| print(f"Press Ctrl + C to stop") | ||
| while True: | ||
| offset =session.meas_array_offset | ||
| gain = session.meas_array_gain | ||
| for i in range(len(waveforms)): | ||
| time.sleep(0.2) | ||
| amplitude_list = [] | ||
| total_data = waveforms[i].samples.tolist() | ||
| for amplitude in total_data: | ||
| amplitude = (amplitude * 10) * gain + offset | ||
| amplitude_list.append(amplitude) | ||
| panel.set_value("Waveform", amplitude_list) | ||
|
|
||
| except KeyboardInterrupt: | ||
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| """Streamlit dashboard for visualizing NI-SCOPE waveform data in real time.""" | ||
|
|
||
| import streamlit as st | ||
| from streamlit_echarts import st_echarts | ||
|
|
||
| import nipanel | ||
|
|
||
| st.set_page_config(page_title="NI-SCOPE Example", page_icon="📈", layout="wide") | ||
| st.title("NIScope EX Fetch Forever") | ||
DilmiWickramanayake marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| panel = nipanel.get_panel_accessor() | ||
|
|
||
| waveform = panel.get_value("Waveform", [0]) | ||
|
|
||
| graph = { | ||
| "animation": False, | ||
| "tooltip": {"trigger": "axis"}, | ||
DilmiWickramanayake marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "legend": {"data": ["Amplitude (V)"]}, | ||
| "xAxis": { | ||
| "type": "category", | ||
| "data": list(range(len(waveform))), | ||
| "name": "Samples", | ||
| "nameLocation": "center", | ||
| "nameGap": 40, | ||
| }, | ||
| "yAxis": { | ||
| "type": "value", | ||
| "name": "Amplitude(V)", | ||
| "nameRotate": 90, | ||
| "nameLocation": "center", | ||
| "nameGap": 40, | ||
| }, | ||
| "series": [ | ||
| { | ||
| "name": "niscope data", | ||
| "type": "line", | ||
| "data": waveform, | ||
| "emphasis": {"focus": "series"}, | ||
| "smooth": True, | ||
| "seriesLayoutBy": "row", | ||
| }, | ||
| ], | ||
| } | ||
| st_echarts(options=graph, height="400px", width="75%", key="graph") | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.