GUI: fix bug in smart_params handling - should be mvoed to daq eventually
This commit is contained in:
@@ -340,9 +340,7 @@ class SimpleRotationSettingsPanel(QWidget):
|
||||
|
||||
#logger.debug("updated labels")
|
||||
self._prev_params = self.parameters
|
||||
if self._prev_params != self.parameters:
|
||||
self.parameters_changed.emit(self.parameters)
|
||||
logger.debug("emitted parameters")
|
||||
self.parameters_changed.emit(self.parameters)
|
||||
|
||||
@Slot()
|
||||
def run_measurement(self):
|
||||
|
||||
@@ -54,6 +54,13 @@ class DAQWorker(QObject):
|
||||
self._status_request_min_interval = 10.0
|
||||
self._last_status_error = None
|
||||
|
||||
self._last_smart_params_json: str | None = None
|
||||
self._smart_params_debounce = QTimer(self)
|
||||
self._smart_params_debounce.setInterval(400) # ms
|
||||
self._smart_params_debounce.setSingleShot(True)
|
||||
self._smart_params_pending: str | None = None
|
||||
self._smart_params_debounce.timeout.connect(self._flush_smart_params)
|
||||
|
||||
@Slot()
|
||||
def regular_update(self):
|
||||
if self.__counter % SPREADHSEET_FREQUENCY == 0:
|
||||
@@ -412,12 +419,25 @@ class DAQWorker(QObject):
|
||||
reply = self.__net_manager.post(request, QByteArray(body.encode("utf-8")))
|
||||
reply.finished.connect(lambda: self.handle_auto_scan_response(reply, s.db_id))
|
||||
|
||||
def _flush_smart_params(self):
|
||||
body = self._smart_params_pending
|
||||
if body is None:
|
||||
return
|
||||
if body == self._last_smart_params_json:
|
||||
return # no-op
|
||||
self._last_smart_params_json = body
|
||||
self.generic_post("scan/smart_params", body)
|
||||
self._smart_params_pending = None
|
||||
|
||||
@Slot(SimpleScanParameters)
|
||||
def smart_params(self, p: SimpleScanParameters):
|
||||
if self.__base_url is None:
|
||||
logger.info(f"POST /scan/smart_params: {p.model_dump_json()}")
|
||||
return
|
||||
self.generic_post("scan/smart_params", p.model_dump_json())
|
||||
body = p.model_dump_json()
|
||||
# dedupe and debounce
|
||||
self._smart_params_pending = body
|
||||
self._smart_params_debounce.start()
|
||||
|
||||
@Slot(Coordinate)
|
||||
def abr_tweak(self, c: Coordinate):
|
||||
|
||||
Reference in New Issue
Block a user