Skip to content

Commit 2fedc38

Browse files
author
Dilmi Wickramanayake
committed
Merge branch 'main' of https://github.com/ni/nipanel-python into users/DilmiWickramanayake/Analog_Input_filtering
2 parents a8f847b + 16d0a0b commit 2fedc38

23 files changed

+804
-571
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("Mod1/ai0")
1516
task.ai_channels.add_ai_thrmcpl_chan("Mod1/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/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@
2626
task.timing.samp_clk_dig_fltr_enable = True
2727
chan_voltage.ai_filter_response
2828
filter = panel.get_value("filter", "No Filtering")
29-
if filter == "No Filtering":
30-
chan_voltage.ai_filter_freq = 0.0
31-
chan_current.ai_filter_freq = 0.0
32-
chan_strain_gage.ai_filter_freq = 0.0
33-
34-
chan_voltage.ai_filter_order = 0
35-
chan_current.ai_filter_order = 0
36-
chan_strain_gage.ai_filter_order = 0
37-
38-
chan_voltage.ai_filter_response = panel.get_value("filter_response", "Comb")
39-
chan_current.ai_filter_response = panel.get_value("filter_response", "Comb")
40-
chan_strain_gage.ai_filter_response = panel.get_value("filter_response", "Comb")
41-
else:
42-
chan_voltage.ai_filter_freq = panel.get_value("filter_freq", 1000.0)
43-
chan_current.ai_filter_freq = panel.get_value("filter_freq", 1000.0)
44-
chan_strain_gage.ai_filter_freq = panel.get_value("filter_freq", 1000.0)
45-
46-
chan_voltage.ai_filter_order = panel.get_value("filter_order", 1)
47-
chan_current.ai_filter_order = panel.get_value("filter_order", 1)
48-
chan_strain_gage.ai_filter_order = panel.get_value("filter_order", 1)
49-
50-
chan_voltage.ai_filter_response = panel.get_value("filter_response", "Comb")
51-
chan_current.ai_filter_response = panel.get_value("filter_response", "Comb")
52-
chan_strain_gage.ai_filter_response = panel.get_value("filter_response", "Comb")
29+
# if filter == "No Filtering":
30+
# chan_voltage.ai_filter_freq = 0.0
31+
# chan_current.ai_filter_freq = 0.0
32+
# chan_strain_gage.ai_filter_freq = 0.0
33+
34+
# chan_voltage.ai_filter_order = 0
35+
# chan_current.ai_filter_order = 0
36+
# chan_strain_gage.ai_filter_order = 0
37+
38+
# chan_voltage.ai_filter_response = panel.get_value("filter_response", "Comb")
39+
# chan_current.ai_filter_response = panel.get_value("filter_response", "Comb")
40+
# chan_strain_gage.ai_filter_response = panel.get_value("filter_response", "Comb")
41+
# else:
42+
# chan_voltage.ai_filter_freq = panel.get_value("filter_freq", 1000.0)
43+
# chan_current.ai_filter_freq = panel.get_value("filter_freq", 1000.0)
44+
# chan_strain_gage.ai_filter_freq = panel.get_value("filter_freq", 1000.0)
45+
46+
# chan_voltage.ai_filter_order = panel.get_value("filter_order", 1)
47+
# chan_current.ai_filter_order = panel.get_value("filter_order", 1)
48+
# chan_strain_gage.ai_filter_order = panel.get_value("filter_order", 1)
49+
50+
# chan_voltage.ai_filter_response = panel.get_value("filter_response", "Comb")
51+
# chan_current.ai_filter_response = panel.get_value("filter_response", "Comb")
52+
# chan_strain_gage.ai_filter_response = panel.get_value("filter_response", "Comb")
5353

5454

5555

@@ -76,11 +76,11 @@
7676
print(f"Press Ctrl + C to stop")
7777

7878
while True:
79-
date = panel.get_value("date", None)
80-
time_input = panel.get_value("time", None)
79+
# date = panel.get_value("date", None)
80+
# time_input = panel.get_value("time", None)
8181

8282
hysteriresis = panel.get_value("hysteriesis", 0.0)
83-
task.triggers.start_trigger.cfg_time_start_trig(when = date, timescale=Timescale.USE_HOST)
83+
# task.triggers.start_trigger.cfg_time_start_trig(when = date, timescale=Timescale.USE_HOST)
8484
level = panel.get_value("level", 0.0)
8585
new_slope = Slopes(panel.get_value("slope",Slopes.FALLING.value))
8686
if slope != new_slope:

examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering_panel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@
138138
st.number_input(
139139
"Max Value",
140140
value=0.001,
141-
step=0.0001,
141+
step=1.0,
142142
key="max_value_strain",
143143
)
144144
panel.set_value("max_value_strain", "max_value_strain")
145145
st.title("strain gage information")
146146
st.number_input(
147147
"Gage Factor",
148148
value=2.0,
149-
step=1,
149+
step=1.0,
150150
key="gage_factor",
151151
)
152152
panel.set_value("gage_factor", "gage_factor")

0 commit comments

Comments
 (0)