Compare commits

...

6 Commits

3 changed files with 20 additions and 19 deletions

View File

@ -78,7 +78,7 @@ class WrappedClient(QObject, Client):
async def _read_line(self):
try:
return await super()._read_line()
except (OSError, TimeoutError, asyncio.TimeoutError) as e: # TODO: Remove asyncio.TimeoutError in Python 3.11
except (OSError, TimeoutError) as e:
logging.error("Client connection error, disconnecting", exc_info=True)
self.connection_error.emit()
@ -204,7 +204,8 @@ class ChannelGraphs:
self.t_setpoint_connector.cb_append_data_point(self._t_line.value(), time)
else:
self.t_setpoint_connector.cb_append_data_point(temperature, time)
self.i_connector.cb_append_data_point(current, time)
if current is not None:
self.i_connector.cb_append_data_point(current, time)
self.iset_connector.cb_append_data_point(iset, time)
def clear(self):
@ -230,7 +231,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
"""Thermostat parameters that are particular to a channel"""
THERMOSTAT_PARAMETERS = [[
{'name': 'Temperature', 'type': 'float', 'suffix': '°C', 'decimals': 6, 'readonly': True},
{'name': 'Temperature', 'type': 'float', 'format': '{value:.4f} °C', 'readonly': True},
{'name': 'Current through TEC', 'type': 'float', 'suffix': 'mA', 'decimals': 6, 'readonly': True},
{'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [
{'name': 'Control Method', 'type': 'mutex', 'limits': ['Constant Current', 'Temperature PID'],
@ -238,7 +239,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
{'name': 'Set Current', 'type': 'float', 'value': 0, 'step': 100, 'limits': (-3000, 3000), 'triggerOnShow': True,
'decimals': 6, 'suffix': 'mA', 'param': ('pwm', ch, 'i_set')},
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300),
'suffix': '°C', 'param': ('pid', ch, 'target')},
'format': '{value:.4f} °C', 'param': ('pid', ch, 'target')},
]},
{'name': 'Limits', 'expanded': False, 'type': 'group', 'children': [
{'name': 'Max Cooling Current', 'type': 'float', 'value': 0, 'step': 100, 'decimals': 6, 'limits': (0, 3000),
@ -251,12 +252,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
]},
{'name': 'Thermistor Config', 'expanded': False, 'type': 'group', 'children': [
{'name': 'T₀', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-100, 100),
'suffix': '°C', 'param': ('s-h', ch, 't0')},
'format': '{value:.4f} °C', 'param': ('s-h', ch, 't0')},
{'name': 'R₀', 'type': 'float', 'value': 10000, 'step': 1, 'siPrefix': True, 'suffix': 'Ω',
'param': ('s-h', ch, 'r0')},
{'name': 'B', 'type': 'float', 'value': 3950, 'step': 1, 'suffix': 'K', 'decimals': 4, 'param': ('s-h', ch, 'b')},
]},
{'name': 'Postfilter Config', 'expanded': False, 'type': 'group', 'children': [
{'name': 'Postfilter Rate', 'type': 'list', 'value': 16.67, 'param': ('postfilter', ch, 'rate'),
'limits': {'Off': None, '16.67 Hz': 16.67, '20 Hz': 20.0, '21.25 Hz': 21.25, '27 Hz': 27.0}},
]},
@ -264,12 +263,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
{'name': 'Kp', 'type': 'float', 'step': 0.1, 'suffix': '', 'param': ('pid', ch, 'kp')},
{'name': 'Ki', 'type': 'float', 'step': 0.1, 'suffix': 'Hz', 'param': ('pid', ch, 'ki')},
{'name': 'Kd', 'type': 'float', 'step': 0.1, 'suffix': 's', 'param': ('pid', ch, 'kd')},
{'name': 'Max Current Output', 'type': 'float', 'step': 100, 'limits': (-3000, 3000), 'decimals': 6, 'suffix': 'mA', 'param': ('pid', ch, 'output_max')},
{'name': 'Min Current Output', 'type': 'float', 'step': 100, 'limits': (-3000, 3000), 'decimals': 6, 'suffix': 'mA', 'param': ('pid', ch, 'output_min')},
{'name': "PID Output Clamping", 'expanded': True, 'type': 'group', 'children': [
{'name': 'Minimum', 'type': 'float', 'step': 100, 'limits': (-3000, 3000), 'decimals': 6, 'suffix': 'mA', 'param': ('pid', ch, 'output_min')},
{'name': 'Maximum', 'type': 'float', 'step': 100, 'limits': (-3000, 3000), 'decimals': 6, 'suffix': 'mA', 'param': ('pid', ch, 'output_max')},
]},
{'name': 'PID Auto Tune', 'expanded': False, 'type': 'group', 'children': [
{'name': 'Target Temperature', 'type': 'float', 'value': 20, 'step': 0.1, 'suffix': '°C'},
{'name': 'Target Temperature', 'type': 'float', 'value': 20, 'step': 0.1, 'format': '{value:.4f} °C'},
{'name': 'Test Current', 'type': 'float', 'value': 1000, 'decimals': 6, 'step': 100, 'limits': (-3000, 3000), 'suffix': 'mA'},
{'name': 'Temperature Swing', 'type': 'float', 'value': 1.5, 'step': 0.1, 'prefix': '±', 'suffix': '°C'},
{'name': 'Temperature Swing', 'type': 'float', 'value': 1.5, 'step': 0.1, 'prefix': '±', 'format': '{value:.4f} °C'},
{'name': 'Run', 'type': 'action', 'tip': 'Run'},
]},
]},
@ -689,7 +690,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
else:
await self.bail()
except (OSError, TimeoutError, asyncio.TimeoutError) as e: # TODO: Remove asyncio.TimeoutError in Python 3.11
except (OSError, TimeoutError) as e:
logging.error(f"Failed communicating to {host}:{port}: {e}")
await self.bail()
@ -825,8 +826,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
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"])
self.params[channel].child("PID Config", "Max Current Output").setValue(settings["parameters"]["output_max"] * 1000)
self.params[channel].child("PID Config", "Min Current Output").setValue(settings["parameters"]["output_min"] * 1000)
self.params[channel].child("PID Config", "PID Output Clamping", "Minimum").setValue(settings["parameters"]["output_min"] * 1000)
self.params[channel].child("PID Config", "PID Output Clamping", "Maximum").setValue(settings["parameters"]["output_max"] * 1000)
self.params[channel].child("Output Config", "Control Method", "Set Temperature").setValue(settings["target"])
self.channel_graphs[channel].set_t_line(temp=round(settings["target"], 6))
@ -874,7 +875,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
for postfilter_params in postfilter_data:
channel = postfilter_params["channel"]
with QSignalBlocker(self.params[channel]):
self.params[channel].child("Postfilter Config", "Postfilter Rate").setValue(postfilter_params["rate"])
self.params[channel].child("Thermistor Config", "Postfilter Rate").setValue(postfilter_params["rate"])
async def coro_main():

