Add power_off_on_end
This commit is contained in:
parent
e42ef07be9
commit
9ac3f73566
@ -314,17 +314,23 @@ class MainWindow(QMainWindow):
|
||||
# IDLE - NOT IN MEASUREMENT
|
||||
# check if devices stayed connected
|
||||
def idle_start(self):
|
||||
self.idle_timer = QTimer(self)
|
||||
self.idle_timer.timeout.connect(self.idle_update)
|
||||
self.idle_timer.start(AppConfig.MAIN_CFG.get_or("idle_update_interval_s", 10)*1000)
|
||||
if self.idle_timer is None:
|
||||
self.idle_timer = QTimer(self)
|
||||
self.idle_timer.timeout.connect(self.idle_update)
|
||||
self.idle_timer.start(AppConfig.MAIN_CFG.get_or("idle_update_interval_s", 10)*1000)
|
||||
else:
|
||||
log.debug("Not starting idle timer - it is already running")
|
||||
|
||||
def idle_update(self):
|
||||
self.vmdev_test_connection()
|
||||
self.leddev_test_connection()
|
||||
|
||||
def idle_stop(self):
|
||||
self.idle_timer.stop()
|
||||
self.idle_timer = None
|
||||
if self.idle_timer is not None:
|
||||
self.idle_timer.stop()
|
||||
self.idle_timer = None
|
||||
else:
|
||||
log.debug("Not stopping idle timer - it is not running")
|
||||
|
||||
|
||||
# MEASUREMENT
|
||||
@ -418,9 +424,9 @@ class MainWindow(QMainWindow):
|
||||
log.info("Stopping measurement")
|
||||
if not self.measurement_is_running():
|
||||
raise RuntimeError("measure_stop: Measurement is not running")
|
||||
self.measurement_timer.stop()
|
||||
self.set_status("Stopping measurement")
|
||||
self.command_queue.put("stop")
|
||||
self.measurement_timer.stop()
|
||||
self.proc_measure.join()
|
||||
self.set_status("Saving data...")
|
||||
self.data_collector.save_csv_in_dir()
|
||||
@ -468,8 +474,9 @@ class MainWindow(QMainWindow):
|
||||
self.measure_stop()
|
||||
# this should only be run when the measurement is stopped automatically
|
||||
# and is therefore not part of measure_stop()
|
||||
if AppConfig.MAIN_CFG.get_or("power_switch_turn_off_when_measurement_ends", False):
|
||||
if AppConfig.MEAS_CFG.get_or("power_off_script_end", False):
|
||||
self.power_off()
|
||||
QMessageBox.information(self, "Powered Off", "The measurement has stopped, power switch has been turned off.")
|
||||
|
||||
def measurement_is_running(self):
|
||||
return self.proc_measure is not None
|
||||
@ -653,10 +660,13 @@ class MainWindow(QMainWindow):
|
||||
if self.power_switch is None:
|
||||
raise RuntimeError("No power switch configured")
|
||||
log.info("Powering off")
|
||||
self.idle_stop() # dont show device disconnected errors
|
||||
self.power_switch.off()
|
||||
silent = True
|
||||
time.sleep(0.2)
|
||||
self.leddev_test_connection(silent=silent)
|
||||
self.vmdev_test_connection(silent=silent)
|
||||
self.idle_start()
|
||||
|
||||
|
||||
def app_exit(self) -> None:
|
||||
|
@ -56,5 +56,3 @@ class AppSettings(QWidget):
|
||||
self.w_form.add_form_row("power_switch_autoconnect_devices_timeout_s", "Autoconnect devices after (s)", 15, w_power_on_reconnect_dt, "After switching on, wait x seconds before trying to reconnect to the last devices\nSet to 0 to disable the auto-connection attempt.", group="power_switch")
|
||||
|
||||
self.w_form.update_alignment()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user