No more _command

This commit is contained in:
atse 2023-08-30 10:17:39 +08:00
parent a213078c9a
commit 72956e19ee

View File

@ -225,7 +225,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
{'name': 'Current through TEC', 'type': 'float', 'siPrefix': True, 'suffix': 'A', 'readonly': True},
{'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [
{'name': 'Control Method', 'type': 'mutex', 'limits': {'Constant Current': False, 'Temperature PID': True},
'commands': [f'pwm {ch} pid'], 'children': [
'param': [('pwm', ch, 'pid')], 'children': [
{'name': 'Set Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (-3, 3), 'siPrefix': True, 'triggerOnShow': True,
'suffix': 'A', 'param': [('pwm', ch, 'i_set')]},
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), 'siPrefix': True,
@ -623,16 +623,16 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
async def send_command(self, param, changes):
for inner_param, change, data in changes:
if change == 'value':
if inner_param.opts.get("commands", None) is not None:
if inner_param.opts.get("param", None) is not None:
if inner_param.name() == 'Control Method' and not data:
return
await asyncio.gather(*[self.client._command(x.format(value=data)) for x in inner_param.opts["commands"]])
if inner_param.opts.get("param", None) is not None:
for thermostat_param in inner_param.opts["param"]:
if len(thermostat_param) == 4: # To tack on prefixes to the data
await self.client.set_param(*thermostat_param[:3], f"{thermostat_param[3]}{data}")
elif inner_param.name() == 'Postfilter Rate':
await self.client.set_param(*thermostat_param, *data)
elif inner_param.name() == 'Control Method':
await self.client.set_param(*thermostat_param)
else:
await self.client.set_param(*thermostat_param, data)