WORKFLOWS: added logging
This commit is contained in:
@@ -6,9 +6,11 @@ from aaredaq.config import ABR_POS_MOUNT, ABR_OMEGA_MOUNT
|
||||
from aaredaq.devices import BeamlineDevices
|
||||
from aaredaq.config import BeamlineConfig
|
||||
from aaredaqlib.coordinate import Coordinate
|
||||
from aaredaqlib.logger_config import setup_logger
|
||||
from aaredaqlib.models import StagePositionEnum, SampleCameraSettings, ZoomModeEnum
|
||||
from mxlibs3.mx_lib import pv_wait
|
||||
|
||||
logger = setup_logger(__name__, "/tmp/mxlogs")
|
||||
|
||||
def move_bsz(devs: BeamlineDevices, target: float):
|
||||
if abs(target - devs.bsz.position) > 0.1:
|
||||
@@ -37,7 +39,7 @@ def wait_for_dc_devices(devs: BeamlineDevices):
|
||||
timeisup = timeout < time.time()
|
||||
if timeisup:
|
||||
if not devs.dtz.done_moving:
|
||||
print("DTZ still moving.")
|
||||
logger.info("DTZ still moving.")
|
||||
raise RuntimeError("Timeout moving devs. Dropping to maintenance.")
|
||||
|
||||
|
||||
@@ -53,18 +55,18 @@ def wait_for_se_devices(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
|
||||
|
||||
def common_2rse(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
print(time.ctime(), " moving COLLIMATOR to PARK position")
|
||||
logger.info(" moving COLLIMATOR to PARK position")
|
||||
devs.collimator = StagePositionEnum.PARK
|
||||
print(time.ctime(), " moving SMARGON to HOME position")
|
||||
logger.info(" moving SMARGON to HOME position")
|
||||
devs.smargon.move_home(wait=True)
|
||||
print(time.ctime(), " moving AEROTECH to MOUNT position")
|
||||
logger.info(" moving AEROTECH to MOUNT position")
|
||||
devs.aerotech.move(ABR_OMEGA_MOUNT, wait=True, direct=True)
|
||||
devs.abr_pos = ABR_POS_MOUNT
|
||||
print(time.ctime(), " moving REFLECTOR to DOWN position")
|
||||
logger.info(" moving REFLECTOR to DOWN position")
|
||||
devs.reflector_up = False
|
||||
print(time.ctime(), " LOCKING AEROTERCH")
|
||||
logger.info(" LOCKING AEROTERCH")
|
||||
devs.aerotech.lock()
|
||||
print(time.ctime(), f" Smargon position in RSE: {devs.smargon.readback} ABS: {devs.abr_pos.x} {devs.abr_pos.y} {devs.abr_pos.z}")
|
||||
logger.info(f" Smargon position in RSE: {devs.smargon.readback} ABS: {devs.abr_pos.x} {devs.abr_pos.y} {devs.abr_pos.z}")
|
||||
|
||||
|
||||
def m2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
@@ -112,23 +114,23 @@ def m2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
def sa2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
hub = cfg.settings
|
||||
hub_cryo = cfg.cryojet_settings
|
||||
print(time.ctime()," moving cryojet to park position")
|
||||
logger.info(" moving cryojet to park position")
|
||||
_cryopark = hub_cryo.cryojet_park_position
|
||||
_dtzpark = hub.dtz_park
|
||||
|
||||
if devs.cryo.position < _cryopark:
|
||||
devs.cryo.move(_cryopark)
|
||||
print(time.ctime(), " moving COLLIMATOR to DOWN position")
|
||||
logger.info(" moving COLLIMATOR to DOWN position")
|
||||
devs.collimator = StagePositionEnum.DOWN
|
||||
print(time.ctime(), " moving REFLECTOR to DOWN position")
|
||||
logger.info(" moving REFLECTOR to DOWN position")
|
||||
devs.reflector_up = False
|
||||
devs.beamstop_stage_up = False
|
||||
print(time.ctime(), " moving SMARGON to HOME position")
|
||||
logger.info(" moving SMARGON to HOME position")
|
||||
devs.smargon.move_home(wait=True)
|
||||
print(time.ctime(), " moving DETECTOR COVER to DOWN position")
|
||||
logger.info(" moving DETECTOR COVER to DOWN position")
|
||||
devs.detector_cover.put(1) # Close detector cover
|
||||
if devs.dtz.position < _dtzpark:
|
||||
print(time.ctime(), " moving DETECTOR to PARK position")
|
||||
logger.info(" moving DETECTOR to PARK position")
|
||||
devs.dtz.move(_dtzpark)
|
||||
|
||||
|
||||
@@ -149,22 +151,23 @@ def se2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
_cryo = hub_cryo.cryojet_in_use
|
||||
cryo_meas = hub_cryo.cryojet_measurement_position
|
||||
_dtz_safety = hub.dtz_bsz_safety_margin
|
||||
print(time.ctime(), " aerotech unlocked")
|
||||
devs.aerotech.unlock()
|
||||
logger.info("aerotech unlocked")
|
||||
devs.aerotech.set_direct_mode()
|
||||
print(time.ctime(), " moving reflector to up position")
|
||||
#devs.reflector_up = True
|
||||
print(time.ctime(), " moving beamstop to up position")
|
||||
logger.info("aerotech in direct mode")
|
||||
logger.info(" moving reflector to up position")
|
||||
devs.reflector_up = True
|
||||
logger.info("moving beamstop to up position")
|
||||
devs.beamstop_stage_up = True
|
||||
print(time.ctime(), " setting lamp to 2.5")
|
||||
logger.info(" setting lamp to 2.5")
|
||||
devs.lamp_light = 2.5
|
||||
print(time.ctime(), " moving aerotech to measure position")
|
||||
logger.info(" moving aerotech to measure position")
|
||||
devs.abr_pos = cfg.abr_meas_pos
|
||||
|
||||
if _cryo:
|
||||
print(time.ctime(), " moving cryojet to measure position")
|
||||
logger.info(" moving cryojet to measure position")
|
||||
devs.cryo.move(cryo_meas)
|
||||
print(time.ctime(), " moving detector to measure position")
|
||||
logger.info("moving detector to measure position")
|
||||
devs.dtz.move(cfg.dtz, wait=False)
|
||||
|
||||
def rse2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
@@ -172,14 +175,13 @@ def rse2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
print(time.ctime(), " moving TELL to COLD")
|
||||
devs.tell.move_cold(wait=True)
|
||||
start_time = time.time()
|
||||
print(time.ctime(), " starting se 2 sa ", start_time)
|
||||
logger.info(f"starting se 2 sa {start_time}")
|
||||
se2sa(devs, cfg)
|
||||
elapsed_time = time.time() - start_time
|
||||
remaining_time = max(0.0, 30 - elapsed_time)
|
||||
print(remaining_time)
|
||||
print(time.ctime(), " sleeping for reamining time ", remaining_time)
|
||||
logger.info(f" sleeping for remaining time {remaining_time}")
|
||||
time.sleep(remaining_time)
|
||||
print(time.ctime(), " slept for remainign time ", remaining_time)
|
||||
logger.info(f" slept for remaining time {remaining_time}")
|
||||
else:
|
||||
se2sa(devs, cfg)
|
||||
|
||||
@@ -338,6 +340,7 @@ def ba2bl(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
|
||||
|
||||
def sa2dh(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
logger.info("moved to dewer transfer")
|
||||
if devs.tell.get_mounted_sample() is not None:
|
||||
try:
|
||||
# Best effort try to unmount
|
||||
|
||||
Reference in New Issue
Block a user