DAQ: Fix magnet position sensor PVs and simplify logic of the check
This commit is contained in:
+9
-41
@@ -534,53 +534,21 @@ class AareDAQ:
|
||||
logger.error(f"Failed to park and dry: {e}")
|
||||
raise e
|
||||
|
||||
def __magnet_position_sensor_check(self, timeout: float = 10.0, repeat: bool = True):
|
||||
def __magnet_position_sensor_check(self, timeout: float = 1.0, repeat: bool = True):
|
||||
#TODO check this works, add beamstop z controls and test.
|
||||
#There is a problem with the amgent sensor pvs
|
||||
|
||||
# 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 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")
|
||||
logger.warning("THERE IS A PROBLEM WITH THE MAGNET SENSOR PVS PLEASE FIX")
|
||||
if self.__devs.magnet_position_sensor_readout.value != 0:
|
||||
time.sleep(1)
|
||||
logger.warning("!!!!!!!!!!!!!!!!!!!!!magnet position sensor readout not 0!!!!!!!!!!!!!!!!!!")
|
||||
logger.debug(f"Checking magnet position sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
|
||||
logger.debug(f"Checking smargon position: {self.__devs.smargon_pos}")
|
||||
logger.debug(f"Checking abr position: {self.__devs.aerotech_pos}")
|
||||
if self.__devs.magnet_position_sensor.value != 0:
|
||||
logger.warning("!!!!!!!!!!!!!!!!!!!!!magnet position sensor readout not 0!!!!!!!!!!!!!!!!!!")
|
||||
logger.info(f"!!!!!!!!!!!!!!!!!!!!!Starting to wait for magnet position sensor to be 0!!!!!!!!!!!!!!!!!!")
|
||||
logger.info(f"!!!!!!!!!!!!!!!!!!!!! Timeout in: {timeout} s !!!!!!!!!!!!!!!!!!")
|
||||
start = time.perf_counter()
|
||||
end = start + timeout
|
||||
while self.__devs.magnet_position_sensor.value != 0:
|
||||
time.sleep(1)
|
||||
logger.debug(f"Checking magnet position sensor positon: {self.__devs.magnet_position_sensor_readout.value}")
|
||||
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:
|
||||
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 self.__devs.magnet_position_sensor.value != 0:
|
||||
logger.warning("Goniometer is not in position based on magnet position sensor readout")
|
||||
for i in range(round(timeout * 10.0)):
|
||||
if self.__devs.magnet_position_sensor.value == 0:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
logger.error("Goniometer didn't reach position based on magnet position sensor readout")
|
||||
raise Exception("Goniometer is not in position based on magnet position sensor readout")
|
||||
|
||||
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
|
||||
|
||||
@@ -101,14 +101,11 @@ class BeamlineDevices:
|
||||
|
||||
self.__cryojet_x = MyMotor(f"{BEAMLINE}-ES-CS:TRX") #currently in is 5 out is 15?
|
||||
|
||||
#TODO TEST MAGNET POSITON SENSOR
|
||||
self.magnet_position_sensor = PV(f"{BEAMLINE}-ES-DF1:CBOX-CMP1")
|
||||
self.magnet_position_sensor_readout = PV(f"{BEAMLINE}-ES-DF1:CBOX-USER1")
|
||||
self.magnet_position_sensor = PV(f"{BEAMLINE}-ES-DFS:CBOX-CMP1")
|
||||
self.magnet_position_sensor_readout = PV(f"{BEAMLINE}-ES-DFS:CBOX-USER1")
|
||||
self.magnet_position_sensor_state = PV(f"{BEAMLINE}-ES-DFS:CBOX-STATE")
|
||||
|
||||
|
||||
|
||||
|
||||
# Transmission
|
||||
@property
|
||||
def transmission(self) -> float:
|
||||
|
||||
Reference in New Issue
Block a user