forked from M-Labs/thermostat
Better send_command
This commit is contained in:
parent
98f2d70cf6
commit
7e89bf5337
|
@ -599,19 +599,22 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
|
||||
@asyncSlot(object, object)
|
||||
async def send_command(self, param, changes):
|
||||
for param, change, data in changes:
|
||||
if param.name() == 'Temperature PID' and not data:
|
||||
ch = param.opts["payload"]
|
||||
await self.client.set_param('pwm', ch, 'i_set', params[ch].child('Constant Current').value())
|
||||
line = getattr(self, f'ch{ch}_t_line')
|
||||
line.setVisible(False)
|
||||
elif param.opts.get("commands", None) is not None:
|
||||
match param.name():
|
||||
for inner_param, change, data in changes:
|
||||
if inner_param.opts.get("commands", None) is not None:
|
||||
match inner_param.name():
|
||||
case 'Temperature PID':
|
||||
getattr(self, f'ch{param.opts["payload"]}_t_line').setVisible(True)
|
||||
pid_enabled = data
|
||||
ch = inner_param.opts['payload']
|
||||
getattr(self, f'ch{ch}_t_line').setVisible(pid_enabled)
|
||||
if pid_enabled:
|
||||
getattr(self, f'ch{ch}_t_line').setValue(inner_param.child('Set Temperature').value())
|
||||
else:
|
||||
await self.client.set_param('pwm', ch, 'i_set', param.child('Constant Current').value())
|
||||
return
|
||||
case 'Set Temperature':
|
||||
getattr(self, f'ch{param.opts["payload"]}_t_line').setValue(data)
|
||||
await asyncio.gather(*[self.client._command(x.format(value=data)) for x in param.opts["commands"]])
|
||||
ch = inner_param.opts['payload']
|
||||
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"]])
|
||||
|
||||
def _set_param_tree(self):
|
||||
for i, tree in enumerate((self.ch0_tree, self.ch1_tree)):
|
||||
|
|
Loading…
Reference in New Issue