Skip to content

Commit 62b1bbc

Browse files
author
Dilmi Wickramanayake
committed
Merge remote-tracking branch 'origin' into users/DilmiWickramanayake/niscope_ex_fetch_forever
2 parents 98b3e18 + 16d0a0b commit 62b1bbc

22 files changed

+788
-529
lines changed

.github/workflows/check_docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
- name: Check out repo
1313
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1414
- name: Set up Python
15-
uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
15+
uses: ni/python-actions/setup-python@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
1616
id: setup-python
1717
- name: Set up Poetry
18-
uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
18+
uses: ni/python-actions/setup-poetry@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
1919
- name: Check for lock changes
2020
run: poetry check --lock
2121
- name: Cache virtualenv (with docs)

.github/workflows/check_nipanel.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
- name: Check out repo
1313
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1414
- name: Set up Python
15-
uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
15+
uses: ni/python-actions/setup-python@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
1616
id: setup-python
1717
- name: Set up Poetry
18-
uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
18+
uses: ni/python-actions/setup-poetry@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
1919
- name: Check for lock changes
2020
run: poetry check --lock
2121
- name: Cache virtualenv

.github/workflows/run_unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
- name: Check out repo
2020
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2121
- name: Set up Python
22-
uses: ni/python-actions/setup-python@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
22+
uses: ni/python-actions/setup-python@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
2323
id: setup-python
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Set up Poetry
27-
uses: ni/python-actions/setup-poetry@a3bfe1baa6062fd6157683651d653d527967d4d4 # v0.3.1
27+
uses: ni/python-actions/setup-poetry@5286c12d65d90b2ea738bd57d452dc4366497581 # v0.4.1
2828
- name: Cache virtualenv
2929
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
3030
with:

CONTRIBUTING.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ start docs\_build\index.html
5656

5757
## Running examples
5858

59-
1. First, run the PythonPanelService (not part of this repo, provided seperately)
60-
2. Run the command `poetry run python examples/hello/hello.py`
61-
3. Open http://localhost:42001/panel-service/panels/hello_panel/ in your browser
62-
4. If there is an error about missing imports (especially nipanel), execute this
63-
command (from the nipanel-python directory) to install the dependencies into the venv:
64-
`%localappdata%\Temp\python_panel_service_venv\Scripts\python.exe -m pip install .\[examples,dev]`,
65-
then restart the PythonPanelService and re-run hello.py.
66-
67-
You can see all running panels (and stop them) at: http://localhost:42001/panel-service/
59+
1. Run the **PythonPanelService** (not part of this repo, provided seperately)
60+
2. `poetry install --with examples` to get the dependencies needed for the examples
61+
3. Run the examples with these command(s):
62+
- `poetry run python examples/hello/hello.py`
63+
- `poetry run python examples/all_types/all_types.py`
64+
- `poetry run python examples/simple_graph/simple_graph.py`
65+
- `poetry run python examples/nidaqmx/nidaqmx_continuous_analog_input.py` (requires real or simulated devices)
66+
4. Open http://localhost:42001/panel-service/ in your browser, which will show all running panels
6867

6968
# Debugging on the streamlit side
7069

examples/all_types/all_types_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
import nipanel
77

8-
panel = nipanel.get_panel_accessor()
98

109
st.set_page_config(page_title="All Types Example", page_icon="📊", layout="wide")
1110
st.title("All Types Example")
1211

12+
panel = nipanel.get_panel_accessor()
1313
for name in all_types_with_values.keys():
1414
col1, col2 = st.columns([0.4, 0.6])
1515

examples/hello/hello_panel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import nipanel
66

7-
panel = nipanel.get_panel_accessor()
87

98
st.set_page_config(page_title="Hello World Example", page_icon="📊", layout="wide")
109
st.title("Hello World Example")
10+
11+
panel = nipanel.get_panel_accessor()
1112
st.write(panel.get_value("hello_string", ""))

examples/nidaqmx/nidaqmx_continuous_analog_input.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
panel_script_path = Path(__file__).with_name("nidaqmx_continuous_analog_input_panel.py")
1111
panel = nipanel.create_panel(panel_script_path)
1212

13+
# How to use nidaqmx: https://nidaqmx-python.readthedocs.io/en/stable/
1314
with nidaqmx.Task() as task:
1415
task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
1516
task.ai_channels.add_ai_thrmcpl_chan("Dev1/ai1")
@@ -18,10 +19,13 @@
1819
)
1920
panel.set_value("sample_rate", task._timing.samp_clk_rate)
2021
task.start()
22+
print(f"Panel URL: {panel.panel_url}")
2123
try:
22-
print(f"\nPress Ctrl + C to stop")
24+
print(f"Press Ctrl + C to stop")
2325
while True:
24-
data = task.read(number_of_samples_per_channel=1000)
26+
data = task.read(
27+
number_of_samples_per_channel=1000 # pyright: ignore[reportArgumentType]
28+
)
2529
panel.set_value("voltage_data", data[0])
2630
panel.set_value("thermocouple_data", data[1])
2731
except KeyboardInterrupt:

examples/nidaqmx/nidaqmx_continuous_analog_input_panel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import nipanel
77

8-
panel = nipanel.get_panel_accessor()
98

9+
st.set_page_config(page_title="NI-DAQmx Example", page_icon="📈", layout="wide")
1010
st.title("Analog Input - Voltage and Thermocouple in a Single Task")
1111
voltage_tab, thermocouple_tab = st.tabs(["Voltage", "Thermocouple"])
1212

@@ -21,6 +21,7 @@
2121
unsafe_allow_html=True,
2222
)
2323

24+
panel = nipanel.get_panel_accessor()
2425
thermocouple_data = panel.get_value("thermocouple_data", [0.0])
2526
voltage_data = panel.get_value("voltage_data", [0.0])
2627

@@ -65,7 +66,7 @@
6566
},
6667
],
6768
}
68-
st_echarts(options=voltage_therm_graph, height="400px", key="graph")
69+
st_echarts(options=voltage_therm_graph, height="400px", key="voltage_therm_graph")
6970

7071
voltage_tab.header("Voltage")
7172
with voltage_tab:

examples/niscope/niscope_ex_fetch_forever.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
try:
4747
print(f"Press Ctrl + C to stop")
4848
while True:
49-
offset =session.meas_array_offset
49+
offset = session.meas_array_offset
5050
gain = session.meas_array_gain
5151
for i in range(len(waveforms)):
5252
time.sleep(0.2)

examples/simple_graph/simple_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# Slowly vary the frequency for a more dynamic visualization
3434
frequency = 1.0 + 0.5 * math.sin(time.time() / 5.0)
35-
time.sleep(1)
35+
time.sleep(0.1)
3636

3737
except KeyboardInterrupt:
3838
print("Exiting...")

0 commit comments

Comments
 (0)