DAQ: Magent postion code - to be tested.
This commit is contained in:
+20
-8
@@ -49,7 +49,7 @@ from aare.common.exception_handler import (
|
||||
AXCFailed,
|
||||
SmargonCommunicationError,
|
||||
TellCommunicationError,
|
||||
JFJochCommunicationError, AerotechCommunicationError
|
||||
JFJochCommunicationError, AerotechCommunicationError, MagnetPositionSensorErorr
|
||||
)
|
||||
|
||||
logger = setup_logger("aareDAQ")
|
||||
@@ -535,15 +535,15 @@ class AareDAQ:
|
||||
logger.error(f"Failed to park and dry: {e}")
|
||||
raise e
|
||||
|
||||
def __magnet_position_sensor_check(self, timeout: float = 360.0):
|
||||
def __magnet_position_sensor_check(self, timeout: float = 360.0, repeat: bool = True):
|
||||
#TODO check this works, add beamstop z controls and test.
|
||||
|
||||
# logger.info("checking beamstop")
|
||||
# if self.__devs.beamstop_z.value < 24.0:
|
||||
# raise Exception("Beamstop Z below 24.0 mm - potentially unsafe with mounting")
|
||||
if self.__devs.magnet_position_sensor.value is None:
|
||||
logger.warning("!!!!!!!!!!!!!!!!!!!!!magnet position sensor not set!!!!!!!!!!!!!!!!!!")
|
||||
logger.warning("NOT IMPLEMENTED")
|
||||
if not self.__devs.magnet_position_sensor_state or self.__devs.magnet_position_sensor_state.value == 0:
|
||||
logger.warning("!!!!!!!!!!!!!!!!!!!!!magnet position sensor not connected!!!!!!!!!!!!!!!!!!")
|
||||
raise MagnetPositionSensorErorr("Magnet position sensor not connected")
|
||||
|
||||
if self.__devs.magnet_position_sensor.value != 0:
|
||||
time.sleep(1)
|
||||
@@ -563,13 +563,25 @@ class AareDAQ:
|
||||
logger.debug(f"Checking smargon position: {self.__devs.smargon_pos}")
|
||||
logger.debug(f"Checking abr position: {self.__devs.aerotech_pos}")
|
||||
if time.perf_counter() > end:
|
||||
raise Exception(f"Magnet position sensor is not in position: {self.__devs.magnet_position_sensor_readout.value}")
|
||||
logger.warning("coudln't reach position 0 in time")
|
||||
if repeat:
|
||||
self.__devs.smargon_initialize()
|
||||
if self.__devs.magnet_position_sensor.value != 0:
|
||||
self.__magnet_position_sensor_check(timeout=timeout, repeat=False)
|
||||
elif self.__devs.magnet_position_sensor.value != 0:
|
||||
logger.warning("magnet position sensor is not in position")
|
||||
raise MagnetPositionSensorErorr(f"Magnet position sensor is not in position: {self.__devs.magnet_position_sensor_readout.value}")
|
||||
elif self.__devs.magnet_position_sensor.value == 0:
|
||||
logger.info(f"!!!!!!!!!!!!!!!!!!!!!magnet position sensor readout is 0!!!!!!!!!!!!!!!!!!")
|
||||
return True
|
||||
else:
|
||||
raise Exception(f"Magnet position sensor is in unknown state: {self.__devs.magnet_position_sensor_readout.value}")
|
||||
|
||||
if round(time.perf_counter(), 0) % 10 == 0:
|
||||
logger.info(f"!!!!!!!!!!!!!!!!!!!!!magnet position sensor readout not 0!!!!!!!!!!!!!!!!!!")
|
||||
logger.info(f"!!!!!!!!!!!!!!!!!!!!! Timeout in: {timeout} s !!!!!!!!!!!!!!!!!!")
|
||||
logger.info(f"!!!!!!!!!!!!!!!!!!!!! Time elapsed: {time.perf_counter() - start} s !!!!!!!!!!!!!!!!!!")
|
||||
|
||||
|
||||
def __mount_failure_handler(self, mount_error):
|
||||
pass
|
||||
|
||||
@@ -577,7 +589,7 @@ class AareDAQ:
|
||||
self.__devs.smargon_move_home()
|
||||
self.__devs.aerotech_pos = ABR_POS_MOUNT
|
||||
#collimator should be down!!!
|
||||
#self.__magnet_position_sensor_check(timeout=360.0)
|
||||
self.__magnet_position_sensor_check(timeout=360.0)
|
||||
self.__devs.tell.check_enable_motion()
|
||||
self.__devs.tell.wait_not_busy()
|
||||
self.__devs.tell.set_in_mount_position(True)
|
||||
|
||||
Reference in New Issue
Block a user