forked from M-Labs/thermostat
Compare commits
13 Commits
3552a582f8
...
21eb13ed6f
Author | SHA1 | Date | |
---|---|---|---|
21eb13ed6f | |||
646452f559 | |||
46a22a9c32 | |||
8ec7bb833a | |||
02d04dbae5 | |||
85ff340b6f | |||
d844c02a3a | |||
8a4d861672 | |||
b668c699fb | |||
eb3719044f | |||
8ac4a32106 | |||
493088f4a5 | |||
2ae58b9abb |
@ -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 loaded", f"Channel {ch} Config has been loaded from flash."
|
||||
"Settings loaded", f"Channel {ch} Settings has been loaded 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):
|
||||
|
@ -6,40 +6,11 @@ from pyqtgraph.parametertree import (
|
||||
)
|
||||
|
||||
|
||||
class MutexParameter(pTypes.ListParameter):
|
||||
"""
|
||||
Mutually exclusive parameter where only one of its children is visible at a time, list selectable.
|
||||
|
||||
The ordering of the list items determines which children will be visible.
|
||||
"""
|
||||
|
||||
def __init__(self, **opts):
|
||||
super().__init__(**opts)
|
||||
|
||||
self.sigValueChanged.connect(self.show_chosen_child)
|
||||
self.sigValueChanged.emit(self, self.opts["value"])
|
||||
|
||||
def _get_param_from_value(self, value):
|
||||
if isinstance(self.opts["limits"], dict):
|
||||
values_list = list(self.opts["limits"].values())
|
||||
else:
|
||||
values_list = self.opts["limits"]
|
||||
|
||||
return self.children()[values_list.index(value)]
|
||||
|
||||
@pyqtSlot(object, object)
|
||||
def show_chosen_child(self, value):
|
||||
for param in self.children():
|
||||
param.hide()
|
||||
|
||||
child_to_show = self._get_param_from_value(value.value())
|
||||
child_to_show.show()
|
||||
|
||||
if child_to_show.opts.get("triggerOnShow", None):
|
||||
child_to_show.sigValueChanged.emit(child_to_show, child_to_show.value())
|
||||
|
||||
|
||||
registerParameterType("mutex", MutexParameter)
|
||||
def set_tree_label_tips(tree):
|
||||
for item in tree.listAllItems():
|
||||
p = item.param
|
||||
if "tip" in p.opts:
|
||||
item.setToolTip(0, p.opts["tip"])
|
||||
|
||||
|
||||
class CtrlPanel(QObject):
|
||||
@ -58,29 +29,40 @@ class CtrlPanel(QObject):
|
||||
self.trees_ui = trees_ui
|
||||
self.NUM_CHANNELS = len(trees_ui)
|
||||
|
||||
self.THERMOSTAT_PARAMETERS = [param_tree for i in range(self.NUM_CHANNELS)]
|
||||
|
||||
self.params = [
|
||||
Parameter.create(
|
||||
name=f"Thermostat Channel {ch} Parameters",
|
||||
type="group",
|
||||
value=ch,
|
||||
children=self.THERMOSTAT_PARAMETERS[ch],
|
||||
children=param_tree,
|
||||
)
|
||||
for ch in range(self.NUM_CHANNELS)
|
||||
]
|
||||
|
||||
for i, param in enumerate(self.params):
|
||||
param.channel = i
|
||||
|
||||
for i, tree in enumerate(self.trees_ui):
|
||||
for ch, tree in enumerate(self.trees_ui):
|
||||
tree.setHeaderHidden(True)
|
||||
tree.setParameters(self.params[i], showTop=False)
|
||||
self.params[i].setValue = self._setValue
|
||||
self.params[i].sigTreeStateChanged.connect(sigTreeStateChanged_handle)
|
||||
tree.setParameters(self.params[ch], showTop=False)
|
||||
|
||||
for handle in sigActivated_handles[i]:
|
||||
self.params[i].child(*handle[0]).sigActivated.connect(handle[1])
|
||||
set_tree_label_tips(tree)
|
||||
|
||||
for ch, param in enumerate(self.params):
|
||||
self.params[ch].setValue = self._setValue
|
||||
param.sigTreeStateChanged.connect(sigTreeStateChanged_handle)
|
||||
|
||||
for handle in sigActivated_handles[ch]:
|
||||
param.child(*handle[0]).sigActivated.connect(handle[1])
|
||||
|
||||
param.child("output", "control_method").sigValueChanged.connect(
|
||||
lambda param, value: param.child("i_set").setWritable(
|
||||
value == "constant_current"
|
||||
)
|
||||
)
|
||||
|
||||
param.child("output", "control_method").sigValueChanged.connect(
|
||||
lambda param, value: param.child("target").show(
|
||||
value == "temperature_pid"
|
||||
)
|
||||
)
|
||||
|
||||
def _setValue(self, value, blockSignal=None):
|
||||
"""
|
||||
@ -116,23 +98,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", "kp").setValue(
|
||||
settings["parameters"]["kp"]
|
||||
)
|
||||
self.params[channel].child("PID Config", "Ki").setValue(
|
||||
self.params[channel].child("pid", "ki").setValue(
|
||||
settings["parameters"]["ki"]
|
||||
)
|
||||
self.params[channel].child("PID Config", "Kd").setValue(
|
||||
self.params[channel].child("pid", "kd").setValue(
|
||||
settings["parameters"]["kd"]
|
||||
)
|
||||
self.params[channel].child(
|
||||
"PID Config", "PID Output Clamping", "Minimum"
|
||||
"pid", "pid_output_clamping", "output_min"
|
||||
).setValue(settings["parameters"]["output_min"] * 1000)
|
||||
self.params[channel].child(
|
||||
"PID Config", "PID Output Clamping", "Maximum"
|
||||
"pid", "pid_output_clamping", "output_max"
|
||||
).setValue(settings["parameters"]["output_max"] * 1000)
|
||||
self.params[channel].child(
|
||||
"Output Config", "Control Method", "Set Temperature"
|
||||
"output", "control_method", "target"
|
||||
).setValue(settings["target"])
|
||||
|
||||
@pyqtSlot("QVariantList")
|
||||
@ -140,19 +122,19 @@ 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(
|
||||
"Temperature PID" if settings["pid_engaged"] else "Constant Current"
|
||||
self.params[channel].child("output", "control_method").setValue(
|
||||
"temperature_pid" if settings["pid_engaged"] else "constant_current"
|
||||
)
|
||||
self.params[channel].child(
|
||||
"Output Config", "Control Method", "Set Current"
|
||||
"output", "control_method", "i_set"
|
||||
).setValue(settings["i_set"] * 1000)
|
||||
if settings["temperature"] is not None:
|
||||
self.params[channel].child("Temperature").setValue(
|
||||
self.params[channel].child("temperature").setValue(
|
||||
settings["temperature"]
|
||||
)
|
||||
if settings["tec_i"] is not None:
|
||||
self.params[channel].child("Current through TEC").setValue(
|
||||
settings["tec_i"] * 1000
|
||||
self.params[channel].child("tec_i").setValue(
|
||||
settings["tec_i"]
|
||||
)
|
||||
|
||||
@pyqtSlot("QVariantList")
|
||||
@ -160,13 +142,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", "t0").setValue(
|
||||
sh_param["params"]["t0"] - 273.15
|
||||
)
|
||||
self.params[channel].child("Thermistor Config", "R₀").setValue(
|
||||
self.params[channel].child("thermistor", "r0").setValue(
|
||||
sh_param["params"]["r0"]
|
||||
)
|
||||
self.params[channel].child("Thermistor Config", "B").setValue(
|
||||
self.params[channel].child("thermistor", "b").setValue(
|
||||
sh_param["params"]["b"]
|
||||
)
|
||||
|
||||
@ -177,15 +159,15 @@ class CtrlPanel(QObject):
|
||||
for pwm_params in pwm_data:
|
||||
channel = pwm_params["channel"]
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child(
|
||||
"Output Config", "Limits", "Max Voltage Difference"
|
||||
).setValue(pwm_params["max_v"]["value"])
|
||||
self.params[channel].child(
|
||||
"Output Config", "Limits", "Max Cooling Current"
|
||||
).setValue(pwm_params["max_i_pos"]["value"] * 1000)
|
||||
self.params[channel].child(
|
||||
"Output Config", "Limits", "Max Heating Current"
|
||||
).setValue(pwm_params["max_i_neg"]["value"] * 1000)
|
||||
self.params[channel].child("output", "limits", "max_v").setValue(
|
||||
pwm_params["max_v"]["value"]
|
||||
)
|
||||
self.params[channel].child("output", "limits", "max_i_pos").setValue(
|
||||
pwm_params["max_i_pos"]["value"] * 1000
|
||||
)
|
||||
self.params[channel].child("output", "limits", "max_i_neg").setValue(
|
||||
pwm_params["max_i_neg"]["value"] * 1000
|
||||
)
|
||||
|
||||
for limit in "max_i_pos", "max_i_neg", "max_v":
|
||||
if pwm_params[limit]["value"] == 0.0:
|
||||
@ -197,6 +179,6 @@ class CtrlPanel(QObject):
|
||||
for postfilter_params in postfilter_data:
|
||||
channel = postfilter_params["channel"]
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child(
|
||||
"Thermistor Config", "Postfilter Rate"
|
||||
).setValue(postfilter_params["rate"])
|
||||
self.params[channel].child("thermistor", "rate").setValue(
|
||||
postfilter_params["rate"]
|
||||
)
|
||||
|
@ -1,30 +1,38 @@
|
||||
{
|
||||
"ctrl_panel": [
|
||||
{
|
||||
"name":"Temperature",
|
||||
"name": "temperature",
|
||||
"title": "Temperature",
|
||||
"type": "float",
|
||||
"format": "{value:.4f} °C",
|
||||
"readonly":true
|
||||
"readonly": true,
|
||||
"tip": "The measured temperature at the thermistor"
|
||||
},
|
||||
{
|
||||
"name":"Current through TEC",
|
||||
"name": "tec_i",
|
||||
"title": "Current through TEC",
|
||||
"type": "float",
|
||||
"suffix":"mA",
|
||||
"siPrefix": true,
|
||||
"suffix": "A",
|
||||
"decimals": 6,
|
||||
"readonly":true
|
||||
"readonly": true,
|
||||
"tip": "The measured current through the TEC"
|
||||
},
|
||||
{
|
||||
"name":"Output Config",
|
||||
"name": "output",
|
||||
"title": "Output Settings",
|
||||
"expanded": true,
|
||||
"type": "group",
|
||||
"tip": "Settings of the output to the TEC",
|
||||
"children": [
|
||||
{
|
||||
"name":"Control Method",
|
||||
"type":"mutex",
|
||||
"limits":[
|
||||
"Constant Current",
|
||||
"Temperature PID"
|
||||
],
|
||||
"name": "control_method",
|
||||
"title": "Control Method",
|
||||
"type": "list",
|
||||
"limits": {
|
||||
"Constant Current": "constant_current",
|
||||
"Temperature PID": "temperature_pid"
|
||||
},
|
||||
"activaters": [
|
||||
null,
|
||||
[
|
||||
@ -33,9 +41,11 @@
|
||||
"pid"
|
||||
]
|
||||
],
|
||||
"tip": "Select control method of output",
|
||||
"children": [
|
||||
{
|
||||
"name":"Set Current",
|
||||
"name": "i_set",
|
||||
"title": "Set Current (mA)",
|
||||
"type": "float",
|
||||
"value": 0,
|
||||
"step": 100,
|
||||
@ -45,90 +55,103 @@
|
||||
],
|
||||
"triggerOnShow": true,
|
||||
"decimals": 6,
|
||||
"suffix":"mA",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pwm",
|
||||
"ch",
|
||||
"i_set"
|
||||
],
|
||||
"tip": "The set current through TEC",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"Set Temperature",
|
||||
"name": "target",
|
||||
"title": "Setpoint (°C)",
|
||||
"type": "float",
|
||||
"visible": false,
|
||||
"value": 25,
|
||||
"step": 0.1,
|
||||
"limits": [
|
||||
-273,
|
||||
300
|
||||
],
|
||||
"format":"{value:.4f} °C",
|
||||
"format": "{value:.4f}",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pid",
|
||||
"ch",
|
||||
"target"
|
||||
],
|
||||
"tip": "The temperature setpoint of the TEC",
|
||||
"lock": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"Limits",
|
||||
"name": "limits",
|
||||
"title": "Limits",
|
||||
"expanded": true,
|
||||
"type": "group",
|
||||
"tip": "The limits of output, with the polarity at the front panel as reference",
|
||||
"children": [
|
||||
{
|
||||
"name":"Max Cooling Current",
|
||||
"name": "max_i_pos",
|
||||
"title": "Max Cooling Current (mA)",
|
||||
"type": "float",
|
||||
"value": 0,
|
||||
"step": 100,
|
||||
"decimals": 6,
|
||||
"compactHeight": false,
|
||||
"limits": [
|
||||
0,
|
||||
2000
|
||||
],
|
||||
"suffix":"mA",
|
||||
"param": [
|
||||
"pwm",
|
||||
"ch",
|
||||
"max_i_pos"
|
||||
],
|
||||
"tip": "The maximum cooling (+ve) current through the output pins",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"Max Heating Current",
|
||||
"name": "max_i_neg",
|
||||
"title": "Max Heating Current (mA)",
|
||||
"type": "float",
|
||||
"value": 0,
|
||||
"step": 100,
|
||||
"decimals": 6,
|
||||
"compactHeight": false,
|
||||
"limits": [
|
||||
0,
|
||||
2000
|
||||
],
|
||||
"suffix":"mA",
|
||||
"param": [
|
||||
"pwm",
|
||||
"ch",
|
||||
"max_i_neg"
|
||||
],
|
||||
"tip": "The maximum heating (-ve) current through the output pins",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"Max Voltage Difference",
|
||||
"name": "max_v",
|
||||
"title": "Max Absolute Voltage (V)",
|
||||
"type": "float",
|
||||
"value": 0,
|
||||
"step": 0.1,
|
||||
"limits": [
|
||||
0,
|
||||
5
|
||||
4
|
||||
],
|
||||
"siPrefix": true,
|
||||
"suffix":"V",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pwm",
|
||||
"ch",
|
||||
"max_v"
|
||||
],
|
||||
"tip": "The maximum voltage (in both directions) across the output pins",
|
||||
"lock": false
|
||||
}
|
||||
]
|
||||
@ -136,12 +159,15 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"Thermistor Config",
|
||||
"name": "thermistor",
|
||||
"title": "Thermistor Settings",
|
||||
"expanded": true,
|
||||
"type": "group",
|
||||
"tip": "Settings of the connected thermistor\n- Parameters for the resistance to temperature conversion (with the B-Parameter equation)\n- Settings for the 50/60 Hz filter with the thermistor",
|
||||
"children": [
|
||||
{
|
||||
"name":"T₀",
|
||||
"name": "t0",
|
||||
"title": "T₀ (°C)",
|
||||
"type": "float",
|
||||
"value": 25,
|
||||
"step": 0.1,
|
||||
@ -149,44 +175,51 @@
|
||||
-100,
|
||||
100
|
||||
],
|
||||
"format":"{value:.4f} °C",
|
||||
"format": "{value:.4f}",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"s-h",
|
||||
"ch",
|
||||
"t0"
|
||||
],
|
||||
"tip": "The base temperature",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"R₀",
|
||||
"name": "r0",
|
||||
"title": "R₀ (Ω)",
|
||||
"type": "float",
|
||||
"value": 10000,
|
||||
"step": 1,
|
||||
"siPrefix": true,
|
||||
"suffix":"Ω",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"s-h",
|
||||
"ch",
|
||||
"r0"
|
||||
],
|
||||
"tip": "The resistance of the thermistor at base temperature T₀",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"B",
|
||||
"name": "b",
|
||||
"title": "B (K)",
|
||||
"type": "float",
|
||||
"value": 3950,
|
||||
"step": 1,
|
||||
"suffix":"K",
|
||||
"decimals": 4,
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"s-h",
|
||||
"ch",
|
||||
"b"
|
||||
],
|
||||
"tip": "The Beta Parameter",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"Postfilter Rate",
|
||||
"name": "rate",
|
||||
"title": "50/60 Hz filter rejection",
|
||||
"type": "list",
|
||||
"value": 16.67,
|
||||
"param": [
|
||||
@ -196,63 +229,76 @@
|
||||
],
|
||||
"limits": {
|
||||
"Off": null,
|
||||
"16.67 Hz":16.67,
|
||||
"20 Hz":20.0,
|
||||
"21.25 Hz":21.25,
|
||||
"27 Hz":27.0
|
||||
"47 dB @ 10.41 Hz": 27.0,
|
||||
"62 dB @ 9.1 Hz": 21.25,
|
||||
"86 dB @ 10 Hz": 20.0,
|
||||
"92 dB @ 8.4 Hz": 16.67
|
||||
},
|
||||
"tip": "Trade off effective sampling rate and rejection of (50±1) Hz and (60±1) Hz",
|
||||
"lock": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"PID Config",
|
||||
"name": "pid",
|
||||
"title": "PID Settings",
|
||||
"expanded": true,
|
||||
"type": "group",
|
||||
"tip": "Settings of PID parameters and clamping",
|
||||
"children": [
|
||||
{
|
||||
"name":"Kp",
|
||||
"name": "kp",
|
||||
"title": "Kp",
|
||||
"type": "float",
|
||||
"step": 0.1,
|
||||
"suffix": "",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pid",
|
||||
"ch",
|
||||
"kp"
|
||||
],
|
||||
"tip": "Proportional gain",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"Ki",
|
||||
"name": "ki",
|
||||
"title": "Ki (Hz)",
|
||||
"type": "float",
|
||||
"step": 0.1,
|
||||
"suffix":"Hz",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pid",
|
||||
"ch",
|
||||
"ki"
|
||||
],
|
||||
"tip": "Integral gain",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"Kd",
|
||||
"name": "kd",
|
||||
"title": "Kd (s)",
|
||||
"type": "float",
|
||||
"step": 0.1,
|
||||
"suffix":"s",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pid",
|
||||
"ch",
|
||||
"kd"
|
||||
],
|
||||
"tip": "Differential gain",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"PID Output Clamping",
|
||||
"name": "pid_output_clamping",
|
||||
"title": "PID Output Clamping",
|
||||
"expanded": true,
|
||||
"type": "group",
|
||||
"tip": "Clamps PID outputs to specified range\nCould be different than output limits",
|
||||
"children": [
|
||||
{
|
||||
"name":"Minimum",
|
||||
"name": "output_min",
|
||||
"title": "Minimum (mA)",
|
||||
"type": "float",
|
||||
"step": 100,
|
||||
"limits": [
|
||||
@ -260,16 +306,18 @@
|
||||
2000
|
||||
],
|
||||
"decimals": 6,
|
||||
"suffix":"mA",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pid",
|
||||
"ch",
|
||||
"output_min"
|
||||
],
|
||||
"tip": "Minimum PID output",
|
||||
"lock": false
|
||||
},
|
||||
{
|
||||
"name":"Maximum",
|
||||
"name": "output_max",
|
||||
"title": "Maximum (mA)",
|
||||
"type": "float",
|
||||
"step": 100,
|
||||
"limits": [
|
||||
@ -277,89 +325,106 @@
|
||||
2000
|
||||
],
|
||||
"decimals": 6,
|
||||
"suffix":"mA",
|
||||
"compactHeight": false,
|
||||
"param": [
|
||||
"pid",
|
||||
"ch",
|
||||
"output_max"
|
||||
],
|
||||
"tip": "Maximum PID output",
|
||||
"lock": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"PID Auto Tune",
|
||||
"name": "pid_autotune",
|
||||
"title": "PID Autotune",
|
||||
"expanded": false,
|
||||
"type": "group",
|
||||
"tip": "Automatically tune PID parameters",
|
||||
"children": [
|
||||
{
|
||||
"name":"Target Temperature",
|
||||
"name": "target_temp",
|
||||
"title": "Target Temperature (°C)",
|
||||
"type": "float",
|
||||
"value": 20,
|
||||
"step": 0.1,
|
||||
"format":"{value:.4f} °C",
|
||||
"format": "{value:.4f}",
|
||||
"compactHeight": false,
|
||||
"pid_autotune": [
|
||||
"target_temp",
|
||||
"ch"
|
||||
]
|
||||
],
|
||||
"tip": "The target temperature to autotune for"
|
||||
},
|
||||
{
|
||||
"name":"Test Current",
|
||||
"name": "test_current",
|
||||
"title": "Test Current (mA)",
|
||||
"type": "float",
|
||||
"value": 0,
|
||||
"decimals": 6,
|
||||
"compactHeight": false,
|
||||
"step": 100,
|
||||
"limits": [
|
||||
-2000,
|
||||
0,
|
||||
2000
|
||||
],
|
||||
"suffix":"mA",
|
||||
"pid_autotune": [
|
||||
"test_current",
|
||||
"ch"
|
||||
]
|
||||
],
|
||||
"tip": "The testing current when autotuning"
|
||||
},
|
||||
{
|
||||
"name":"Temperature Swing",
|
||||
"name": "temp_swing",
|
||||
"title": "Temperature Swing (°C)",
|
||||
"type": "float",
|
||||
"value": 1.5,
|
||||
"step": 0.1,
|
||||
"prefix": "±",
|
||||
"format":"{value:.4f} °C",
|
||||
"format": "{value:.4f}",
|
||||
"compactHeight": false,
|
||||
"pid_autotune": [
|
||||
"temp_swing",
|
||||
"ch"
|
||||
]
|
||||
],
|
||||
"tip": "The temperature swing around the target"
|
||||
},
|
||||
{
|
||||
"name":"Lookback",
|
||||
"name": "lookback",
|
||||
"title": "Lookback (s)",
|
||||
"type": "float",
|
||||
"value": 3.0,
|
||||
"step": 0.1,
|
||||
"format":"{value:.4f} s",
|
||||
"format": "{value:.4f}",
|
||||
"compactHeight": false,
|
||||
"pid_autotune": [
|
||||
"lookback",
|
||||
"ch"
|
||||
]
|
||||
],
|
||||
"tip": "Amount of time referenced for tuning"
|
||||
},
|
||||
{
|
||||
"name":"Run",
|
||||
"name": "run_pid",
|
||||
"title": "Run",
|
||||
"type": "action",
|
||||
"tip":"Run"
|
||||
"tip": "Run PID Autotune with above settings"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"Save to flash",
|
||||
"name": "save",
|
||||
"title": "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",
|
||||
"name": "load",
|
||||
"title": "Load from flash",
|
||||
"type": "action",
|
||||
"tip":"Load config from flash"
|
||||
"tip": "Load settings from thermostat"
|
||||
}
|
||||
]
|
||||
}
|
@ -78,11 +78,11 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
param_tree_sigActivated_handles = [
|
||||
[
|
||||
[["Save to flash"], partial(self.thermostat.save_cfg, ch)],
|
||||
[["Load from flash"], partial(self.thermostat.load_cfg, ch)],
|
||||
[["save"], partial(self.thermostat.save_cfg, ch)],
|
||||
[["load"], partial(self.thermostat.load_cfg, ch)],
|
||||
[
|
||||
["PID Config", "PID Auto Tune", "Run"],
|
||||
partial(self.pid_auto_tune_request, ch),
|
||||
["pid", "pid_autotune", "run_pid"],
|
||||
partial(self.pid_autotune_request, ch),
|
||||
],
|
||||
]
|
||||
for ch in range(self.NUM_CHANNELS)
|
||||
@ -262,19 +262,19 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
@asyncSlot(object, object)
|
||||
async def send_command(self, param, changes):
|
||||
"""Translates parameter tree changes into thermostat set_param calls"""
|
||||
ch = param.channel
|
||||
ch = param.value()
|
||||
|
||||
for inner_param, change, data in changes:
|
||||
if change == "value":
|
||||
if inner_param.opts.get("param", None) is not None:
|
||||
if inner_param.opts.get("suffix", None) == "mA":
|
||||
if inner_param.opts.get("title", None).endswith(" (mA)"):
|
||||
data /= 1000 # Given in mA
|
||||
|
||||
thermostat_param = inner_param.opts["param"]
|
||||
if thermostat_param[1] == "ch":
|
||||
thermostat_param[1] = ch
|
||||
|
||||
if inner_param.name() == "Postfilter Rate" and data is None:
|
||||
if inner_param.name() == "rate" and data is None:
|
||||
set_param_args = (*thermostat_param[:2], "off")
|
||||
else:
|
||||
set_param_args = (*thermostat_param, data)
|
||||
@ -283,14 +283,14 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
param.child(*param.childPath(inner_param)).setOpts(lock=False)
|
||||
|
||||
if inner_param.opts.get("pid_autotune", None) is not None:
|
||||
auto_tuner_param = inner_param.opts["pid_autotune"][0]
|
||||
autotuner_param = inner_param.opts["pid_autotune"][0]
|
||||
if inner_param.opts["pid_autotune"][1] != "ch":
|
||||
ch = inner_param.opts["pid_autotune"][1]
|
||||
self.autotuners.set_params(auto_tuner_param, ch, data)
|
||||
self.autotuners.set_params(autotuner_param, ch, data)
|
||||
|
||||
if inner_param.opts.get("activaters", None) is not None:
|
||||
activater = inner_param.opts["activaters"][
|
||||
inner_param.opts["limits"].index(data)
|
||||
inner_param.reverse[0].index(data) # ListParameter.reverse = list of codename values
|
||||
]
|
||||
if activater is not None:
|
||||
if activater[1] == "ch":
|
||||
@ -298,7 +298,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
await self.client.set_param(*activater)
|
||||
|
||||
@asyncSlot()
|
||||
async def pid_auto_tune_request(self, ch=0):
|
||||
async def pid_autotune_request(self, ch=0):
|
||||
match self.autotuners.get_state(ch):
|
||||
case PIDAutotuneState.STATE_OFF | PIDAutotuneState.STATE_FAILED:
|
||||
self.autotuners.load_params_and_set_ready(ch)
|
||||
@ -315,18 +315,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", "pid_autotune", "run_pid"), "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", "pid_autotune", "run_pid"), "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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user