Control Method simplifcation

This commit is contained in:
atse 2023-10-16 12:00:16 +08:00
parent c56a167824
commit d8b1e7e964

View File

@ -213,7 +213,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
{'name': 'Current through TEC', 'type': 'float', 'suffix': 'mA', 'decimals': 6, 'readonly': True}, {'name': 'Current through TEC', 'type': 'float', 'suffix': 'mA', 'decimals': 6, 'readonly': True},
{'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [ {'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [
{'name': 'Control Method', 'type': 'mutex', 'limits': {'Constant Current': False, 'Temperature PID': True}, {'name': 'Control Method', 'type': 'mutex', 'limits': {'Constant Current': False, 'Temperature PID': True},
'param': ('pwm', ch, 'pid'), 'children': [ 'activater': ('pwm', ch, 'pid'), 'children': [
{'name': 'Set Current', 'type': 'float', 'value': 0, 'step': 100, 'limits': (-3000, 3000), 'triggerOnShow': True, {'name': 'Set Current', 'type': 'float', 'value': 0, 'step': 100, 'limits': (-3000, 3000), 'triggerOnShow': True,
'decimals': 6, 'suffix': 'mA', 'param': ('pwm', ch, 'i_set')}, 'decimals': 6, 'suffix': 'mA', 'param': ('pwm', ch, 'i_set')},
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), {'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300),
@ -662,19 +662,18 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
for inner_param, change, data in changes: for inner_param, change, data in changes:
if change == 'value': if change == 'value':
if inner_param.opts.get("param", None) is not None: if inner_param.opts.get("param", None) is not None:
if inner_param.name() == 'Control Method' and not data:
return
if 'Current' in inner_param.name(): if 'Current' in inner_param.name():
data /= 1000 # Given in mA data /= 1000 # Given in mA
thermostat_param = inner_param.opts["param"] thermostat_param = inner_param.opts["param"]
if inner_param.name() == 'Postfilter Rate' and data == None: if inner_param.name() == 'Postfilter Rate' and data == None:
set_param_args = (*thermostat_param[:2], 'off') set_param_args = (*thermostat_param[:2], 'off')
elif inner_param.name() == 'Control Method':
set_param_args = thermostat_param
else: else:
set_param_args = (*thermostat_param, data) set_param_args = (*thermostat_param, data)
await self.client.set_param(*set_param_args) await self.client.set_param(*set_param_args)
if inner_param.opts.get('activater', None) is not None:
if data:
await self.client.set_param(*inner_param.opts['activater'])
def _set_param_tree(self): def _set_param_tree(self):