gui: autotuner only set_i when relay state changes
- Previously, autotuner issues set_i cmd for each report obj received - These change increase the maximum autotune-able PID update rate with GUI
This commit is contained in:
parent
a1b7538295
commit
49dc8a9b96
|
@ -814,8 +814,10 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
tree.setParameters(self.params[1], showTop=False)
|
tree.setParameters(self.params[1], showTop=False)
|
||||||
self.params[1].sigTreeStateChanged.connect(self.send_command)
|
self.params[1].sigTreeStateChanged.connect(self.send_command)
|
||||||
|
|
||||||
|
self.prev_autotuner_state = None
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def autotune(param):
|
async def autotune(param):
|
||||||
|
self.prev_autotuner_state = None
|
||||||
match self.autotuner.state():
|
match self.autotuner.state():
|
||||||
case PIDAutotuneState.STATE_OFF:
|
case PIDAutotuneState.STATE_OFF:
|
||||||
settings = await self.kirdy.device.get_settings_summary()
|
settings = await self.kirdy.device.get_settings_summary()
|
||||||
|
@ -825,6 +827,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
param.parent().child('Temperature Swing').value(),
|
param.parent().child('Temperature Swing').value(),
|
||||||
1.0 / settings['thermostat']['temp_adc_settings']['rate'],
|
1.0 / settings['thermostat']['temp_adc_settings']['rate'],
|
||||||
param.parent().child('Lookback').value())
|
param.parent().child('Lookback').value())
|
||||||
|
print(param.parent().child('Lookback').value())
|
||||||
self.autotuner.setReady()
|
self.autotuner.setReady()
|
||||||
param.setOpts(title="Stop")
|
param.setOpts(title="Stop")
|
||||||
self.kirdy.task_dispatcher(self.kirdy.thermostat.set_constant_current_control_mode())
|
self.kirdy.task_dispatcher(self.kirdy.thermostat.set_constant_current_control_mode())
|
||||||
|
@ -878,12 +881,14 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.info_box.setWindowTitle("Command fails to execute")
|
self.info_box.setWindowTitle("Command fails to execute")
|
||||||
self.info_box.show()
|
self.info_box.show()
|
||||||
|
|
||||||
@pyqtSlot(dict)
|
@asyncSlot(dict)
|
||||||
def autotune_tick(self, report):
|
async def autotune_tick(self, report):
|
||||||
|
self.autotuner.run(report['thermostat']['temperature'], report['ts']/1000)
|
||||||
|
if self.prev_autotuner_state != self.autotuner.state():
|
||||||
match self.autotuner.state():
|
match self.autotuner.state():
|
||||||
case PIDAutotuneState.STATE_READY | PIDAutotuneState.STATE_RELAY_STEP_UP | PIDAutotuneState.STATE_RELAY_STEP_DOWN:
|
case PIDAutotuneState.STATE_READY | PIDAutotuneState.STATE_RELAY_STEP_UP | PIDAutotuneState.STATE_RELAY_STEP_DOWN:
|
||||||
self.autotuner.run(report['thermostat']['temperature'], report['ts']/1000)
|
await self.kirdy.thermostat.set_tec_i_out(self.autotuner.output())
|
||||||
self.kirdy.task_dispatcher(self.kirdy.thermostat.set_tec_i_out(self.autotuner.output()))
|
self.prev_autotuner_state = self.autotuner.state()
|
||||||
case PIDAutotuneState.STATE_SUCCEEDED:
|
case PIDAutotuneState.STATE_SUCCEEDED:
|
||||||
kp, ki, kd = self.autotuner.get_tec_pid()
|
kp, ki, kd = self.autotuner.get_tec_pid()
|
||||||
self.autotuner.setOff()
|
self.autotuner.setOff()
|
||||||
|
@ -900,7 +905,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.info_box.setWindowTitle("PID AutoTune Success")
|
self.info_box.setWindowTitle("PID AutoTune Success")
|
||||||
self.info_box.setText("PID Config has been loaded to Thermostat.\nRegulating temperature.")
|
self.info_box.setText("PID Config has been loaded to Thermostat.\nRegulating temperature.")
|
||||||
self.info_box.show()
|
self.info_box.show()
|
||||||
|
self.prev_autotuner_state = None
|
||||||
case PIDAutotuneState.STATE_FAILED:
|
case PIDAutotuneState.STATE_FAILED:
|
||||||
self.autotuner.setOff()
|
self.autotuner.setOff()
|
||||||
self.params[1].child('PID Config', 'PID Auto Tune', 'Run').setOpts(title="Run")
|
self.params[1].child('PID Config', 'PID Auto Tune', 'Run').setOpts(title="Run")
|
||||||
|
@ -912,6 +917,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.info_box.setWindowTitle("PID Autotune Failed")
|
self.info_box.setWindowTitle("PID Autotune Failed")
|
||||||
self.info_box.setText("PID Autotune is failed.")
|
self.info_box.setText("PID Autotune is failed.")
|
||||||
self.info_box.show()
|
self.info_box.show()
|
||||||
|
self.prev_autotuner_state = None
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def _on_connection_changed(self, result):
|
def _on_connection_changed(self, result):
|
||||||
|
|
Loading…
Reference in New Issue