Add line at PID temp

This commit is contained in:
atse 2023-08-02 12:38:45 +08:00
parent 64891231cd
commit 8e98b62cfb
1 changed files with 14 additions and 1 deletions

View File

@ -29,7 +29,7 @@ THERMOSTAT_PARAMETERS = [[
{'name': 'Temperature PID', 'type': 'bool', 'value': False, 'commands': [f'pwm {ch} pid'], 'payload': ch,
'children': [
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), 'siPrefix': True,
'suffix': '°C', 'commands': [f'pid {ch} target {{value}}']},
'suffix': '°C', 'commands': [f'pid {ch} target {{value}}'], 'payload': ch},
]},
{'name': 'Output Config', 'expanded': False, 'type': 'group', 'children': [
{'name': 'Max Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 3), 'siPrefix': True,
@ -158,6 +158,11 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.ch1_t_plot = LiveLinePlot()
self.ch1_i_plot = LiveLinePlot()
self.ch0_t_line = self.ch0_t_graph.getPlotItem().addLine(label='{value} °C')
self.ch0_t_line.setVisible(False)
self.ch1_t_line = self.ch1_t_graph.getPlotItem().addLine(label='{value} °C')
self.ch1_t_line.setVisible(False)
self._set_up_graphs()
self.ch0_t_connector = DataConnector(self.ch0_t_plot, max_points=self.DEFAULT_MAX_SAMPLES)
@ -391,7 +396,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
if param.name() == 'Temperature PID' and not data:
ch = param.opts["payload"]
await self.tec_client.set_param('pwm', ch, 'i_set', params[ch].child('Constant Current').value())
line = getattr(self, f'ch{ch}_t_line')
line.setVisible(False)
elif param.opts.get("commands", None) is not None:
if param.name() == 'Temperature PID':
getattr(self, f'ch{param.opts["payload"]}_t_line').setVisible(True)
elif param.name() == 'Set Temperature':
getattr(self, f'ch{param.opts["payload"]}_t_line').setValue(data)
await asyncio.gather(*[self.tec_client._command(x.format(value=data)) for x in param.opts["commands"]])
def _set_param_tree(self):
@ -409,6 +420,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
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"])
getattr(self, f'ch{channel}_t_line').setValue(settings["target"])
@pyqtSlot(list)
def update_report(self, report_data):
@ -416,6 +428,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
channel = settings["channel"]
with QSignalBlocker(params[channel]):
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"])