forked from M-Labs/thermostat
send_command: Better maps to thermostat commands
* Use a `dict` to map values to thermostat parameters. New tag "thermostat:set_param" used in JSON. * Remove "activater" option and interpret commands anomalies directly in send_command
This commit is contained in:
parent
d70ba8aaa0
commit
2548746fc6
@ -33,14 +33,10 @@
|
|||||||
"Constant Current": "constant_current",
|
"Constant Current": "constant_current",
|
||||||
"Temperature PID": "temperature_pid"
|
"Temperature PID": "temperature_pid"
|
||||||
},
|
},
|
||||||
"activaters": [
|
"thermostat:set_param": {
|
||||||
null,
|
"topic": "pwm",
|
||||||
[
|
"field": "pid"
|
||||||
"pwm",
|
},
|
||||||
"ch",
|
|
||||||
"pid"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"tip": "Select control method of output",
|
"tip": "Select control method of output",
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
@ -56,11 +52,10 @@
|
|||||||
"triggerOnShow": true,
|
"triggerOnShow": true,
|
||||||
"decimals": 6,
|
"decimals": 6,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pwm",
|
"topic": "pwm",
|
||||||
"ch",
|
"field": "i_set"
|
||||||
"i_set"
|
},
|
||||||
],
|
|
||||||
"tip": "The set current through TEC",
|
"tip": "The set current through TEC",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -77,11 +72,10 @@
|
|||||||
],
|
],
|
||||||
"format": "{value:.4f}",
|
"format": "{value:.4f}",
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pid",
|
"topic": "pid",
|
||||||
"ch",
|
"field": "target"
|
||||||
"target"
|
},
|
||||||
],
|
|
||||||
"tip": "The temperature setpoint of the TEC",
|
"tip": "The temperature setpoint of the TEC",
|
||||||
"lock": false
|
"lock": false
|
||||||
}
|
}
|
||||||
@ -106,11 +100,10 @@
|
|||||||
0,
|
0,
|
||||||
2000
|
2000
|
||||||
],
|
],
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pwm",
|
"topic": "pwm",
|
||||||
"ch",
|
"field": "max_i_pos"
|
||||||
"max_i_pos"
|
},
|
||||||
],
|
|
||||||
"tip": "The maximum cooling (+ve) current through the output pins",
|
"tip": "The maximum cooling (+ve) current through the output pins",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -126,11 +119,10 @@
|
|||||||
0,
|
0,
|
||||||
2000
|
2000
|
||||||
],
|
],
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pwm",
|
"topic": "pwm",
|
||||||
"ch",
|
"field": "max_i_neg"
|
||||||
"max_i_neg"
|
},
|
||||||
],
|
|
||||||
"tip": "The maximum heating (-ve) current through the output pins",
|
"tip": "The maximum heating (-ve) current through the output pins",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -146,11 +138,10 @@
|
|||||||
],
|
],
|
||||||
"siPrefix": true,
|
"siPrefix": true,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pwm",
|
"topic": "pwm",
|
||||||
"ch",
|
"field": "max_v"
|
||||||
"max_v"
|
},
|
||||||
],
|
|
||||||
"tip": "The maximum voltage (in both directions) across the output pins",
|
"tip": "The maximum voltage (in both directions) across the output pins",
|
||||||
"lock": false
|
"lock": false
|
||||||
}
|
}
|
||||||
@ -177,11 +168,10 @@
|
|||||||
],
|
],
|
||||||
"format": "{value:.4f}",
|
"format": "{value:.4f}",
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"s-h",
|
"topic": "s-h",
|
||||||
"ch",
|
"field": "t0"
|
||||||
"t0"
|
},
|
||||||
],
|
|
||||||
"tip": "The base temperature",
|
"tip": "The base temperature",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -193,11 +183,10 @@
|
|||||||
"step": 1,
|
"step": 1,
|
||||||
"siPrefix": true,
|
"siPrefix": true,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"s-h",
|
"topic": "s-h",
|
||||||
"ch",
|
"field": "r0"
|
||||||
"r0"
|
},
|
||||||
],
|
|
||||||
"tip": "The resistance of the thermistor at base temperature T₀",
|
"tip": "The resistance of the thermistor at base temperature T₀",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -209,11 +198,10 @@
|
|||||||
"step": 1,
|
"step": 1,
|
||||||
"decimals": 4,
|
"decimals": 4,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"s-h",
|
"topic": "s-h",
|
||||||
"ch",
|
"field": "b"
|
||||||
"b"
|
},
|
||||||
],
|
|
||||||
"tip": "The Beta Parameter",
|
"tip": "The Beta Parameter",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -222,13 +210,12 @@
|
|||||||
"title": "50/60 Hz filter rejection",
|
"title": "50/60 Hz filter rejection",
|
||||||
"type": "list",
|
"type": "list",
|
||||||
"value": 16.67,
|
"value": 16.67,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"postfilter",
|
"topic": "postfilter",
|
||||||
"ch",
|
"field": "rate"
|
||||||
"rate"
|
},
|
||||||
],
|
|
||||||
"limits": {
|
"limits": {
|
||||||
"Off": null,
|
"Off": "",
|
||||||
"47 dB @ 10.41 Hz": 27.0,
|
"47 dB @ 10.41 Hz": 27.0,
|
||||||
"62 dB @ 9.1 Hz": 21.25,
|
"62 dB @ 9.1 Hz": 21.25,
|
||||||
"86 dB @ 10 Hz": 20.0,
|
"86 dB @ 10 Hz": 20.0,
|
||||||
@ -253,11 +240,10 @@
|
|||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"suffix": "",
|
"suffix": "",
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pid",
|
"topic": "pid",
|
||||||
"ch",
|
"field": "kp"
|
||||||
"kp"
|
},
|
||||||
],
|
|
||||||
"tip": "Proportional gain",
|
"tip": "Proportional gain",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -267,11 +253,10 @@
|
|||||||
"type": "float",
|
"type": "float",
|
||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pid",
|
"topic": "pid",
|
||||||
"ch",
|
"field": "ki"
|
||||||
"ki"
|
},
|
||||||
],
|
|
||||||
"tip": "Integral gain",
|
"tip": "Integral gain",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -281,11 +266,10 @@
|
|||||||
"type": "float",
|
"type": "float",
|
||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pid",
|
"topic": "pid",
|
||||||
"ch",
|
"field": "kd"
|
||||||
"kd"
|
},
|
||||||
],
|
|
||||||
"tip": "Differential gain",
|
"tip": "Differential gain",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -307,11 +291,10 @@
|
|||||||
],
|
],
|
||||||
"decimals": 6,
|
"decimals": 6,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pid",
|
"topic": "pid",
|
||||||
"ch",
|
"field": "output_min"
|
||||||
"output_min"
|
},
|
||||||
],
|
|
||||||
"tip": "Minimum PID output",
|
"tip": "Minimum PID output",
|
||||||
"lock": false
|
"lock": false
|
||||||
},
|
},
|
||||||
@ -326,11 +309,10 @@
|
|||||||
],
|
],
|
||||||
"decimals": 6,
|
"decimals": 6,
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"param": [
|
"thermostat:set_param": {
|
||||||
"pid",
|
"topic": "pid",
|
||||||
"ch",
|
"field": "output_max"
|
||||||
"output_max"
|
},
|
||||||
],
|
|
||||||
"tip": "Maximum PID output",
|
"tip": "Maximum PID output",
|
||||||
"lock": false
|
"lock": false
|
||||||
}
|
}
|
||||||
@ -351,10 +333,9 @@
|
|||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"format": "{value:.4f}",
|
"format": "{value:.4f}",
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"pid_autotune": [
|
"pid_autotune": {
|
||||||
"target_temp",
|
"params_name": "target_temp"
|
||||||
"ch"
|
},
|
||||||
],
|
|
||||||
"tip": "The target temperature to autotune for"
|
"tip": "The target temperature to autotune for"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -369,10 +350,9 @@
|
|||||||
0,
|
0,
|
||||||
2000
|
2000
|
||||||
],
|
],
|
||||||
"pid_autotune": [
|
"pid_autotune": {
|
||||||
"test_current",
|
"params_name": "test_current"
|
||||||
"ch"
|
},
|
||||||
],
|
|
||||||
"tip": "The testing current when autotuning"
|
"tip": "The testing current when autotuning"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -384,10 +364,9 @@
|
|||||||
"prefix": "±",
|
"prefix": "±",
|
||||||
"format": "{value:.4f}",
|
"format": "{value:.4f}",
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"pid_autotune": [
|
"pid_autotune": {
|
||||||
"temp_swing",
|
"params_name": "temp_swing"
|
||||||
"ch"
|
},
|
||||||
],
|
|
||||||
"tip": "The temperature swing around the target"
|
"tip": "The temperature swing around the target"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -398,10 +377,9 @@
|
|||||||
"step": 0.1,
|
"step": 0.1,
|
||||||
"format": "{value:.4f}",
|
"format": "{value:.4f}",
|
||||||
"compactHeight": false,
|
"compactHeight": false,
|
||||||
"pid_autotune": [
|
"pid_autotune": {
|
||||||
"lookback",
|
"params_name": "lookback"
|
||||||
"ch"
|
},
|
||||||
],
|
|
||||||
"tip": "Amount of time referenced for tuning"
|
"tip": "Amount of time referenced for tuning"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -270,35 +270,29 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
if "thermostat:set_param" in inner_param.opts:
|
if "thermostat:set_param" in inner_param.opts:
|
||||||
thermostat_param = inner_param.opts["thermostat:set_param"]
|
thermostat_param = inner_param.opts["thermostat:set_param"]
|
||||||
|
|
||||||
|
# Handle thermostat command irregularities
|
||||||
|
match inner_param.name(), new_value:
|
||||||
|
case "rate", "":
|
||||||
|
thermostat_param = thermostat_param.copy()
|
||||||
|
thermostat_param["field"] = "off"
|
||||||
|
case "control_method", "constant_current":
|
||||||
|
inner_param = inner_param.child("i_set")
|
||||||
|
thermostat_param = inner_param.opts["thermostat:set_param"]
|
||||||
|
new_value = inner_param.value()
|
||||||
|
case "control_method", "temperature_pid":
|
||||||
|
new_value = ""
|
||||||
|
|
||||||
if inner_param.opts.get("title", None).endswith(" (mA)"):
|
if inner_param.opts.get("title", None).endswith(" (mA)"):
|
||||||
new_value /= 1000 # Given in mA
|
new_value /= 1000 # Given in mA
|
||||||
|
|
||||||
thermostat_param = inner_param.opts["param"]
|
|
||||||
if thermostat_param[1] == "ch":
|
|
||||||
thermostat_param[1] = ch
|
|
||||||
|
|
||||||
if inner_param.name() == "rate" and new_value is None:
|
|
||||||
set_param_args = (*thermostat_param[:2], "off")
|
|
||||||
else:
|
|
||||||
set_param_args = (*thermostat_param, new_value)
|
|
||||||
inner_param.setOpts(lock=True)
|
inner_param.setOpts(lock=True)
|
||||||
await self.client.set_param(*set_param_args)
|
await self.client.set_param(
|
||||||
|
channel=ch, value=new_value, **thermostat_param
|
||||||
|
)
|
||||||
inner_param.setOpts(lock=False)
|
inner_param.setOpts(lock=False)
|
||||||
|
|
||||||
if "pid_autotune" in inner_param.opts:
|
if "pid_autotune" in inner_param.opts:
|
||||||
autotuner_param = inner_param.opts["pid_autotune"][0]
|
autotuner_param = inner_param.opts["pid_autotune"]
|
||||||
if inner_param.opts["pid_autotune"][1] != "ch":
|
self.autotuners.set_params(ch=ch, val=new_value, **autotuner_param)
|
||||||
ch = inner_param.opts["pid_autotune"][1]
|
|
||||||
self.autotuners.set_params(autotuner_param, ch, data)
|
|
||||||
|
|
||||||
if "activaters" in inner_param.opts:
|
|
||||||
activater = inner_param.opts["activaters"][
|
|
||||||
inner_param.reverse[0].index(data) # ListParameter.reverse = list of codename values
|
|
||||||
]
|
|
||||||
if activater is not None:
|
|
||||||
if activater[1] == "ch":
|
|
||||||
activater[1] = ch
|
|
||||||
await self.client.set_param(*activater)
|
|
||||||
|
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def pid_autotune_request(self, ch=0):
|
async def pid_autotune_request(self, ch=0):
|
||||||
|
Loading…
Reference in New Issue
Block a user