Skip to content

Commit 065d6f4

Browse files
author
Dilmi Wickramanayake
committed
Fixed panel comments
1 parent bbdeb81 commit 065d6f4

File tree

7 files changed

+240
-264
lines changed

7 files changed

+240
-264
lines changed

examples/nidaqmx_analog_input_filtering/README.md renamed to examples/nidaqmx/nidaqmx_analog_input_filtering/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Script demonstrates analog input data getting continuously acquired, and being f
1616

1717
### Usage
1818

19+
```pwsh
1920
poetry install --with examples
20-
poetry run examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py
21-
Run `poetry run examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py`
21+
poetry run python examples/all_types/all_types.py
22+
```
2223

examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py renamed to examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,50 @@
1010
Edge,
1111
ExcitationSource,
1212
FilterResponse,
13-
LoggingMode,
14-
LoggingOperation,
1513
Slope,
1614
StrainGageBridgeType,
1715
TerminalConfiguration,
1816
)
17+
import time
1918

19+
import nidaqmx.system
2020
import nipanel
21-
2221
panel_script_path = Path(__file__).with_name("nidaqmx_analog_input_filtering_panel.py")
2322
panel = nipanel.create_panel(panel_script_path)
2423
panel.set_value("is_running", False)
24+
25+
system = nidaqmx.system.System.local()
26+
27+
channel_name = []
28+
for dev in system.devices:
29+
for chan in dev.ai_physical_chans:
30+
channel_name.append(chan.name)
31+
panel.set_value("channel_name", channel_name)
32+
trigger_sources = []
33+
for dev in system.devices:
34+
if hasattr(dev, "terminals"):
35+
for term in dev.terminals:
36+
trigger_sources.append(term)
37+
panel.set_value("trigger_sources", trigger_sources)
2538
try:
2639
print(f"Panel URL: {panel.panel_url}")
2740
print(f"Waiting for the 'Run' button to be pressed...")
2841
print(f"(Press Ctrl + C to quit)")
2942
while True:
3043
while not panel.get_value("run_button", False):
3144
panel.set_value("is_running", False)
45+
# time.sleep(0.1)
3246
panel.set_value("is_running", True)
3347
panel.set_value("stop_button", False)
3448

3549
# How to use nidaqmx: https://nidaqmx-python.readthedocs.io/en/stable/
3650
with nidaqmx.Task() as task:
51+
3752
chan_type = panel.get_value("chan_type", "1")
3853

3954
if chan_type == "2":
4055
chan = task.ai_channels.add_ai_current_chan(
41-
"Mod3/ai10",
56+
panel.get_value("physical_channel", ""),
4257
max_val=panel.get_value("max_value_current", 0.01),
4358
min_val=panel.get_value("min_value_current", -0.01),
4459
ext_shunt_resistor_val=panel.get_value("shunt_resistor_value", 249.0),
@@ -50,7 +65,7 @@
5065

5166
elif chan_type == "3":
5267
chan = task.ai_channels.add_ai_strain_gage_chan(
53-
"Mod3/ai10",
68+
panel.get_value("physical_channel", ""),
5469
nominal_gage_resistance=panel.get_value("gage_resistance", 350.0),
5570
voltage_excit_source=ExcitationSource.EXTERNAL, # Only mode that works
5671
max_val=panel.get_value("max_value_strain", 0.001),
@@ -66,27 +81,23 @@
6681
)
6782
else:
6883
chan = task.ai_channels.add_ai_voltage_chan(
69-
"Mod3/ai10",
84+
panel.get_value("physical_channel", ""),
7085
terminal_config=panel.get_value(
7186
"terminal_configuration", TerminalConfiguration.DEFAULT
7287
),
7388
max_val=panel.get_value("max_value_voltage", 5.0),
7489
min_val=panel.get_value("min_value_voltage", -5.0),
7590
)
91+
7692

7793
task.timing.cfg_samp_clk_timing(
7894
rate=panel.get_value("rate", 1000.0),
7995
sample_mode=AcquisitionType.CONTINUOUS,
8096
samps_per_chan=panel.get_value("total_samples", 100),
8197
)
82-
panel.set_value("actual_sample_rate", task._timing.samp_clk_rate)
98+
panel.set_value("actual_sample_rate", task.timing.samp_clk_rate)
8399
panel.set_value("sample_rate", panel.get_value("rate", 100.0))
84-
85-
task.in_stream.configure_logging(
86-
file_path=panel.get_value("tdms_file_path", "data.tdms"),
87-
logging_mode=panel.get_value("logging_mode", LoggingMode.OFF),
88-
operation=LoggingOperation.OPEN_OR_CREATE,
89-
)
100+
90101
if panel.get_value("filter", "Filter") == "Filter":
91102
chan.ai_filter_enable = True
92103
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
@@ -101,14 +112,16 @@
101112
panel.set_value("actual_filter_freq", 0.0)
102113
panel.set_value("actual_filter_response", FilterResponse.COMB)
103114
panel.set_value("actual_filter_order", 0)
104-
115+
105116
trigger_type = panel.get_value("trigger_type")
106117
if trigger_type == "5":
107118
task.triggers.start_trigger.cfg_anlg_edge_start_trig(
108119
trigger_source="APFI0",
109120
trigger_slope=panel.get_value("slope", Slope.FALLING),
110121
trigger_level=panel.get_value("level", 0.0),
111122
)
123+
124+
112125
if trigger_type == "2":
113126
task.triggers.start_trigger.cfg_dig_edge_start_trig(
114127
trigger_source="/Dev2/PFI0", trigger_edge=panel.get_value("edge", Edge.FALLING)

0 commit comments

Comments
 (0)