bec/gui: added save_current_psotion and save_and_reload macros to GUI
This commit is contained in:
@@ -1908,6 +1908,7 @@ class AareDAQ:
|
||||
self.__cfg.set_busy(BeamlineStateEnum.SampleAlignment)
|
||||
try:
|
||||
self.__cfg.abr_meas_pos = AerotechCoordinate(at_mm=self.__devs.aerotech_pos.at_mm)
|
||||
self.__devs.bec_worker.save_current_aerotech_position()
|
||||
self.__cfg.state_busy = False
|
||||
except Exception:
|
||||
self.__cfg.state_busy = False
|
||||
@@ -3533,6 +3534,27 @@ class AareDAQ:
|
||||
finally:
|
||||
self.__cfg.state_busy = False
|
||||
|
||||
def bec_save_current_bs_pos(self) -> None:
|
||||
self.__cfg.try_set_busy(timeout=360)
|
||||
try:
|
||||
self.__devs.bec_worker.save_current_bs_pos()
|
||||
finally:
|
||||
self.__cfg.state_busy = False
|
||||
|
||||
def bec_save_current_collimator_pos(self) -> None:
|
||||
self.__cfg.try_set_busy(timeout=360)
|
||||
try:
|
||||
self.__devs.bec_worker.save_current_collimator_pos()
|
||||
finally:
|
||||
self.__cfg.state_busy = False
|
||||
|
||||
def bec_save_current_aerotech_position(self) -> None:
|
||||
self.__cfg.try_set_busy(timeout=360)
|
||||
try:
|
||||
self.__devs.bec_worker.save_current_aerotech_position()
|
||||
finally:
|
||||
self.__cfg.state_busy = False
|
||||
|
||||
def fluorimeter_take_spectrum(self, fm: FluorescenceSpectrumParameterModel) -> FluorescenceSpectrumOutputModel:
|
||||
self.__cfg.try_set_busy(timeout=360)
|
||||
|
||||
|
||||
@@ -640,6 +640,45 @@ async def bec_reinitialise_planner_and_position_devices(
|
||||
"message": "BEC planner and position devices reinitialised.",
|
||||
}
|
||||
|
||||
@app.post("/bec/save_current_bs_pos")
|
||||
async def bec_save_current_bs_pos(token: str = Depends(oauth2_scheme)) -> dict:
|
||||
"""
|
||||
Save the current BEC beamstop work position. Staff only.
|
||||
"""
|
||||
data = auth.parse_token(token)
|
||||
auth.check_jwt_staff_only(data)
|
||||
daq.bec_save_current_bs_pos()
|
||||
return {
|
||||
"ok": True,
|
||||
"message": "Saved current BEC beamstop work position.",
|
||||
}
|
||||
|
||||
@app.post("/bec/save_current_collimator_pos")
|
||||
async def bec_save_current_collimator_pos(token: str = Depends(oauth2_scheme)) -> dict:
|
||||
"""
|
||||
Save the current BEC collimator work position. Staff only.
|
||||
"""
|
||||
data = auth.parse_token(token)
|
||||
auth.check_jwt_staff_only(data)
|
||||
daq.bec_save_current_collimator_pos()
|
||||
return {
|
||||
"ok": True,
|
||||
"message": "Saved current BEC collimator work position.",
|
||||
}
|
||||
|
||||
@app.post("/bec/save_current_aerotech_position")
|
||||
async def bec_save_current_aerotech_position(token: str = Depends(oauth2_scheme)) -> dict:
|
||||
"""
|
||||
Save the current BEC aerotech work position and reload device config. Staff only.
|
||||
"""
|
||||
data = auth.parse_token(token)
|
||||
auth.check_jwt_staff_only(data)
|
||||
daq.bec_save_current_aerotech_position()
|
||||
return {
|
||||
"ok": True,
|
||||
"message": "Saved current BEC aerotech work position and reloaded devices.",
|
||||
}
|
||||
|
||||
def initialise_aerotech(self):
|
||||
self.__cfg.try_set_busy(timeout=360)
|
||||
try:
|
||||
|
||||
@@ -494,6 +494,21 @@ class BECClientWorker:
|
||||
tags=["backlight"]
|
||||
)
|
||||
|
||||
def save_current_bs_pos(self):
|
||||
save_current_position(self.dev.bs_z, 'safe')
|
||||
|
||||
def save_current_collimator_pos(self):
|
||||
save_current_position(self.dev.coll_y, 'work')
|
||||
|
||||
def save_current_aerotech_position(self):
|
||||
save_current_position(self.dev.aerotech, 'work', axis = 'x')
|
||||
save_current_position(self.dev.aerotech, 'work', axis='y')
|
||||
save_current_position(self.dev.aerotech, 'work', axis='z')
|
||||
self.save_config_and_reload_devices()
|
||||
|
||||
def save_config_and_reload_devices(self):
|
||||
self.position_devices, self.planner = save_and_reload()
|
||||
|
||||
@property
|
||||
def zoom(self):
|
||||
return self.__zoom.position
|
||||
|
||||
@@ -315,13 +315,14 @@ class LocalContactPanel(QFrame):
|
||||
tools_layout.setContentsMargins(10, 12, 10, 10)
|
||||
tools_layout.setSpacing(6)
|
||||
|
||||
#label = QLabel("BEC inspection and recovery utilities.", tools)
|
||||
#label.setWordWrap(True)
|
||||
tools_layout.addWidget(tools)
|
||||
|
||||
tools_layout.addWidget(self._make_button("Load BEC user macros", self._daq.bec_load_user_macros, "Loading BEC user macros."))
|
||||
tools_layout.addWidget(self._make_button("Show BEC user macros", self._daq.bec_list_all_user_macros, "Listing BEC user macros."))
|
||||
tools_layout.addWidget(self._make_button("Show BEC position devices", self._daq.bec_list_all_devices, "Listing BEC devices."))
|
||||
tools_layout.addWidget(
|
||||
self._make_button("Load BEC user macros", self._daq.bec_load_user_macros, "Loading BEC user macros."))
|
||||
tools_layout.addWidget(
|
||||
self._make_button("Show BEC user macros", self._daq.bec_list_all_user_macros, "Listing BEC user macros."))
|
||||
tools_layout.addWidget(
|
||||
self._make_button("Show BEC position devices", self._daq.bec_list_all_devices, "Listing BEC devices."))
|
||||
tools_layout.addWidget(
|
||||
self._make_button(
|
||||
"Reinitialise BEC planner/devices",
|
||||
@@ -330,7 +331,35 @@ class LocalContactPanel(QFrame):
|
||||
)
|
||||
)
|
||||
|
||||
device_config = QGroupBox("Device config", tab)
|
||||
device_config_layout = QVBoxLayout(device_config)
|
||||
device_config_layout.setContentsMargins(10, 12, 10, 10)
|
||||
device_config_layout.setSpacing(6)
|
||||
|
||||
device_config_layout.addWidget(
|
||||
self._make_button(
|
||||
"Save current beamstop z safe position",
|
||||
self._daq.bec_save_current_bs_pos,
|
||||
"Saving current BEC beamstop safe position.",
|
||||
)
|
||||
)
|
||||
device_config_layout.addWidget(
|
||||
self._make_button(
|
||||
"Save current collimator position",
|
||||
self._daq.bec_save_current_collimator_pos,
|
||||
"Saving current BEC collimator work position.",
|
||||
)
|
||||
)
|
||||
device_config_layout.addWidget(
|
||||
self._make_button(
|
||||
"Save current aerotech position",
|
||||
self._daq.bec_save_current_aerotech_position,
|
||||
"Saving current BEC aerotech work position and reloading devices.",
|
||||
)
|
||||
)
|
||||
|
||||
layout.addWidget(tools)
|
||||
layout.addWidget(device_config)
|
||||
layout.addStretch(1)
|
||||
return tab
|
||||
|
||||
|
||||
@@ -1663,6 +1663,18 @@ class DAQWorker(QObject):
|
||||
def bec_reinitialise_planner_and_position_devices(self, method: str = "auto"):
|
||||
self.generic_post(f"bec/reinitialise_planner_and_position_devices?method={method}")
|
||||
|
||||
@Slot()
|
||||
def bec_save_current_bs_pos(self):
|
||||
self.generic_post("bec/save_current_bs_pos")
|
||||
|
||||
@Slot()
|
||||
def bec_save_current_collimator_pos(self):
|
||||
self.generic_post("bec/save_current_collimator_pos")
|
||||
|
||||
@Slot()
|
||||
def bec_save_current_aerotech_position(self):
|
||||
self.generic_post("bec/save_current_aerotech_position")
|
||||
|
||||
@Slot()
|
||||
def initialise_smargon(self):
|
||||
self.generic_post("smargon/initialize")
|
||||
|
||||
Reference in New Issue
Block a user