forked from M-Labs/thermostat
Don't use payload to get channel
Use parent param instead
This commit is contained in:
parent
6f40adb19d
commit
82c3576603
|
@ -26,10 +26,10 @@ class CommandsParameter(Parameter):
|
||||||
THERMOSTAT_PARAMETERS = [[
|
THERMOSTAT_PARAMETERS = [[
|
||||||
{'name': 'Constant Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (-3, 3), 'siPrefix': True,
|
{'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', 'commands': [f'pwm {ch} i_set {{value}}']},
|
||||||
{'name': 'Temperature PID', 'type': 'bool', 'value': False, 'commands': [f'pwm {ch} pid'], 'payload': ch,
|
{'name': 'Temperature PID', 'type': 'bool', 'value': False, 'commands': [f'pwm {ch} pid'],
|
||||||
'children': [
|
'children': [
|
||||||
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), 'siPrefix': True,
|
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), 'siPrefix': True,
|
||||||
'suffix': '°C', 'commands': [f'pid {ch} target {{value}}'], 'payload': ch},
|
'suffix': '°C', 'commands': [f'pid {ch} target {{value}}']},
|
||||||
]},
|
]},
|
||||||
{'name': 'Output Config', 'expanded': False, 'type': 'group', 'children': [
|
{'name': 'Output Config', 'expanded': False, 'type': 'group', 'children': [
|
||||||
{'name': 'Max Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 3), 'siPrefix': True, 'prefix': '±',
|
{'name': 'Max Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 3), 'siPrefix': True, 'prefix': '±',
|
||||||
|
@ -65,8 +65,8 @@ THERMOSTAT_PARAMETERS = [[
|
||||||
|
|
||||||
|
|
||||||
params = [
|
params = [
|
||||||
CommandsParameter.create(name='Thermostat Params 0', type='group', children=THERMOSTAT_PARAMETERS[0]),
|
CommandsParameter.create(name='Thermostat Params 0', type='group', value=0, children=THERMOSTAT_PARAMETERS[0]),
|
||||||
CommandsParameter.create(name='Thermostat Params 1', type='group', children=THERMOSTAT_PARAMETERS[1]),
|
CommandsParameter.create(name='Thermostat Params 1', type='group', value=1, children=THERMOSTAT_PARAMETERS[1]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -602,10 +602,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
async def send_command(self, param, changes):
|
async def send_command(self, param, changes):
|
||||||
for inner_param, change, data in changes:
|
for inner_param, change, data in changes:
|
||||||
if inner_param.opts.get("commands", None) is not None:
|
if inner_param.opts.get("commands", None) is not None:
|
||||||
|
ch = param.value()
|
||||||
match inner_param.name():
|
match inner_param.name():
|
||||||
case 'Temperature PID':
|
case 'Temperature PID':
|
||||||
pid_enabled = data
|
pid_enabled = data
|
||||||
ch = inner_param.opts['payload']
|
|
||||||
getattr(self, f'ch{ch}_t_line').setVisible(pid_enabled)
|
getattr(self, f'ch{ch}_t_line').setVisible(pid_enabled)
|
||||||
if pid_enabled:
|
if pid_enabled:
|
||||||
getattr(self, f'ch{ch}_t_line').setValue(inner_param.child('Set Temperature').value())
|
getattr(self, f'ch{ch}_t_line').setValue(inner_param.child('Set Temperature').value())
|
||||||
|
@ -613,7 +613,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
await self.client.set_param('pwm', ch, 'i_set', param.child('Constant Current').value())
|
await self.client.set_param('pwm', ch, 'i_set', param.child('Constant Current').value())
|
||||||
return
|
return
|
||||||
case 'Set Temperature':
|
case 'Set Temperature':
|
||||||
ch = inner_param.opts['payload']
|
|
||||||
getattr(self, f'ch{ch}_t_line').setValue(data)
|
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"]])
|
await asyncio.gather(*[self.client._command(x.format(value=data)) for x in inner_param.opts["commands"]])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue