|
1 | 1 | """Streamlit visualization script to display data acquired by nidaqmx_continuous_analog_input.py.""" |
2 | 2 |
|
3 | 3 | 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 | +) |
5 | 11 | from streamlit_echarts import st_echarts |
6 | 12 |
|
7 | 13 | import nipanel |
|
97 | 103 | key="thermocouple_max_value", |
98 | 104 | ) |
99 | 105 | 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 | + ) |
102 | 120 | 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 | + ) |
105 | 135 |
|
106 | 136 | # Timing Settings section in left column |
107 | 137 | st.header("Timing Settings") |
108 | 138 | timing_left, timing_right = st.columns(2) |
109 | 139 | 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 | + ) |
112 | 153 | 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 | + ) |
114 | 162 | st.text_input( |
115 | | - label="Sample Rate", |
116 | | - disabled=True, |
| 163 | + label="Actual Sample Rate", |
117 | 164 | value=str(sample_rate) if sample_rate else "", |
118 | | - key="sample_rate_display", |
| 165 | + key="actual_sample_rate_display", |
119 | 166 | ) |
120 | 167 |
|
121 | 168 | # Right column - Graph and Logging Settings |
|
168 | 215 | st.header("Logging Settings") |
169 | 216 | logging_left, logging_right = st.columns(2) |
170 | 217 | 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, |
175 | 222 | disabled=panel.get_value("is_running", False), |
176 | | - value="", |
177 | | - key="tdms_file_path", |
| 223 | + key="logging_mode", |
178 | 224 | ) |
| 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