DAQ: Added CryojetSettings as a seperate model in config and implemented in DAQ.
This commit is contained in:
1 parent
053daa24ff
commit
99305a473e
4 files changed
+51
-57
No files matched your search
@@ -179,10 +179,6 @@ class DAQStatusModel(BaseModel):
|
||||
session: SessionStatus
|
||||
|
||||
class BeamlineSettingsModel(BaseModel):
|
||||
# Float properties
|
||||
cryojet_park_position: float | None = 12.0
|
||||
cryojet_measurement_position: float | None = 5.0
|
||||
|
||||
dtz_max: float | None = 1600.0
|
||||
dtz_min: float | None = 120.0
|
||||
dtz_collection: float | None = 130.0
|
||||
@@ -196,4 +192,7 @@ class BeamlineSettingsModel(BaseModel):
|
||||
camera_translation_factor_a: float | None = 0.00253
|
||||
camera_translation_factor_b: float | None = 255.0
|
||||
|
||||
cryojet_in_use: bool | None = True
|
||||
class CryojetSettingsModel(BaseModel):
|
||||
cryojet_park_position: float | None = 12.0
|
||||
cryojet_measurement_position: float | None = 5.0
|
||||
cryojet_in_use: bool | None = True
|
||||
@@ -14,7 +14,7 @@ from aaredaqlib.models import (
|
||||
def_loop_centering_zoom,
|
||||
SampleShortInfo,
|
||||
SessionStatus,
|
||||
BeamlineStateEnum, SessionsStateEnum, SampleShortInfoList,
|
||||
BeamlineStateEnum, SessionsStateEnum, SampleShortInfoList, CryojetSettingsModel,
|
||||
)
|
||||
|
||||
from aaredaqlib.beamline import MXBeamline
|
||||
@@ -267,6 +267,19 @@ class BeamlineConfig:
|
||||
updated_data = current.model_copy(update=data.model_dump(exclude_unset=True))
|
||||
self.__client.set(f"{self.__bl}:settings", updated_data.model_dump_json())
|
||||
|
||||
@property
|
||||
def cryojet_settings(self) -> CryojetSettingsModel:
|
||||
tmp = self.__client.get(f"{self.__bl}:cryojet_settings")
|
||||
if tmp is None:
|
||||
return CryojetSettingsModel()
|
||||
|
||||
data_dict = json.loads(tmp)
|
||||
return CryojetSettingsModel(**data_dict)
|
||||
|
||||
@cryojet_settings.setter
|
||||
def cryojet_settings(self, data: CryojetSettingsModel):
|
||||
self.__client.set(f"{self.__bl}:cryojet_settings", data.model_dump_json())
|
||||
|
||||
def get_alc_bkg(self, zoom: float) -> np.ndarray | None:
|
||||
return base64_to_numpy(self.__client.get(f"{self.__bl}:bkg{zoom:.1f}"))
|
||||
|
||||
|
||||
@@ -742,9 +742,7 @@ class AareDAQ:
|
||||
else:
|
||||
raise TransformationInvalidException()
|
||||
case BeamlineStateEnum.DataCollection:
|
||||
if target == BeamlineStateEnum.SampleExchange:
|
||||
workflows.dc2se(self.__devs, self.__cfg)
|
||||
elif target == BeamlineStateEnum.SampleAlignment:
|
||||
if target == BeamlineStateEnum.SampleAlignment:
|
||||
workflows.dc2sa(self.__devs, self.__cfg)
|
||||
elif target == BeamlineStateEnum.RobotSampleExchange:
|
||||
workflows.dc2rse(self.__devs, self.__cfg)
|
||||
|
||||
@@ -43,8 +43,10 @@ def wait_for_dc_devices(devs: BeamlineDevices):
|
||||
|
||||
def wait_for_se_devices(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
_cryo = hub.cryojet_in_use
|
||||
_cryopark = hub.cryojet_park_position
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
|
||||
_cryo = hub_cryo.cryojet_in_use
|
||||
_cryopark = hub_cryo.cryojet_park_position
|
||||
|
||||
if _cryo and not devs.cryo.position_is(_cryopark):
|
||||
raise RuntimeError("Cryojet did not reach far position")
|
||||
@@ -55,19 +57,21 @@ def common_2rse(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
devs.smargon.move_home(wait=True)
|
||||
devs.aerotech.move(ABR_OMEGA_MOUNT, wait=True, direct=True)
|
||||
devs.abr_pos = ABR_POS_MOUNT
|
||||
devs.reflector_up = False
|
||||
devs.aerotech.lock()
|
||||
|
||||
|
||||
def m2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
print("executing MAINTENANCE -> sample exchange")
|
||||
hub = cfg.settings
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
|
||||
devs.collimator = StagePositionEnum.PARK
|
||||
devs.scintillator = StagePositionEnum.DOWN
|
||||
|
||||
_dtzpark = hub.dtz_park
|
||||
_cryopark = hub.cryojet_park_position
|
||||
_cryo = hub.cryojet_in_use
|
||||
_cryopark = hub_cryo.cryojet_park_position
|
||||
_cryo = hub_cryo.cryojet_in_use
|
||||
|
||||
# devs.detector_cover.move("closed")
|
||||
if not devs.aerotech.is_ready_and_willing():
|
||||
@@ -96,7 +100,8 @@ def m2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
|
||||
def sa2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
_cryopark = hub.cryojet_park_position
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
_cryopark = hub_cryo.cryojet_park_position
|
||||
_dtzpark = hub.dtz_park
|
||||
|
||||
if devs.cryo.position < _cryopark:
|
||||
@@ -115,17 +120,14 @@ def sa2rse(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
|
||||
|
||||
def dc2rse(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
if not devs.aerotech.is_ready_and_willing():
|
||||
devs.aerotech.stop()
|
||||
time.sleep(5.0)
|
||||
raise RuntimeError("Aerotech device is not ready")
|
||||
common_2rse(devs, cfg)
|
||||
|
||||
|
||||
def se2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
_cryo = hub.cryojet_in_use
|
||||
cryo_meas = hub.cryojet_measurement_position
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
_cryo = hub_cryo.cryojet_in_use
|
||||
cryo_meas = hub_cryo.cryojet_measurement_position
|
||||
_dtz_safety = hub.dtz_bsz_safety_margin
|
||||
|
||||
devs.aerotech.unlock()
|
||||
@@ -142,16 +144,8 @@ def se2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
|
||||
|
||||
def sa2dc(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
|
||||
_cryo = hub.cryojet_in_use
|
||||
cryo_meas = hub.cryojet_measurement_position
|
||||
|
||||
devs.reflector_up = False
|
||||
|
||||
if _cryo:
|
||||
devs.cryo.move(cryo_meas)
|
||||
|
||||
#devs.reflector.wait("park")
|
||||
devs.beamstop_stage_up = True
|
||||
devs.dtz.move(cfg.dtz, wait=True)
|
||||
@@ -161,26 +155,6 @@ def sa2dc(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
wait_for_dc_devices(devs)
|
||||
|
||||
|
||||
def dc2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
_cryo = hub.cryojet_in_use
|
||||
_dtzpark = hub.dtz_park
|
||||
|
||||
devs.cryo.move(hub.cryojet_park_position)
|
||||
devs.aerotech.move(ABR_OMEGA_MOUNT, speed=180, wait=True, direct=True)
|
||||
|
||||
# devs.detector_cover.move("closed")
|
||||
|
||||
if not devs.aerotech.is_ready_and_willing():
|
||||
devs.aerotech.stop()
|
||||
time.sleep(5.0)
|
||||
raise RuntimeError("Aerotech device is not ready")
|
||||
|
||||
if devs.dtz.position < _dtzpark:
|
||||
devs.dtz.move(_dtzpark)
|
||||
devs.collimator = StagePositionEnum.PARK
|
||||
devs.reflector_up = True
|
||||
|
||||
def dc2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
devs.collimator = StagePositionEnum.PARK
|
||||
@@ -213,32 +187,39 @@ def sa2ws(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
_dtzwash = hub.dtz_wash_sample_distance
|
||||
devs.cryo.move(hub.cryojet_park_position)
|
||||
|
||||
if devs.dtz.position < _dtzwash:
|
||||
devs.dtz.move(_dtzwash)
|
||||
|
||||
devs.reflector_up = False
|
||||
devs.beamstop_stage_up = False
|
||||
|
||||
|
||||
def ws2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
cryo_meas = hub.cryojet_measurement_position
|
||||
cryo_user = hub.cryojet_measurement_user
|
||||
_cryo = hub.cryojet_in_use
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
|
||||
cryo_meas = hub_cryo.cryojet_measurement_position
|
||||
_cryo = hub_cryo.cryojet_in_use
|
||||
|
||||
if cryo_user >= cryo_meas:
|
||||
cryo_meas = cryo_user
|
||||
devs.dtz.move(cfg.dtz)
|
||||
|
||||
if _cryo:
|
||||
devs.cryo.move(cryo_meas)
|
||||
|
||||
devs.reflector_up = True
|
||||
devs.beamstop_stage_up = True
|
||||
|
||||
|
||||
def sa2ba(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
_cryopark = hub_cryo.cryojet_park_position
|
||||
_cryo = hub_cryo.cryojet_in_use
|
||||
|
||||
if _cryo:
|
||||
devs.cryo.move(_cryopark)
|
||||
|
||||
if hub.cryojet_in_use:
|
||||
devs.cryo.move(hub.cryojet_park_position)
|
||||
devs.gmx.move(-38.0)
|
||||
devs.lamp_light = 2.5
|
||||
devs.beamstop_stage_up = True
|
||||
@@ -271,6 +252,9 @@ def sa2bl(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
|
||||
def bl2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
cryo_meas = hub_cryo.cryojet_measurement_position
|
||||
_cryo = hub_cryo.cryojet_in_use
|
||||
|
||||
devs.shutter = False
|
||||
|
||||
@@ -281,8 +265,8 @@ def bl2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
devs.scintillator = StagePositionEnum.DOWN
|
||||
devs.collimator = StagePositionEnum.PARK
|
||||
|
||||
if hub.cryojet_in_use:
|
||||
devs.cryo.move(hub.cryojet_measurement_position)
|
||||
if _cryo:
|
||||
devs.cryo.move(cryo_meas)
|
||||
|
||||
devs.abr_pos = cfg.abr_meas_pos
|
||||
|
||||
|
||||
Reference in new issue
Block a user