DAQ: changed print statements to log statements in mount()

This commit is contained in:
leonarski_f committed 2025-10-23 14:08:16 +02:00
1 parent 3c5b193fcc
commit 4c054006c0
1 file changed
+24 -24
+24 -24
View File
@@ -239,37 +239,36 @@ class AareDAQ:
def __mount(self, target: SampleShortInfo | None):
self.__set_state(BeamlineStateEnum.RobotSampleExchange)
self.__saved_box = None
print(f"{time.ctime()} moving smargon to home")
logger.info("Moving smargon to home")
self.__devs.smargon.move_home(wait=True)
print(f"{time.ctime()} moving aerotech to mount position")
logger.info("moving aerotech to mount position")
self.__devs.abr_pos = ABR_POS_MOUNT
time.sleep(0.5)
print(f"{time.ctime()} checking beamstop")
logger.info("checking beamstop")
if self.__devs.bsz.value < 24.0:
raise Exception("Beamstop Z below 24.0 mm - potentially unsafe with mounting")
print(f"{time.ctime()} checking magnet postion sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
print(f"{time.ctime()} checking smargon position: {self.__devs.smargon.readback}")
print(f"{time.ctime()} checking abr position: {self.__devs.abr_pos}")
logger.info(f"Checking magnet postion sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
logger.info(f"Checking smargon position: {self.__devs.smargon.readback}")
logger.info(f"Checking abr position: {self.__devs.abr_pos}")
if self.__devs.magnet_position_sensor.value != 0:
time.sleep(5)
print("!!!!!!!!!!!!!!!!!!!!!MAGNET CONTROLLER BROKE AGAIN!!!!!!!!!!!!!!!!!!")
print(f"{time.ctime()} checking magnet position sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
print(f"{time.ctime()} checking smargon position: {self.__devs.smargon.readback}")
print(f"{time.ctime()} checking abr position: {self.__devs.abr_pos}")
logger.warning("!!!!!!!!!!!!!!!!!!!!!MAGNET CONTROLLER BROKE AGAIN!!!!!!!!!!!!!!!!!!")
logger.debug(f"Checking magnet position sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
logger.debug(f"Checking smargon position: {self.__devs.smargon.readback}")
logger.debug(f"Checking abr position: {self.__devs.abr_pos}")
if self.__devs.magnet_position_sensor.value != 0:
print(time.ctime())
start = time.time()
end = start + 360
while self.__devs.magnet_position_sensor.value != 0:
time.sleep(1)
print(f"checking magnet position sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
print(f"{time.ctime()} checking smargon position: {self.__devs.smargon.readback}")
print(f"{time.ctime()} checking abr position: {self.__devs.abr_pos}")
logger.debug(f"Checking magnet position sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
logger.debug(f"Checking smargon position: {self.__devs.smargon.readback}")
logger.debug(f"Checking abr position: {self.__devs.abr_pos}")
if time.time() > end:
raise Exception(f"Magnet position sensor is not in position: {self.__devs.magnet_position_sensor_readout.value}")
#Reenable TELL after doors locked
print(f"{time.ctime()} enable tell motion after doors locked")
logger.info("enable tell motion after doors locked")
self.__devs.tell.check_enable_motion()
#self.__devs.tell.wait_mount_complete()
@@ -280,18 +279,18 @@ class AareDAQ:
# time.sleep(30)
# self.__devs.tell.check_enable_motion()
print(f"{time.ctime()} moving tell to mount position")
logger.debug("Moving tell to mount position")
self.__devs.tell.set_in_mount_position(True)
curr_sample = self.__cfg.current_sample
print(f"{time.ctime()} waiting for tell to be ready")
logger.info("Waiting for tell to be ready")
self.__devs.tell.wait_ready()
if curr_sample is not None and curr_sample.location is None:
print(f"{time.ctime()} unmounting current sample")
logger.info(f"Unmounting current sample")
# TODO: Smarter way to know manual sample has be removed from goniometer
self.__aare.sample_unmounted(curr_sample)
self.__cfg.current_sample = None
elif target is None:
print(f"{time.ctime()} moving tell to unmount with no target")
logger.info(f"Moving tell to unmount with no target")
self.__devs.tell.unmount(wait=True, timeout=360)
self.__aare.sample_unmounted(curr_sample)
self.__cfg.current_sample = None
@@ -299,9 +298,9 @@ class AareDAQ:
# reset zoom
self.zoom = 1
# mount sample
print(f"{time.ctime()} moving tell to unmount")
logger.info(f"Moving tell to unmount")
self.__aare.sample_unmounted(curr_sample)
print(f"{time.ctime()} moving tell to mount")
logger.info(f"Moving tell to mount")
self.__devs.tell.mount(
address=target.tell_address(),
force=True,
@@ -310,7 +309,7 @@ class AareDAQ:
wait=True,
timeout=360,
)
print(f"{time.ctime()} post tell mount, pre db input")
logger.debug(f"Post tell mount, pre db input")
self.__aare.sample_mounted(target)
self.__cfg.current_sample = target
if target is not None and target.db_id is not None:
@@ -328,7 +327,8 @@ class AareDAQ:
try:
curr_sample = self.__cfg.current_sample
curr_sample_is_manual = False
logger.info(f"current sample: {curr_sample}")
logger.info(f"new target is: {target}")
self.crystal_size = CrystalSize(x=0, y=0, z=0)
self.last_best_b_factor = None
self.last_best_res = None
@@ -1075,7 +1075,7 @@ class AareDAQ:
samples = self.prepare_height_samples(boxes, area=True)
#logger.info(f"height vs angle samples: {samples}")
#area_fn, best_angle_deg, params = self.fit_area_vs_angle(samples)
area_fn, best_angle_deg, params = self.fit_area_vs_angle(samples)
A, B, phi = self.fit_cosine_height(samples)
#logger.info(f"cosine fit: A={A}, B={B}, phi={phi}")
#A, B, phi = params["A"], params["B"], params["phi_rad"]