Try triggering on show

This commit is contained in:
atse 2023-08-25 23:44:01 +08:00
parent 6f0677bac6
commit 6014dce158
1 changed files with 6 additions and 3 deletions

View File

@ -58,7 +58,11 @@ class MutexParameter(pTypes.ListParameter):
for param in self.children(): for param in self.children():
param.hide() param.hide()
self._get_param_from_value(value.value()).show() child_to_show = self._get_param_from_value(value.value())
child_to_show.show()
if child_to_show.opts.get('triggerOnShow', None):
child_to_show.sigValueChanged.emit(child_to_show, child_to_show.value())
registerParameterType('mutex', MutexParameter) registerParameterType('mutex', MutexParameter)
@ -162,7 +166,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
{'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [ {'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [
{'name': 'Control Method', 'type': 'mutex', 'limits': {'Current Setpoint': False, 'Temperature PID': True}, {'name': 'Control Method', 'type': 'mutex', 'limits': {'Current Setpoint': False, 'Temperature PID': True},
'commands': [f'pwm {ch} pid'], 'children': [ 'commands': [f'pwm {ch} pid'], 'children': [
{'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, 'triggerOnShow': True,
'suffix': 'A', 'param': [('pwm', ch, 'i_set')]}, 'suffix': 'A', 'param': [('pwm', ch, 'i_set')]},
{'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', 'param': [('pid', ch, 'target')]}, 'suffix': '°C', 'param': [('pid', ch, 'target')]},
@ -629,7 +633,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
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())
else: else:
await self.client.set_param('pwm', ch, 'i_set', inner_param.child('Constant Current').value())
return return
case 'Set Temperature': case 'Set Temperature':
getattr(self, f'ch{ch}_t_line').setValue(data) getattr(self, f'ch{ch}_t_line').setValue(data)