diff --git a/cpdctrl_gui/ui/main_window.py b/cpdctrl_gui/ui/main_window.py index b6116f0..714f37f 100644 --- a/cpdctrl_gui/ui/main_window.py +++ b/cpdctrl_gui/ui/main_window.py @@ -113,7 +113,7 @@ class MainWindow(QMainWindow): # LED SCRIPT self.w_led_script = LedScriptViewer(LedScript(0)) - self.w_led_script.model.dataChanged.connect(self._led_script_updated) + self.w_led_script.dataChanged.connect(self._led_script_updated) self.w_lefttab.addTab(self.w_led_script, "LED Script") self.w_measurement_settings.w_led_script.script_changed.connect(self.led_script_load) @@ -256,19 +256,23 @@ class MainWindow(QMainWindow): if self.leddev is None: raise ValueError("No led control device selected") - self.topbar.disable_button("meas_start") - self.topbar.disable_button("connect_vmdev") - self.topbar.disable_button("connect_leddev") - self.topbar.disable_button("meas_save") - self.topbar.disable_button("meas_load") - self.topbar.enable_button("meas_stop") - self.w_plot.clear_data() name = self.w_measurement_settings.get_value("name") script = self.w_measurement_settings.get_value("led_script") led_script = LedScript(script=script) flush_after = self.w_measurement_settings.get_value("flush_after") use_buffer = self.w_measurement_settings.get_value("use_buffer") + # check if device supports buffer mode + if use_buffer and not callable(getattr(self.vmdev, 'buffer_measure', None)): + # show warning dialog + ret = QMessageBox.warning(self, "Buffer mode not supported", "The selected voltage measurement device does not support the buffer measurement mode.\nClick Ok to continue without buffer measurement mode.", buttons=QMessageBox.StandardButton.Ok|QMessageBox.StandardButton.Cancel, defaultButton=QMessageBox.StandardButton.Ok) + if ret == QMessageBox.StandardButton.Ok: + log.warning("Device does not support buffer mode, disabling") + use_buffer = False + else: + log.info("Cancelled measurement due to buffer mode not being available") + return + max_measurements = self.w_measurement_settings.get_value("max_measurements") stop_on_script_end = self.w_measurement_settings.get_value("stop_on_script_end") interval = self.w_measurement_settings.get_value("interval") @@ -280,6 +284,14 @@ class MainWindow(QMainWindow): log.info(f"Starting measurement with:\n\tinterval = {interval}\n\tflush_after = {flush_after}\n\tuse_buffer = {use_buffer}\n\tmax_measurements = {max_measurements}\n\tstop_on_script_end = {stop_on_script_end}") + self.topbar.disable_button("meas_start") + self.topbar.disable_button("connect_vmdev") + self.topbar.disable_button("connect_leddev") + self.topbar.disable_button("meas_save") + self.topbar.disable_button("meas_load") + self.topbar.enable_button("meas_stop") + self.w_plot.clear_data() + # have the led script member be the only auto-updating script, # and pass a non-updating copy to the measurement thread if self.led_script is None: @@ -456,6 +468,7 @@ class MainWindow(QMainWindow): """ Send the new led script to the measurement thread and update the gui widget. """ + print("Update script") # update gui self.w_led_script.update_time_predictions() # update the measurement led script