Add store led script after measurement
This commit is contained in:
parent
dc93134651
commit
d9947e18a9
@ -33,7 +33,7 @@ from ..utility.config import AppConfig
|
|||||||
|
|
||||||
import cpdctrl.voltage_measurement_device as vmd
|
import cpdctrl.voltage_measurement_device as vmd
|
||||||
import cpdctrl.led_control_device as ledd
|
import cpdctrl.led_control_device as ledd
|
||||||
from cpdctrl.led_script import LedScript
|
from cpdctrl.led_script import LedScript, InvalidScript
|
||||||
from cpdctrl.utility.data import DataCollector
|
from cpdctrl.utility.data import DataCollector
|
||||||
from cpdctrl.measurement import measure
|
from cpdctrl.measurement import measure
|
||||||
|
|
||||||
@ -343,6 +343,21 @@ class MainWindow(QMainWindow):
|
|||||||
self.proc_measure = None
|
self.proc_measure = None
|
||||||
# don't update w_led_script, keep displaying the last values
|
# don't update w_led_script, keep displaying the last values
|
||||||
self.led_script.reset()
|
self.led_script.reset()
|
||||||
|
# store a copy of the led script
|
||||||
|
if AppConfig.MAIN_CFG.get_or("led_script_save_copy", True):
|
||||||
|
filename = self.led_script.filepath
|
||||||
|
extra_header = []
|
||||||
|
if filename is None:
|
||||||
|
filename = "led_script.led"
|
||||||
|
else:
|
||||||
|
filename = os.path.basename(filename)
|
||||||
|
extra_header.append(f"# Original file path: {self.led_script.filepath}")
|
||||||
|
filename = "led_script.led" # always use led_script.led
|
||||||
|
datadir = self.data_collector.dirpath
|
||||||
|
filepath = os.path.join(datadir, filename)
|
||||||
|
led_script = self.led_script.to_file(add_default_header=True, add_extra_header=extra_header)
|
||||||
|
with open(filepath, "w") as f:
|
||||||
|
f.write(led_script)
|
||||||
self.topbar.enable_button("meas_start")
|
self.topbar.enable_button("meas_start")
|
||||||
self.topbar.enable_button("connect_vmdev")
|
self.topbar.enable_button("connect_vmdev")
|
||||||
self.topbar.enable_button("connect_leddev")
|
self.topbar.enable_button("connect_leddev")
|
||||||
@ -460,9 +475,9 @@ class MainWindow(QMainWindow):
|
|||||||
log.info(f"Loading led script of type '{script_type}' with auto-update {auto_update}")
|
log.info(f"Loading led script of type '{script_type}' with auto-update {auto_update}")
|
||||||
try:
|
try:
|
||||||
self.led_script = LedScript(script=script, auto_update=False, verbose=True)
|
self.led_script = LedScript(script=script, auto_update=False, verbose=True)
|
||||||
except ValueError as e:
|
except InvalidScript as e:
|
||||||
# show qt error
|
# show qt error
|
||||||
QMessageBox.critical(self, "LED script error", str(e))
|
QMessageBox.critical(self, "Invalid script", str(e))
|
||||||
return
|
return
|
||||||
if auto_update and script_type == "file":
|
if auto_update and script_type == "file":
|
||||||
# can not use "integrated" auto update function because we cant receive qt signals
|
# can not use "integrated" auto update function because we cant receive qt signals
|
||||||
|
Loading…
x
Reference in New Issue
Block a user