View File

@ -498,7 +498,7 @@
</action>
<action name="actionLoad_all_configs">
<property name="text">
<string>Load all configs</string>
<string>Load all channel configs from flash</string>
</property>
<property name="toolTip">
<string>Restore configuration for all channels from flash</string>
@ -509,7 +509,7 @@
</action>
<action name="actionSave_all_configs">
<property name="text">
<string>Save all configs</string>
<string>Save all channel configs to flash</string>
</property>
<property name="toolTip">
<string>Save configuration for all channels to flash</string>

View File

@ -249,9 +249,9 @@ class Ui_MainWindow(object):
self.actionNetwork_Settings.setToolTip(_translate("MainWindow", "Configure IPv4 address, netmask length, and optional default gateway"))
self.actionAbout_Thermostat.setText(_translate("MainWindow", "About Thermostat"))
self.actionAbout_Thermostat.setToolTip(_translate("MainWindow", "Show Thermostat hardware revision, and settings related to i"))
self.actionLoad_all_configs.setText(_translate("MainWindow", "Load all configs"))
self.actionLoad_all_configs.setText(_translate("MainWindow", "Load all channel configs from flash"))
self.actionLoad_all_configs.setToolTip(_translate("MainWindow", "Restore configuration for all channels from flash"))
self.actionSave_all_configs.setText(_translate("MainWindow", "Save all configs"))
self.actionSave_all_configs.setText(_translate("MainWindow", "Save all channel configs to flash"))
self.actionSave_all_configs.setToolTip(_translate("MainWindow", "Save configuration for all channels to flash"))
from pglive.sources.live_plot_widget import LivePlotWidget
from pyqtgraph.parametertree import ParameterTree