Skip to content

Commit bd84426

Browse files
Mike ProsserMike Prosser
authored andcommitted
finish updating daqmx example, so all the controls (except I/O) are fully functional
1 parent 1fc1ce2 commit bd84426

File tree

2 files changed

+95
-19
lines changed

2 files changed

+95
-19
lines changed

examples/nidaqmx/nidaqmx_continuous_analog_input.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
from pathlib import Path
55

66
import nidaqmx
7-
from nidaqmx.constants import AcquisitionType, TerminalConfiguration
7+
from nidaqmx.constants import (
8+
AcquisitionType,
9+
TerminalConfiguration,
10+
CJCSource,
11+
TemperatureUnits,
12+
ThermocoupleType,
13+
LoggingMode,
14+
LoggingOperation,
15+
)
816

917
import nipanel
1018

@@ -35,9 +43,22 @@
3543
"Dev1/ai1",
3644
min_val=panel.get_value("thermocouple_min_value", 0.0),
3745
max_val=panel.get_value("thermocouple_max_value", 100.0),
46+
units=panel.get_value("thermocouple_units", TemperatureUnits.DEG_C),
47+
thermocouple_type=panel.get_value("thermocouple_type", ThermocoupleType.K),
48+
cjc_source=panel.get_value(
49+
"thermocouple_cjc_source", CJCSource.CONSTANT_USER_VALUE
50+
),
51+
cjc_val=panel.get_value("thermocouple_cjc_val", 25.0),
3852
)
3953
task.timing.cfg_samp_clk_timing(
40-
rate=1000.0, sample_mode=AcquisitionType.CONTINUOUS, samps_per_chan=3000
54+
rate=panel.get_value("sample_rate_input", 1000.0),
55+
sample_mode=AcquisitionType.CONTINUOUS,
56+
samps_per_chan=panel.get_value("samples_per_channel", 3000),
57+
)
58+
task.in_stream.configure_logging(
59+
file_path=panel.get_value("tdms_file_path", "data.tdms"),
60+
logging_mode=panel.get_value("logging_mode", LoggingMode.OFF),
61+
operation=LoggingOperation.OPEN_OR_CREATE,
4162
)
4263
panel.set_value("sample_rate", task._timing.samp_clk_rate)
4364
try:

examples/nidaqmx/nidaqmx_continuous_analog_input_panel.py

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
"""Streamlit visualization script to display data acquired by nidaqmx_continuous_analog_input.py."""
22

33
import streamlit as st
4-
from nidaqmx.constants import TerminalConfiguration
4+
from nidaqmx.constants import (
5+
TerminalConfiguration,
6+
CJCSource,
7+
TemperatureUnits,
8+
ThermocoupleType,
9+
LoggingMode,
10+
)
511
from streamlit_echarts import st_echarts
612

713
import nipanel
@@ -97,25 +103,66 @@
97103
key="thermocouple_max_value",
98104
)
99105
with channel_middle:
100-
st.selectbox(options=["Deg C"], label="Units", disabled=False)
101-
st.selectbox(options=["J"], label="Thermocouple Type", disabled=False)
106+
nipanel.enum_selectbox(
107+
panel,
108+
label="Units",
109+
value=TemperatureUnits.DEG_C,
110+
disabled=panel.get_value("is_running", False),
111+
key="thermocouple_units",
112+
)
113+
nipanel.enum_selectbox(
114+
panel,
115+
label="Thermocouple Type",
116+
value=ThermocoupleType.K,
117+
disabled=panel.get_value("is_running", False),
118+
key="thermocouple_type",
119+
)
102120
with channel_right:
103-
st.selectbox(options=["Constant Value"], label="CJC Source", disabled=False)
104-
st.selectbox(options=["25"], label="CJC Value", disabled=False)
121+
nipanel.enum_selectbox(
122+
panel,
123+
label="CJC Source",
124+
value=CJCSource.CONSTANT_USER_VALUE,
125+
disabled=panel.get_value("is_running", False),
126+
key="thermocouple_cjc_source",
127+
)
128+
st.number_input(
129+
"CJC Value",
130+
value=25.0,
131+
step=1.0,
132+
disabled=panel.get_value("is_running", False),
133+
key="thermocouple_cjc_val",
134+
)
105135

106136
# Timing Settings section in left column
107137
st.header("Timing Settings")
108138
timing_left, timing_right = st.columns(2)
109139
with timing_left:
110-
st.selectbox(options=["OnboardClock"], label="Sample Clock Source", disabled=False)
111-
st.selectbox(options=["1000"], label="Samples per Loop", disabled=False)
140+
st.selectbox(
141+
options=["OnboardClock"],
142+
label="Sample Clock Source",
143+
disabled=True,
144+
)
145+
st.number_input(
146+
"Sample Rate",
147+
value=1000.0,
148+
step=100.0,
149+
min_value=1.0,
150+
disabled=panel.get_value("is_running", False),
151+
key="sample_rate_input",
152+
)
112153
with timing_right:
113-
st.selectbox(options=[" "], label="Actual Sample Rate", disabled=True)
154+
st.number_input(
155+
"Samples per Loop",
156+
value=3000,
157+
step=100,
158+
min_value=10,
159+
disabled=panel.get_value("is_running", False),
160+
key="samples_per_channel",
161+
)
114162
st.text_input(
115-
label="Sample Rate",
116-
disabled=True,
163+
label="Actual Sample Rate",
117164
value=str(sample_rate) if sample_rate else "",
118-
key="sample_rate_display",
165+
key="actual_sample_rate_display",
119166
)
120167

121168
# Right column - Graph and Logging Settings
@@ -168,11 +215,19 @@
168215
st.header("Logging Settings")
169216
logging_left, logging_right = st.columns(2)
170217
with logging_left:
171-
st.selectbox(options=["Off"], label="Logging Mode", disabled=False)
172-
with logging_right:
173-
st.text_input(
174-
label="TDMS File Path",
218+
nipanel.enum_selectbox(
219+
panel,
220+
label="Logging Mode",
221+
value=LoggingMode.OFF,
175222
disabled=panel.get_value("is_running", False),
176-
value="",
177-
key="tdms_file_path",
223+
key="logging_mode",
178224
)
225+
with logging_right:
226+
col1, col2 = st.columns([3, 1])
227+
with col1:
228+
tdms_file_path = st.text_input(
229+
label="TDMS File Path",
230+
disabled=panel.get_value("is_running", False),
231+
value="data.tdms",
232+
key="tdms_file_path",
233+
)

0 commit comments

Comments
 (0)