forked from M-Labs/thermostat
Move global params into window
This commit is contained in:
parent
3597fb4445
commit
e82437ca9f
|
@ -64,12 +64,6 @@ THERMOSTAT_PARAMETERS = [[
|
||||||
] for ch in range(2)]
|
] for ch in range(2)]
|
||||||
|
|
||||||
|
|
||||||
params = [
|
|
||||||
CommandsParameter.create(name=f"Thermostat Channel {ch} Parameters", type='group', value=ch, children=THERMOSTAT_PARAMETERS[ch])
|
|
||||||
for ch in range(2)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def get_argparser():
|
def get_argparser():
|
||||||
parser = argparse.ArgumentParser(description="ARTIQ master")
|
parser = argparse.ArgumentParser(description="ARTIQ master")
|
||||||
|
|
||||||
|
@ -150,6 +144,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
self._set_up_thermostat_menu()
|
self._set_up_thermostat_menu()
|
||||||
self._set_up_plot_menu()
|
self._set_up_plot_menu()
|
||||||
|
|
||||||
|
self.params = [
|
||||||
|
CommandsParameter.create(name=f"Thermostat Channel {ch} Parameters", type='group', value=ch, children=THERMOSTAT_PARAMETERS[ch])
|
||||||
|
for ch in range(2)
|
||||||
|
]
|
||||||
self._set_param_tree()
|
self._set_param_tree()
|
||||||
|
|
||||||
self.ch0_t_plot = LiveLinePlot()
|
self.ch0_t_plot = LiveLinePlot()
|
||||||
|
@ -617,54 +615,54 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
def _set_param_tree(self):
|
def _set_param_tree(self):
|
||||||
for i, tree in enumerate((self.ch0_tree, self.ch1_tree)):
|
for i, tree in enumerate((self.ch0_tree, self.ch1_tree)):
|
||||||
tree.setParameters(params[i], showTop=False)
|
tree.setParameters(self.params[i], showTop=False)
|
||||||
params[i].sigTreeStateChanged.connect(self.send_command)
|
self.params[i].sigTreeStateChanged.connect(self.send_command)
|
||||||
|
|
||||||
@pyqtSlot(list)
|
@pyqtSlot(list)
|
||||||
def update_pid(self, pid_settings):
|
def update_pid(self, pid_settings):
|
||||||
for settings in pid_settings:
|
for settings in pid_settings:
|
||||||
channel = settings["channel"]
|
channel = settings["channel"]
|
||||||
with QSignalBlocker(params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
params[channel].child("PID Config", "Kp").setValue(settings["parameters"]["kp"])
|
self.params[channel].child("PID Config", "Kp").setValue(settings["parameters"]["kp"])
|
||||||
params[channel].child("PID Config", "Ki").setValue(settings["parameters"]["ki"])
|
self.params[channel].child("PID Config", "Ki").setValue(settings["parameters"]["ki"])
|
||||||
params[channel].child("PID Config", "Kd").setValue(settings["parameters"]["kd"])
|
self.params[channel].child("PID Config", "Kd").setValue(settings["parameters"]["kd"])
|
||||||
if params[channel].child("Temperature PID").value():
|
if self.params[channel].child("Temperature PID").value():
|
||||||
params[channel].child("Temperature PID", "Set Temperature").setValue(settings["target"])
|
self.params[channel].child("Temperature PID", "Set Temperature").setValue(settings["target"])
|
||||||
getattr(self, f'ch{channel}_t_line').setValue(settings["target"])
|
getattr(self, f'ch{channel}_t_line').setValue(settings["target"])
|
||||||
|
|
||||||
@pyqtSlot(list)
|
@pyqtSlot(list)
|
||||||
def update_report(self, report_data):
|
def update_report(self, report_data):
|
||||||
for settings in report_data:
|
for settings in report_data:
|
||||||
channel = settings["channel"]
|
channel = settings["channel"]
|
||||||
with QSignalBlocker(params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
params[channel].child("Temperature PID").setValue(settings["pid_engaged"])
|
self.params[channel].child("Temperature PID").setValue(settings["pid_engaged"])
|
||||||
getattr(self, f'ch{channel}_t_line').setVisible(settings["pid_engaged"])
|
getattr(self, f'ch{channel}_t_line').setVisible(settings["pid_engaged"])
|
||||||
if not settings["pid_engaged"]:
|
if not settings["pid_engaged"]:
|
||||||
params[channel].child("Constant Current").setValue(settings["i_set"])
|
self.params[channel].child("Constant Current").setValue(settings["i_set"])
|
||||||
|
|
||||||
@pyqtSlot(list)
|
@pyqtSlot(list)
|
||||||
def update_thermistor(self, sh_data):
|
def update_thermistor(self, sh_data):
|
||||||
for sh_param in sh_data:
|
for sh_param in sh_data:
|
||||||
channel = sh_param["channel"]
|
channel = sh_param["channel"]
|
||||||
with QSignalBlocker(params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
params[channel].child("Thermistor Config", "T₀").setValue(sh_param["params"]["t0"] - 273.15)
|
self.params[channel].child("Thermistor Config", "T₀").setValue(sh_param["params"]["t0"] - 273.15)
|
||||||
params[channel].child("Thermistor Config", "R₀").setValue(sh_param["params"]["r0"])
|
self.params[channel].child("Thermistor Config", "R₀").setValue(sh_param["params"]["r0"])
|
||||||
params[channel].child("Thermistor Config", "β").setValue(sh_param["params"]["b"])
|
self.params[channel].child("Thermistor Config", "β").setValue(sh_param["params"]["b"])
|
||||||
|
|
||||||
@pyqtSlot(list)
|
@pyqtSlot(list)
|
||||||
def update_pwm(self, pwm_data):
|
def update_pwm(self, pwm_data):
|
||||||
for pwm_params in pwm_data:
|
for pwm_params in pwm_data:
|
||||||
channel = pwm_params["channel"]
|
channel = pwm_params["channel"]
|
||||||
with QSignalBlocker(params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
params[channel].child("Output Config", "Max Voltage").setValue(pwm_params["max_v"]["value"])
|
self.params[channel].child("Output Config", "Max Voltage").setValue(pwm_params["max_v"]["value"])
|
||||||
params[channel].child("Output Config", "Max Current").setValue(pwm_params["max_i_pos"]["value"])
|
self.params[channel].child("Output Config", "Max Current").setValue(pwm_params["max_i_pos"]["value"])
|
||||||
|
|
||||||
@pyqtSlot(list)
|
@pyqtSlot(list)
|
||||||
def update_postfilter(self, postfilter_data):
|
def update_postfilter(self, postfilter_data):
|
||||||
for postfilter_params in postfilter_data:
|
for postfilter_params in postfilter_data:
|
||||||
channel = postfilter_params["channel"]
|
channel = postfilter_params["channel"]
|
||||||
with QSignalBlocker(params[channel]):
|
with QSignalBlocker(self.params[channel]):
|
||||||
params[channel].child("Postfilter Config", "Rate").setValue(postfilter_params["rate"])
|
self.params[channel].child("Postfilter Config", "Rate").setValue(postfilter_params["rate"])
|
||||||
|
|
||||||
|
|
||||||
async def coro_main():
|
async def coro_main():
|
||||||
|
|
Loading…
Reference in New Issue