Don't use _command

zotino-tec
atse 2023-08-29 12:24:31 +08:00
parent 4caaf44f74
commit 5bb64e577f
1 changed files with 20 additions and 14 deletions

View File

@ -261,7 +261,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
{'name': 'Run', 'type': 'action', 'tip': 'Run'},
]},
]},
{'name': 'Save to flash', 'type': 'action', 'tip': 'Save config to thermostat, applies on reset', 'commands': [f'save {ch}']}
{'name': 'Save to flash', 'type': 'action', 'tip': 'Save config to thermostat, applies on reset'}
] for ch in range(2)]
def __init__(self, args):
@ -275,19 +275,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self._set_up_thermostat_menu()
self._set_up_plot_menu()
self.params = [
Parameter.create(name=f"Thermostat Channel {ch} Parameters", type='group', value=ch, children=self.THERMOSTAT_PARAMETERS[ch])
for ch in range(2)
]
self._set_param_tree()
self.channel_graphs = [
ChannelGraphs(getattr(self, f'ch{ch}_t_graph'), getattr(self, f'ch{ch}_i_graph'))
for ch in range(2)
]
self.hw_rev_data = None
self.client = WrappedClient(self)
self.client.connection_error.connect(self.bail)
self.client_watcher = ClientWatcher(self, self.client, self.report_refresh_spin.value())
@ -301,6 +288,19 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
lambda: self.client_watcher.set_update_s(self.report_refresh_spin.value())
)
self.params = [
Parameter.create(name=f"Thermostat Channel {ch} Parameters", type='group', value=ch, children=self.THERMOSTAT_PARAMETERS[ch])
for ch in range(2)
]
self._set_param_tree()
self.channel_graphs = [
ChannelGraphs(getattr(self, f'ch{ch}_t_graph'), getattr(self, f'ch{ch}_i_graph'))
for ch in range(2)
]
self.hw_rev_data = None
if args.connect:
if args.IP:
self.host_set_line.setText(args.IP)
@ -637,6 +637,12 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
tree.setParameters(self.params[i], showTop=False)
self.params[i].sigTreeStateChanged.connect(self.send_command)
@asyncSlot()
async def save(_, channel=i):
await self.client.save_config(channel)
self.params[i].child('Save to flash').sigActivated.connect(save)
@pyqtSlot(list)
def update_pid(self, pid_settings):
for settings in pid_settings: