ctrl_panel: Config -> Settings

This commit is contained in:
atse 2024-06-24 12:04:34 +08:00
parent 55a7583867
commit 9af4ffd125
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):
await self._client.save_config(ch)
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()
async def load_cfg(self, ch):
await self._client.load_config(ch)
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):

View File

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

View File

@ -14,7 +14,7 @@
"readonly": true
},
{
"name": "Output Config",
"name": "Output Settings",
"expanded": true,
"type": "group",
"children": [
@ -127,9 +127,10 @@
]
},
{
"name": "Thermistor Config",
"name": "Thermistor Settings",
"expanded": true,
"type": "group",
"tip": "Settings of the connected Thermistor",
"children": [
{
"name": "T₀",
@ -193,7 +194,7 @@
]
},
{
"name": "PID Config",
"name": "PID Settings",
"expanded": true,
"type": "group",
"children": [
@ -324,12 +325,12 @@
{
"name": "Save to flash",
"type": "action",
"tip": "Save config to thermostat, applies on reset"
"tip": "Save settings to thermostat, applies on reset"
},
{
"name": "Load from flash",
"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)],
[["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),
],
]
@ -312,18 +312,18 @@ class MainWindow(QtWidgets.QMainWindow):
match self.autotuners.get_state(ch):
case PIDAutotuneState.STATE_OFF:
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:
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)
case PIDAutotuneState.STATE_SUCCEEDED:
self.info_box.display_info_box(
"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()