DAQ: safe beamline status
This commit is contained in:
1 parent
4a874326f0
commit
09e7200aee
1 file changed
+50
-8
+50
-8
@@ -1470,23 +1470,65 @@ class AareDAQ:
|
||||
)
|
||||
return fallback, False, f"Smargon unavailable: {e}"
|
||||
|
||||
def _safe_beamline_status(self) -> BeamlineStatus:
|
||||
try:
|
||||
return self.beamline_status
|
||||
except Exception:
|
||||
return BeamlineStatus(
|
||||
name=self.__bl,
|
||||
ring_current_mA=0.0,
|
||||
front_light=0.0,
|
||||
back_light=0.0,
|
||||
cryojet_K=0.0,
|
||||
shutter_open=False,
|
||||
exp_shutter_open=None,
|
||||
flux_ph_s=0.0,
|
||||
sample_camera=SampleCameraSettings(gain=0.0, exposure=0.0),
|
||||
transmission=None,
|
||||
zoom=self.__devs.zoom,
|
||||
commissioning_mode=self.__cfg.commissioning_mode,
|
||||
dtz_min=20,
|
||||
dtz_max=1000,
|
||||
)
|
||||
|
||||
def _safe_diffraction_geometry(self) -> DiffractionGeometry:
|
||||
try:
|
||||
return self.diffraction_geometry
|
||||
except Exception:
|
||||
# Must satisfy pydantic constraints in DiffractionGeometry
|
||||
return DiffractionGeometry(
|
||||
energy_keV=12.4,
|
||||
dtz_mm=150.0,
|
||||
detector_size_pxl=(1, 1),
|
||||
pixel_size_mm=0.15,
|
||||
beam_center_pxl=(0.0, 0.0),
|
||||
detector_description="unavailable",
|
||||
detector_serial_number="unavailable",
|
||||
poni_rot1_rad=0.0,
|
||||
poni_rot2_rad=0.0,
|
||||
)
|
||||
|
||||
@property
|
||||
def status(self) -> DAQStatusModel:
|
||||
safe_sample, tell_ok, tell_err = self._safe_sample()
|
||||
safe_geom, smargon_ok, smargon_err = self._safe_geom()
|
||||
# session should be set by FastAPI server
|
||||
|
||||
return DAQStatusModel(
|
||||
state=self.state,
|
||||
busy=self.busy,
|
||||
geom=self.sample_geometry,
|
||||
bl=self.beamline_status,
|
||||
sample=self.sample,
|
||||
geom=safe_geom,
|
||||
bl=self._safe_beamline_status(),
|
||||
sample=safe_sample,
|
||||
session=SessionStatus(),
|
||||
diffraction=self.diffraction_geometry,
|
||||
diffraction=self._safe_diffraction_geometry(),
|
||||
box=self.__saved_box,
|
||||
last_best_res = self.__cfg.last_best_res,
|
||||
last_best_b_factor = self.__cfg.last_best_b_factor,
|
||||
crystal_size = self.__cfg.crystal_size
|
||||
last_best_res=self.__cfg.last_best_res,
|
||||
last_best_b_factor=self.__cfg.last_best_b_factor,
|
||||
crystal_size=self.__cfg.crystal_size,
|
||||
tell_connected=tell_ok,
|
||||
tell_error=tell_err,
|
||||
smargon_connected=smargon_ok,
|
||||
smargon_error=smargon_err,
|
||||
)
|
||||
|
||||
def cancel(self):
|
||||
|
||||
Reference in new issue
Block a user