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)]
|
||||
|
||||
|
||||
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():
|
||||
parser = argparse.ArgumentParser(description="ARTIQ master")
|
||||
|
||||
|
@ -150,6 +144,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
self._set_up_thermostat_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.ch0_t_plot = LiveLinePlot()
|
||||
|
@ -617,54 +615,54 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
|
||||
def _set_param_tree(self):
|
||||
for i, tree in enumerate((self.ch0_tree, self.ch1_tree)):
|
||||
tree.setParameters(params[i], showTop=False)
|
||||
params[i].sigTreeStateChanged.connect(self.send_command)
|
||||
tree.setParameters(self.params[i], showTop=False)
|
||||
self.params[i].sigTreeStateChanged.connect(self.send_command)
|
||||
|
||||
@pyqtSlot(list)
|
||||
def update_pid(self, pid_settings):
|
||||
for settings in pid_settings:
|
||||
channel = settings["channel"]
|
||||
with QSignalBlocker(params[channel]):
|
||||
params[channel].child("PID Config", "Kp").setValue(settings["parameters"]["kp"])
|
||||
params[channel].child("PID Config", "Ki").setValue(settings["parameters"]["ki"])
|
||||
params[channel].child("PID Config", "Kd").setValue(settings["parameters"]["kd"])
|
||||
if params[channel].child("Temperature PID").value():
|
||||
params[channel].child("Temperature PID", "Set Temperature").setValue(settings["target"])
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("PID Config", "Kp").setValue(settings["parameters"]["kp"])
|
||||
self.params[channel].child("PID Config", "Ki").setValue(settings["parameters"]["ki"])
|
||||
self.params[channel].child("PID Config", "Kd").setValue(settings["parameters"]["kd"])
|
||||
if self.params[channel].child("Temperature PID").value():
|
||||
self.params[channel].child("Temperature PID", "Set Temperature").setValue(settings["target"])
|
||||
getattr(self, f'ch{channel}_t_line').setValue(settings["target"])
|
||||
|
||||
@pyqtSlot(list)
|
||||
def update_report(self, report_data):
|
||||
for settings in report_data:
|
||||
channel = settings["channel"]
|
||||
with QSignalBlocker(params[channel]):
|
||||
params[channel].child("Temperature PID").setValue(settings["pid_engaged"])
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("Temperature PID").setValue(settings["pid_engaged"])
|
||||
getattr(self, f'ch{channel}_t_line').setVisible(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)
|
||||
def update_thermistor(self, sh_data):
|
||||
for sh_param in sh_data:
|
||||
channel = sh_param["channel"]
|
||||
with QSignalBlocker(params[channel]):
|
||||
params[channel].child("Thermistor Config", "T₀").setValue(sh_param["params"]["t0"] - 273.15)
|
||||
params[channel].child("Thermistor Config", "R₀").setValue(sh_param["params"]["r0"])
|
||||
params[channel].child("Thermistor Config", "β").setValue(sh_param["params"]["b"])
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("Thermistor Config", "T₀").setValue(sh_param["params"]["t0"] - 273.15)
|
||||
self.params[channel].child("Thermistor Config", "R₀").setValue(sh_param["params"]["r0"])
|
||||
self.params[channel].child("Thermistor Config", "β").setValue(sh_param["params"]["b"])
|
||||
|
||||
@pyqtSlot(list)
|
||||
def update_pwm(self, pwm_data):
|
||||
for pwm_params in pwm_data:
|
||||
channel = pwm_params["channel"]
|
||||
with QSignalBlocker(params[channel]):
|
||||
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"])
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("Output Config", "Max Voltage").setValue(pwm_params["max_v"]["value"])
|
||||
self.params[channel].child("Output Config", "Max Current").setValue(pwm_params["max_i_pos"]["value"])
|
||||
|
||||
@pyqtSlot(list)
|
||||
def update_postfilter(self, postfilter_data):
|
||||
for postfilter_params in postfilter_data:
|
||||
channel = postfilter_params["channel"]
|
||||
with QSignalBlocker(params[channel]):
|
||||
params[channel].child("Postfilter Config", "Rate").setValue(postfilter_params["rate"])
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("Postfilter Config", "Rate").setValue(postfilter_params["rate"])
|
||||
|
||||
|
||||
async def coro_main():
|
||||
|
|
Loading…
Reference in New Issue