ctrl_panel: Config -> Settings

This commit is contained in:
atse 2024-06-24 12:04:34 +08:00
parent 0f14212622
commit 7829ce6adf
4 changed files with 29 additions and 26 deletions

View File

@ -117,14 +117,14 @@ class Thermostat(QObject, metaclass=PropertyMeta):
async def save_cfg(self, ch): async def save_cfg(self, ch):
await self._client.save_config(ch) await self._client.save_config(ch)
self.info_box_trigger.emit( self.info_box_trigger.emit(
"Config saved", f"Channel {ch} Config has been saved from flash." "Settings saved", f"Channel {ch} Settings has been saved to flash."
) )
@asyncSlot() @asyncSlot()
async def load_cfg(self, ch): async def load_cfg(self, ch):
await self._client.load_config(ch) await self._client.load_config(ch)
self.info_box_trigger.emit( self.info_box_trigger.emit(
"Config loaded", f"Channel {ch} Config has been loaded from flash." "Settings loaded", f"Channel {ch} Settings has been loaded from flash."
) )
async def dfu(self): async def dfu(self):

View File

@ -116,23 +116,23 @@ class CtrlPanel(QObject):
for settings in pid_settings: for settings in pid_settings:
channel = settings["channel"] channel = settings["channel"]
with QSignalBlocker(self.params[channel]): with QSignalBlocker(self.params[channel]):
self.params[channel].child("PID Config", "Kp").setValue( self.params[channel].child("PID Settings", "Kp").setValue(
settings["parameters"]["kp"] settings["parameters"]["kp"]
) )
self.params[channel].child("PID Config", "Ki").setValue( self.params[channel].child("PID Settings", "Ki").setValue(
settings["parameters"]["ki"] settings["parameters"]["ki"]
) )
self.params[channel].child("PID Config", "Kd").setValue( self.params[channel].child("PID Settings", "Kd").setValue(
settings["parameters"]["kd"] settings["parameters"]["kd"]
) )
self.params[channel].child( self.params[channel].child(
"PID Config", "PID Output Clamping", "Minimum" "PID Settings", "PID Output Clamping", "Minimum"
).setValue(settings["parameters"]["output_min"] * 1000) ).setValue(settings["parameters"]["output_min"] * 1000)
self.params[channel].child( self.params[channel].child(
"PID Config", "PID Output Clamping", "Maximum" "PID Settings", "PID Output Clamping", "Maximum"
).setValue(settings["parameters"]["output_max"] * 1000) ).setValue(settings["parameters"]["output_max"] * 1000)
self.params[channel].child( self.params[channel].child(
"Output Config", "Control Method", "Set Temperature" "Output Settings", "Control Method", "Set Temperature"
).setValue(settings["target"]) ).setValue(settings["target"])
@pyqtSlot("QVariantList") @pyqtSlot("QVariantList")
@ -140,11 +140,13 @@ class CtrlPanel(QObject):
for settings in report_data: for settings in report_data:
channel = settings["channel"] channel = settings["channel"]
with QSignalBlocker(self.params[channel]): with QSignalBlocker(self.params[channel]):
self.params[channel].child("Output Config", "Control Method").setValue( self.params[channel].child(
"Output Settings", "Control Method"
).setValue(
"Temperature PID" if settings["pid_engaged"] else "Constant Current" "Temperature PID" if settings["pid_engaged"] else "Constant Current"
) )
self.params[channel].child( self.params[channel].child(
"Output Config", "Control Method", "Set Current" "Output Settings", "Control Method", "Set Current"
).setValue(settings["i_set"] * 1000) ).setValue(settings["i_set"] * 1000)
if settings["temperature"] is not None: if settings["temperature"] is not None:
self.params[channel].child("Temperature").setValue( self.params[channel].child("Temperature").setValue(
@ -160,13 +162,13 @@ class CtrlPanel(QObject):
for sh_param in sh_data: for sh_param in sh_data:
channel = sh_param["channel"] channel = sh_param["channel"]
with QSignalBlocker(self.params[channel]): with QSignalBlocker(self.params[channel]):
self.params[channel].child("Thermistor Config", "T₀").setValue( self.params[channel].child("Thermistor Settings", "T₀").setValue(
sh_param["params"]["t0"] - 273.15 sh_param["params"]["t0"] - 273.15
) )
self.params[channel].child("Thermistor Config", "R₀").setValue( self.params[channel].child("Thermistor Settings", "R₀").setValue(
sh_param["params"]["r0"] sh_param["params"]["r0"]
) )
self.params[channel].child("Thermistor Config", "B").setValue( self.params[channel].child("Thermistor Settings", "B").setValue(
sh_param["params"]["b"] sh_param["params"]["b"]
) )
@ -178,13 +180,13 @@ class CtrlPanel(QObject):
channel = pwm_params["channel"] channel = pwm_params["channel"]
with QSignalBlocker(self.params[channel]): with QSignalBlocker(self.params[channel]):
self.params[channel].child( self.params[channel].child(
"Output Config", "Limits", "Max Voltage Difference" "Output Settings", "Limits", "Max Voltage Difference"
).setValue(pwm_params["max_v"]["value"]) ).setValue(pwm_params["max_v"]["value"])
self.params[channel].child( self.params[channel].child(
"Output Config", "Limits", "Max Cooling Current" "Output Settings", "Limits", "Max Cooling Current"
).setValue(pwm_params["max_i_pos"]["value"] * 1000) ).setValue(pwm_params["max_i_pos"]["value"] * 1000)
self.params[channel].child( self.params[channel].child(
"Output Config", "Limits", "Max Heating Current" "Output Settings", "Limits", "Max Heating Current"
).setValue(pwm_params["max_i_neg"]["value"] * 1000) ).setValue(pwm_params["max_i_neg"]["value"] * 1000)
for limit in "max_i_pos", "max_i_neg", "max_v": for limit in "max_i_pos", "max_i_neg", "max_v":
@ -198,5 +200,5 @@ class CtrlPanel(QObject):
channel = postfilter_params["channel"] channel = postfilter_params["channel"]
with QSignalBlocker(self.params[channel]): with QSignalBlocker(self.params[channel]):
self.params[channel].child( self.params[channel].child(
"Thermistor Config", "Postfilter Rate" "Thermistor Settings", "Postfilter Rate"
).setValue(postfilter_params["rate"]) ).setValue(postfilter_params["rate"])

View File

@ -14,7 +14,7 @@
"readonly": true "readonly": true
}, },
{ {
"name": "Output Config", "name": "Output Settings",
"expanded": true, "expanded": true,
"type": "group", "type": "group",
"children": [ "children": [
@ -136,9 +136,10 @@
] ]
}, },
{ {
"name": "Thermistor Config", "name": "Thermistor Settings",
"expanded": true, "expanded": true,
"type": "group", "type": "group",
"tip": "Settings of the connected Thermistor",
"children": [ "children": [
{ {
"name": "T₀", "name": "T₀",
@ -206,7 +207,7 @@
] ]
}, },
{ {
"name": "PID Config", "name": "PID Settings",
"expanded": true, "expanded": true,
"type": "group", "type": "group",
"children": [ "children": [
@ -354,12 +355,12 @@
{ {
"name": "Save to flash", "name": "Save to flash",
"type": "action", "type": "action",
"tip": "Save config to thermostat, applies on reset" "tip": "Save settings to thermostat, applies on reset"
}, },
{ {
"name": "Load from flash", "name": "Load from flash",
"type": "action", "type": "action",
"tip": "Load config from flash" "tip": "Load settings from flash"
} }
] ]
} }

View File

@ -81,7 +81,7 @@ class MainWindow(QtWidgets.QMainWindow):
[["Save to flash"], partial(self.thermostat.save_cfg, ch)], [["Save to flash"], partial(self.thermostat.save_cfg, ch)],
[["Load from flash"], partial(self.thermostat.load_cfg, ch)], [["Load from flash"], partial(self.thermostat.load_cfg, ch)],
[ [
["PID Config", "PID Auto Tune", "Run"], ["PID Settings", "PID Auto Tune", "Run"],
partial(self.pid_auto_tune_request, ch), partial(self.pid_auto_tune_request, ch),
], ],
] ]
@ -315,18 +315,18 @@ class MainWindow(QtWidgets.QMainWindow):
match self.autotuners.get_state(ch): match self.autotuners.get_state(ch):
case PIDAutotuneState.STATE_OFF: case PIDAutotuneState.STATE_OFF:
self.ctrl_panel_view.change_params_title( self.ctrl_panel_view.change_params_title(
ch, ("PID Config", "PID Auto Tune", "Run"), "Run" ch, ("PID Settings", "PID Auto Tune", "Run"), "Run"
) )
case PIDAutotuneState.STATE_READY | PIDAutotuneState.STATE_RELAY_STEP_UP | PIDAutotuneState.STATE_RELAY_STEP_DOWN: case PIDAutotuneState.STATE_READY | PIDAutotuneState.STATE_RELAY_STEP_UP | PIDAutotuneState.STATE_RELAY_STEP_DOWN:
self.ctrl_panel_view.change_params_title( self.ctrl_panel_view.change_params_title(
ch, ("PID Config", "PID Auto Tune", "Run"), "Stop" ch, ("PID Settings", "PID Auto Tune", "Run"), "Stop"
) )
ch_tuning.append(ch) ch_tuning.append(ch)
case PIDAutotuneState.STATE_SUCCEEDED: case PIDAutotuneState.STATE_SUCCEEDED:
self.info_box.display_info_box( self.info_box.display_info_box(
"PID Autotune Success", "PID Autotune Success",
f"Channel {ch} PID Config has been loaded to Thermostat. Regulating temperature.", f"Channel {ch} PID Settings has been loaded to Thermostat. Regulating temperature.",
) )
self.info_box.show() self.info_box.show()