fix: subscribe dap updates before align and unsubscribe after align is done
This commit is contained in:
@@ -93,6 +93,16 @@ class XrayEyeAlign:
|
||||
|
||||
def align(self, keep_shutter_open=False):
|
||||
self.flomni.flomnigui_show_xeyealign()
|
||||
self.gui.set_dap_params_forwarding(True)
|
||||
try:
|
||||
self._align_impl(keep_shutter_open)
|
||||
finally:
|
||||
try:
|
||||
self.gui.set_dap_params_forwarding(False)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
logger.warning(f"Failed to disable XRayEye DAP parameter forwarding: {exc}")
|
||||
|
||||
def _align_impl(self, keep_shutter_open=False):
|
||||
if not keep_shutter_open:
|
||||
print(
|
||||
"This routine can be called with paramter keep_shutter_open=True to keep the shutter always open"
|
||||
|
||||
@@ -102,6 +102,13 @@ class XRayEye(RPCBase):
|
||||
None
|
||||
"""
|
||||
|
||||
@rpc_timeout(20)
|
||||
@rpc_call
|
||||
def set_dap_params_forwarding(self, enabled: "bool"):
|
||||
"""
|
||||
Connect or disconnect DAP fit parameter forwarding to omny_xray_gui.
|
||||
"""
|
||||
|
||||
@rpc_timeout(20)
|
||||
@rpc_call
|
||||
def submit_fit_array(self, fit_array):
|
||||
|
||||
@@ -140,6 +140,7 @@ class XRayEye(BECWidget, QWidget):
|
||||
"enable_move_buttons",
|
||||
"enable_move_buttons.setter",
|
||||
"switch_tab",
|
||||
"set_dap_params_forwarding",
|
||||
"submit_fit_array",
|
||||
]
|
||||
PLUGIN = True
|
||||
@@ -147,6 +148,7 @@ class XRayEye(BECWidget, QWidget):
|
||||
def __init__(self, parent=None, **kwargs):
|
||||
super().__init__(parent=parent, **kwargs)
|
||||
self._connected_motor = None
|
||||
self._dap_params_forwarding_connected = False
|
||||
self.get_bec_shortcuts()
|
||||
|
||||
self._init_ui()
|
||||
@@ -308,9 +310,6 @@ class XRayEye(BECWidget, QWidget):
|
||||
self.fit_x = self.waveform_x.curves[0]
|
||||
self.fit_y = self.waveform_y.curves[0]
|
||||
|
||||
self.waveform_x.dap_params_update.connect(self.on_dap_params)
|
||||
self.waveform_y.dap_params_update.connect(self.on_dap_params)
|
||||
|
||||
for wave in (self.waveform_x, self.waveform_y):
|
||||
wave.x_label = "Angle (deg)"
|
||||
wave.x_grid = True
|
||||
@@ -490,6 +489,31 @@ class XRayEye(BECWidget, QWidget):
|
||||
else:
|
||||
self.submit_button.setEnabled(False)
|
||||
|
||||
@SafeSlot(bool)
|
||||
@rpc_timeout(20)
|
||||
def set_dap_params_forwarding(self, enabled: bool):
|
||||
"""
|
||||
Connect or disconnect DAP fit parameter forwarding to omny_xray_gui.
|
||||
"""
|
||||
if enabled == self._dap_params_forwarding_connected:
|
||||
return
|
||||
|
||||
signals = (self.waveform_x.dap_params_update, self.waveform_y.dap_params_update)
|
||||
if enabled:
|
||||
for signal in signals:
|
||||
signal.connect(self.on_dap_params)
|
||||
self._dap_params_forwarding_connected = True
|
||||
logger.info("Enabled XRayEye DAP parameter forwarding.")
|
||||
return
|
||||
|
||||
for signal in signals:
|
||||
try:
|
||||
signal.disconnect(self.on_dap_params)
|
||||
except (TypeError, RuntimeError):
|
||||
pass
|
||||
self._dap_params_forwarding_connected = False
|
||||
logger.info("Disabled XRayEye DAP parameter forwarding.")
|
||||
|
||||
@SafeSlot(dict, dict)
|
||||
def on_dap_params(self, data, meta):
|
||||
print("#######################################")
|
||||
|
||||
Reference in New Issue
Block a user