forked from M-Labs/thermostat
Switch to using set_param if possible
This commit is contained in:
parent
db766d8707
commit
ef87225339
|
@ -126,34 +126,34 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
"""Thermostat parameters that are particular to a channel"""
|
||||
THERMOSTAT_PARAMETERS = [[
|
||||
{'name': 'Constant Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (-3, 3), 'siPrefix': True,
|
||||
'suffix': 'A', 'commands': [f'pwm {ch} i_set {{value}}']},
|
||||
'suffix': 'A', 'param': [('pwm', ch, 'i_set')]},
|
||||
{'name': 'Temperature PID', 'type': 'bool', 'value': False, 'commands': [f'pwm {ch} pid'],
|
||||
'children': [
|
||||
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), 'siPrefix': True,
|
||||
'suffix': '°C', 'commands': [f'pid {ch} target {{value}}']},
|
||||
'suffix': '°C', 'param': [('pid', ch, 'target')]},
|
||||
]},
|
||||
{'name': 'Output Config', 'expanded': False, 'type': 'group', 'children': [
|
||||
{'name': 'Max Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 3), 'siPrefix': True, 'prefix': '±',
|
||||
'suffix': 'A', 'commands': [f'pwm {ch} max_i_pos {{value}}', f'pwm {ch} max_i_neg {{value}}',
|
||||
f'pid {ch} output_min -{{value}}', f'pid {ch} output_max {{value}}']},
|
||||
{'name': 'Max Voltage', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 5), 'siPrefix': True,
|
||||
'suffix': 'V', 'commands': [f'pwm {ch} max_v {{value}}']},
|
||||
'suffix': 'V', 'param': [('pwm', ch, 'max_v')]},
|
||||
]},
|
||||
{'name': 'Thermistor Config', 'expanded': False, 'type': 'group', 'children': [
|
||||
{'name': 'T₀', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-100, 100), 'siPrefix': True,
|
||||
'suffix': '°C', 'commands': [f's-h {ch} t0 {{value}}']},
|
||||
'suffix': '°C', 'param': [('s-h', ch, 't0')]},
|
||||
{'name': 'R₀', 'type': 'float', 'value': 10000, 'step': 1, 'siPrefix': True, 'suffix': 'Ω',
|
||||
'commands': [f's-h {ch} r0 {{value}}']},
|
||||
{'name': 'β', 'type': 'float', 'value': 3950, 'step': 1, 'suffix': 'K', 'commands': [f's-h {ch} b {{value}}']},
|
||||
'param': [('s-h', ch, 'r0')]},
|
||||
{'name': 'β', 'type': 'float', 'value': 3950, 'step': 1, 'suffix': 'K', 'param': [('s-h', ch, 'b')]},
|
||||
]},
|
||||
{'name': 'Postfilter Config', 'expanded': False, 'type': 'group', 'children': [
|
||||
{'name': 'Rate', 'type': 'float', 'value': 16.67, 'step': 0.01, 'suffix': 'Hz',
|
||||
'commands': [f'postfilter {ch} rate {{value}}']},
|
||||
'param': [('postfilter', ch, 'rate')]},
|
||||
]},
|
||||
{'name': 'PID Config', 'expanded': False, 'type': 'group', 'children': [
|
||||
{'name': 'Kp', 'type': 'float', 'value': 0, 'step': 0.1, 'suffix': '°C/A', 'commands': [f'pid {ch} kp {{value}}']},
|
||||
{'name': 'Ki', 'type': 'float', 'value': 0, 'step': 0.1, 'suffix': '°C/C', 'commands': [f'pid {ch} ki {{value}}']},
|
||||
{'name': 'Kd', 'type': 'float', 'value': 0, 'step': 0.1, 'suffix': '°Cs²/C', 'commands': [f'pid {ch} kd {{value}}']},
|
||||
{'name': 'Kp', 'type': 'float', 'value': 0, 'step': 0.1, 'suffix': '°C/A', 'param': [('pid', ch, 'kp')]},
|
||||
{'name': 'Ki', 'type': 'float', 'value': 0, 'step': 0.1, 'suffix': '°C/C', 'param': [('pid', ch, 'ki')]},
|
||||
{'name': 'Kd', 'type': 'float', 'value': 0, 'step': 0.1, 'suffix': '°Cs²/C', 'param': [('pid', ch, 'kd')]},
|
||||
{'name': 'PID Auto Tune', 'expanded': False, 'type': 'group', 'children': [
|
||||
{'name': 'Target Temperature', 'type': 'float', 'value': 20, 'step': 0.1, 'siPrefix': True, 'suffix': '°C'},
|
||||
{'name': 'Test Current', 'type': 'float', 'value': 1, 'step': 0.1, 'siPrefix': True, 'suffix': 'A'},
|
||||
|
@ -596,6 +596,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
case 'Set Temperature':
|
||||
getattr(self, f'ch{ch}_t_line').setValue(data)
|
||||
await asyncio.gather(*[self.client._command(x.format(value=data)) for x in inner_param.opts["commands"]])
|
||||
elif inner_param.opts.get("param", None) is not None:
|
||||
await asyncio.gather(*[self.client.set_param(*x, data) for x in inner_param.opts["param"]])
|
||||
|
||||
|
||||
def _set_param_tree(self):
|
||||
for i, tree in enumerate((self.ch0_tree, self.ch1_tree)):
|
||||
|
|
Loading…
Reference in New Issue