-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVtxEngineParamsDialog.py
More file actions
198 lines (159 loc) · 8.67 KB
/
VtxEngineParamsDialog.py
File metadata and controls
198 lines (159 loc) · 8.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import sys
from PyQt5.QtGui import QDoubleValidator, QIntValidator
from PyQt5.QtWidgets import QDialog, QApplication, QFileDialog
from DAQConst import ATS9350InputRange
from VtxEngineParams import VtxEngineParams, DEFAULT_VTX_ENGINE_PARAMS, AcquisitionType
from Ui_VtxEngineParamsDialog import Ui_VtxEngineParamsDialog
from vortex import Range
class VtxEngineParamsDialog(QDialog, Ui_VtxEngineParamsDialog):
"""Dialog for setting VtxEngineParameters.
"""
def __init__(self, cfg: VtxEngineParams=DEFAULT_VTX_ENGINE_PARAMS):
"""Instantiate dialog for editing params in cfg.
Args:
cfg (StandardEngineParams, optional): Configuration to edit. Defaults to DEFAULT_ENGINE_PARAMS.
"""
super().__init__()
self.setupUi(self)
self.setWindowTitle("OCT Engine Parameters")
# uic.loadUi("VtxEngineParamsDialog.ui", self)
# Set validators for some values
# scientific notation for some
v = QDoubleValidator()
v.setNotation(QDoubleValidator.Notation.ScientificNotation)
self.lineEditGalvoDelay.setValidator(v)
# plain double validators
v = QDoubleValidator(-10,10,3)
self.lineEditGalvoSLOWmin.setValidator(v)
v = QDoubleValidator(-10,10,3)
self.lineEditGalvoSLOWmax.setValidator(v)
v = QDoubleValidator(-10,10,3)
self.lineEditGalvoFASTmin.setValidator(v)
v = QDoubleValidator(-10,10,3)
self.lineEditGalvoFASTmax.setValidator(v)
v = QDoubleValidator(0,2,3)
self.lineEditSLOWUnitsPerVolt.setValidator(v)
v = QDoubleValidator(0,2,3)
self.lineEditFASTUnitsPerVolt.setValidator(v)
self.lineEditBlocksToAllocate.setValidator(v)
v = QIntValidator(1, 1000)
self.lineEditPreloadCount.setValidator(v)
v = QIntValidator(0, 16)
self.lineEditProcessSlots.setValidator(v)
v = QIntValidator(1000,1000000)
self.lineEditInternalClockRate.setValidator(v)
v = QIntValidator(1,100)
self.lineEditExternalClockLevelPct.setValidator(v)
v = QIntValidator(1,10000)
self.lineEditTriggerRange.setValidator(v)
v = QDoubleValidator()
self.lineEditTriggerLevelFraction.setValidator(v)
self.initializeDialog(cfg) # takes whatever is in cfg and inits dlg
# slot for pb to select file
self.pbSelectFile.clicked.connect(self._selectFileClicked)
# slots for accept and cancel
self.buttonBoxMain.accepted.connect(self._accepted)
self.buttonBoxMain.rejected.connect(self.reject)
def _selectFileClicked(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fname, _ = QFileDialog.getOpenFileName(self,"Select input file", "","numpy files (*.npy)", options=options)
if fname:
print(fname)
self.labelFileName.setText(fname)
else:
print("None selected")
def _accepted(self) -> None:
self._cfg = self.getEngineParameters()
self.accept()
def initializeDialog(self, cfg: VtxEngineParams):
self._cfg = cfg
self.leAperBlock.setText(str(cfg.ascans_per_block))
self.leSperA.setText(str(cfg.samples_per_ascan))
self.leTriggerDelay.setText(str(cfg.trigger_delay_samples))
self.leLaserPort.setText(str(cfg.laser_port))
self.lineEditGalvoDelay.setText(str(cfg.galvo_delay))
self.lineEditGalvoSLOWmin.setText(str(cfg.galvo_slow_voltage_range.min))
self.lineEditGalvoSLOWmax.setText(str(cfg.galvo_slow_voltage_range.max))
self.lineEditGalvoFASTmin.setText(str(cfg.galvo_fast_voltage_range.min))
self.lineEditGalvoFASTmax.setText(str(cfg.galvo_fast_voltage_range.max))
self.lineEditSLOWUnitsPerVolt.setText(str(cfg.galvo_slow_units_per_volt))
self.lineEditFASTUnitsPerVolt.setText(str(cfg.galvo_fast_units_per_volt))
self.lineEditTriggersPerSecond.setText(str(cfg.ssrc_triggers_per_second))
self.lineEditClockRisingEdgesPerTrigger.setText(str(cfg.ssrc_clock_rising_edges_per_trigger))
self.checkBoxInternalClock.setChecked(cfg.internal_clock)
self.lineEditInternalClockRate.setText(str(cfg.clock_samples_per_second))
self.lineEditExternalClockLevelPct.setText(str(cfg.external_clock_level_pct))
self.comboBoxInputChannel.setCurrentText(cfg.input_channel)
self.lineEditTriggerRange.setText(str(cfg.trigger_range_millivolts))
self.lineEditTriggerLevelFraction.setText(str(cfg.trigger_level_fraction))
# self.widgetDispersion.setDispersion(cfg.dispersion)
self.lineEditBlocksToAllocate.setText(str(cfg.blocks_to_allocate))
self.lineEditPreloadCount.setText(str(cfg.preload_count))
self.lineEditProcessSlots.setText(str(cfg.process_slots))
self.lineEditLogLevel.setText(str(cfg.log_level))
self.cbSaveProfilerData.setChecked(cfg.save_profiler_data)
self.cbFileAcquisition.setChecked(cfg.acquisition_type == AcquisitionType.FILE_ACQUISITION)
self.labelFileName.setText(cfg.input_file)
# enum-using combo boxes....
self.comboBoxInputRange.initialize(ATS9350InputRange, cfg.input_channel_range_millivolts)
# clock and device sources
self.lineEditGalvoClockSource.setText(cfg.galvo_clock_source)
self.lineEditGalvoSLOWDevice.setText(cfg.galvo_slow_device_channel)
self.lineEditGalvoFASTDevice.setText(cfg.galvo_fast_device_channel)
self.lineEditStrobeClockSource.setText(cfg.strobe_clock_source)
self.lineEditStrobeDevice.setText(cfg.strobe_device_channel)
# enable/disable
self.groupBoxGalvo.setChecked(cfg.galvo_enabled)
self.groupBoxStrobe.setChecked(cfg.strobe_enabled)
def getEngineParameters(self) -> VtxEngineParams:
s = VtxEngineParams()
s.ascans_per_block = int(self.leAperBlock.text())
s.samples_per_ascan = int(self.leSperA.text())
s.trigger_delay_samples = int(self.leTriggerDelay.text())
s.laser_port = self.leLaserPort.text()
s.galvo_delay = float(self.lineEditGalvoDelay.text())
s.galvo_slow_voltage_range = Range(float(self.lineEditGalvoSLOWmin.text()), float(self.lineEditGalvoSLOWmax.text()))
s.galvo_fast_voltage_range = Range(float(self.lineEditGalvoFASTmin.text()), float(self.lineEditGalvoFASTmax.text()))
s.galvo_slow_units_per_volt = float(self.lineEditSLOWUnitsPerVolt.text())
s.galvo_fast_units_per_volt = float(self.lineEditFASTUnitsPerVolt.text())
s.clock_samples_per_second = int(self.lineEditInternalClockRate.text())
s.ssrc_triggers_per_second = int(self.lineEditTriggersPerSecond.text())
s.ssrc_clock_rising_edges_per_trigger = int(self.lineEditClockRisingEdgesPerTrigger.text())
# s.dispersion = self.widgetDispersion.getDispersion()
s.internal_clock = bool(self.checkBoxInternalClock.isChecked())
s.external_clock_level_pct = int(self.lineEditExternalClockLevelPct.text())
s.input_channel = self.comboBoxInputChannel.currentText()
s.trigger_range_millivolts = int(self.lineEditTriggerRange.text())
s.trigger_level_fraction = float(self.lineEditTriggerLevelFraction.text())
s.input_channel_range_millivolts = self.comboBoxInputRange.itemData(self.comboBoxInputRange.currentIndex())
s.blocks_to_allocate = int(self.lineEditBlocksToAllocate.text())
s.preload_count = int(self.lineEditPreloadCount.text())
s.process_slots = int(self.lineEditProcessSlots.text())
s.log_level = int(self.lineEditLogLevel.text())
s.save_profiler_data = self.cbSaveProfilerData.isChecked()
if self.cbFileAcquisition.isChecked():
s.acquisition_type = AcquisitionType.FILE_ACQUISITION
else:
s.acquisition_type = AcquisitionType.ALAZAR_ACQUISITION
s.input_file = self.labelFileName.text()
# enable/disable
s.galvo_enabled = self.groupBoxGalvo.isChecked()
s.strobe_enabled = self.groupBoxStrobe.isChecked()
# clock source stuff added
s.galvo_clock_source = self.lineEditGalvoClockSource.text()
s.galvo_slow_device_channel = self.lineEditGalvoSLOWDevice.text()
s.galvo_fast_device_channel = self.lineEditGalvoFASTDevice.text()
s.strobe_clock_source = self.lineEditStrobeClockSource.text()
s.strobe_device_channel = self.lineEditStrobeDevice.text()
return s
if __name__ == '__main__':
app = QApplication(sys.argv)
dlg = VtxEngineParamsDialog(DEFAULT_VTX_ENGINE_PARAMS)
dlg.show()
app.exec_()
print("exec() done")
params = dlg._cfg
dlg2 = VtxEngineParamsDialog(params)
dlg2.exec()
# app.exec_()