added option to save dtz safe position in redis but currently unused, added detector limit modifier so we do not hit soft limits by mistak in yaml file. Moved Detector_Z low and high limit check to the device and out of workflows.
This commit is contained in:
@@ -12,6 +12,7 @@ gui:
|
||||
daq:
|
||||
daq_url: "https://mx-x06da-queue-01.psi.ch"
|
||||
cert_path: "/sls/x06da/misc/.cert/6d.crt"
|
||||
|
||||
shared:
|
||||
jfjoch:
|
||||
jfjoch_url: "http://sls-gpu-001:8080"
|
||||
@@ -24,9 +25,6 @@ daq:
|
||||
bec_url: "x06da-bec-001.psi.ch"
|
||||
redis_url: "x06da-redis.psi.ch"
|
||||
aarelc_url: "http://sls-gpu-003:9090"
|
||||
states:
|
||||
backlight_levels: {off: 0.0, half: 0.98, max: 1.2}
|
||||
frontlight_levels: {off: 1.49, half: 2.0, max: 3.0}
|
||||
|
||||
db:
|
||||
aaredb_url: "https://mx-aaredb-dmz-01.psi.ch/dispatcher"
|
||||
@@ -44,3 +42,5 @@ daq:
|
||||
start_omega_deg: 0.0
|
||||
increment_omega_deg: 0.2
|
||||
steps: 1800
|
||||
|
||||
detector_limit_modifier: 2.0
|
||||
@@ -22,9 +22,6 @@ daq:
|
||||
tell_url: ""
|
||||
bec_url: "x06sa-bec-001.psi.ch"
|
||||
redis_url: ""
|
||||
states:
|
||||
backlight_levels: { off: 0.0, half: 0.98, max: 1.2 }
|
||||
frontlight_levels: { off: 1.49, half: 2.0, max: 3.0 }
|
||||
|
||||
db:
|
||||
aaredb_url: "https://mx-aaredb-dmz-01.psi.ch/dispatcher"
|
||||
|
||||
@@ -24,9 +24,6 @@ daq:
|
||||
bec_url: "x10sa-bec-001.psi.ch"
|
||||
redis_url: "x10sa-redis.psi.ch"
|
||||
aarelc_url: "http://sls-gpu-003:9090"
|
||||
states:
|
||||
backlight_levels: {off: 0.0, half: 0.98, max: 1.2}
|
||||
frontlight_levels: {off: 1.49, half: 2.0, max: 3.0}
|
||||
|
||||
db:
|
||||
aaredb_url: "https://mx-aaredb-dmz-01.psi.ch/dispatcher"
|
||||
@@ -45,4 +42,4 @@ daq:
|
||||
increment_omega_deg: 0.2
|
||||
steps: 1800
|
||||
|
||||
detector_distance_minimum: 170
|
||||
detector_limit_modifier: 2.0
|
||||
+11
-1
@@ -47,7 +47,6 @@ ABR_POS_MOUNT = AerotechCoordinate(
|
||||
at_mm=Coordinate(x=0, y=0, z=0),
|
||||
omega_deg=0
|
||||
)
|
||||
#Coordinate(x=-18, y=0, z=0)
|
||||
ABR_OMEGA_MOUNT = 0.0
|
||||
|
||||
logger = setup_logger("aareDAQ")
|
||||
@@ -808,6 +807,17 @@ class BeamlineConfig:
|
||||
def dtz(self, dtz: float):
|
||||
self.__client.set(f"{self.__bl}:dtz", dtz)
|
||||
|
||||
@property
|
||||
def dtz_safe_position(self) -> float | None:
|
||||
tmp = self.__client.get(f"{self.__bl}:dtz_safe_position")
|
||||
if tmp is None:
|
||||
return 200.0
|
||||
return float(tmp)
|
||||
|
||||
@dtz_safe_position.setter
|
||||
def dtz_safe_position(self, dtz: float):
|
||||
self.__client.set(f"{self.__bl}:dtz_safe_position", dtz)
|
||||
|
||||
@property
|
||||
def xrf(self) -> FluorescenceSpectrumOutputModel | None:
|
||||
tmp = self.__client.get(f"{self.__bl}:xrf")
|
||||
|
||||
+17
-9
@@ -8,7 +8,7 @@
|
||||
import numpy as np
|
||||
from epics import PV
|
||||
|
||||
from aare.common.beamline import MXBeamline
|
||||
from aare.common.beamline import MXBeamline, cfg_get
|
||||
from aare.common.coordinate import SmargonCoordinate, AerotechCoordinate
|
||||
from aare.common.logger_config import setup_logger
|
||||
from aare.common.logger_events import log_timing
|
||||
@@ -37,12 +37,9 @@ class BeamlineDevices:
|
||||
logger.debug("initialising BEC worker done")
|
||||
self.__smargon = smargon.Smargon(beamline)
|
||||
|
||||
self.__dtz = MyMotor(f"{BEAMLINE}-ES-DET:TRZ")
|
||||
self.__dty = MyMotor(f"{BEAMLINE}-ES-DET:TRY")
|
||||
|
||||
self.__det_cov = EnumPV(name="det_cov",
|
||||
setpv=f"{BEAMLINE}-ES-DETCOV:SET",
|
||||
getpv=f"{BEAMLINE}-ES-DETCOV:GET")
|
||||
#only used at the moment to get hlm and llm from BEC
|
||||
self.__dtz = self.bec_worker.dev.det_z
|
||||
self.dtz_mod = cfg_get('daq.detector_limit_modifier', 1.0)
|
||||
|
||||
self.__sample_cam = epicsAD(f"{BEAMLINE}-ES-MS:")
|
||||
|
||||
@@ -297,18 +294,29 @@ class BeamlineDevices:
|
||||
# Detector Z
|
||||
@property
|
||||
def dtz(self) -> float:
|
||||
return self.__dtz.readback
|
||||
return self.bec_worker.get_det_z()
|
||||
|
||||
@dtz.setter
|
||||
def dtz(self, value: float):
|
||||
self.set_dtz(value, wait=True)
|
||||
|
||||
def set_dtz(self, value: float, /, wait: bool = True):
|
||||
if value < self.detector_distance_minimum:
|
||||
if value < self.__dtz.low_limit:
|
||||
#raise ValueError(f"Detector distance cannot be less than {self.detector_distance_minimum} mm")
|
||||
logger.warning(f"Requested detector distance {value} is less than minimum: {self.detector_distance_minimum}, setting to minimum")
|
||||
value = self.detector_distance_minimum
|
||||
self.__dtz.move(value, wait=wait)
|
||||
logger.warning(f"Requested detector distance {value} is less than minimum: {self.__dtz.low_limit}, setting to minimum")
|
||||
value = self.__dtz.low_limit + self.dtz_mod
|
||||
if value > self.__dtz.high_limit:
|
||||
logger.warning(f"Requested detector distance {value} is greater than maximum: {self.__dtz.high_limit}, setting to maximum")
|
||||
value = self.__dtz.high_limit - self.dtz_mod
|
||||
if wait:
|
||||
status = self.bec_worker.det_z(value, timeout=60)
|
||||
return status
|
||||
else:
|
||||
status = self.bec_worker.det_z(value)
|
||||
return status
|
||||
|
||||
@property
|
||||
def dtz_low(self) -> float:
|
||||
|
||||
+10
-60
@@ -10,52 +10,14 @@ import time
|
||||
|
||||
logger = setup_logger("aareDAQ")
|
||||
|
||||
SAFE_POSITION = 200
|
||||
|
||||
def move_bsz(devs: BeamlineDevices, target: float):
|
||||
if abs(target - devs.bsz.position) > 0.1:
|
||||
beamstop_stage_measure = devs.beamstop_stage_up
|
||||
reflector_measure = devs.reflector_up
|
||||
devs.reflector_up = False
|
||||
devs.beamstop_stage_up = True
|
||||
devs.beamstop_z = target
|
||||
|
||||
if reflector_measure:
|
||||
devs.reflector_up = True
|
||||
|
||||
if not beamstop_stage_measure:
|
||||
devs.beamstop_stage_up = False
|
||||
|
||||
|
||||
def wait_for_dc_devices(devs: BeamlineDevices):
|
||||
# Should wait for DTZ
|
||||
pass
|
||||
|
||||
def wait_for_se_devices(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
# Should wait for Cryojet go far
|
||||
pass
|
||||
SAFE_POSITION = 600
|
||||
|
||||
def common_2rse(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
if not devs.bec_worker:
|
||||
print('move collimator and scintillator to 20')
|
||||
devs.collimator = 20.0
|
||||
devs.scintillator = 20.0
|
||||
print('move smargon home')
|
||||
devs.smargon_move_home()
|
||||
print('try to move aerotech')
|
||||
devs.aerotech_pos = ABR_POS_MOUNT
|
||||
#print('move bl to park')
|
||||
#devs.reflector_up = StagePositionEnum.PARK
|
||||
print('move bs to park')
|
||||
devs.beamstop_stage_up = StagePositionEnum.PARK
|
||||
#print('move cryo to park')
|
||||
#devs.__cryojet_pos = StagePositionEnum.PARK
|
||||
else:
|
||||
devs.bec_worker.move_to(BeamlineState.ROBOT_SAMPLE_EXCHANGE)
|
||||
print('move smargon home')
|
||||
devs.smargon_move_home()
|
||||
print('try to move aerotech')
|
||||
devs.aerotech_pos = ABR_POS_MOUNT
|
||||
devs.bec_worker.move_to(BeamlineState.ROBOT_SAMPLE_EXCHANGE)
|
||||
print('move smargon home')
|
||||
devs.smargon_move_home()
|
||||
print('try to move aerotech')
|
||||
devs.aerotech_pos = ABR_POS_MOUNT
|
||||
|
||||
def rse2se(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
devs.samcam_auto(AutoEnum.AUTO)
|
||||
@@ -145,19 +107,6 @@ def rse2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
def sa2dc(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
start = time.perf_counter()
|
||||
det_z_pos = cfg.dtz
|
||||
#TODO det_z_minimum
|
||||
if not det_z_pos:
|
||||
logger.error("Detector Z position not set, defaulting to 170")
|
||||
det_z_pos = 99
|
||||
cfg.dtz = 99
|
||||
if det_z_pos and det_z_pos < 99:
|
||||
logger.warning(f"Detector Z position is less than 170: {det_z_pos}, setting to 170")
|
||||
det_z_pos = 99
|
||||
cfg.dtz = 99
|
||||
if det_z_pos and det_z_pos > 830:
|
||||
logger.warning(f"Detector Z position is greater than 1200: {det_z_pos}, setting to 1200")
|
||||
det_z_pos = 800
|
||||
cfg.dtz = 800
|
||||
status = devs.bec_worker.det_z(value=det_z_pos)
|
||||
logger.info(f"start detector move to {cfg.dtz} at {time.perf_counter() - start:.2f}")
|
||||
devs.samcam_auto(AutoEnum.AUTO)
|
||||
@@ -190,7 +139,7 @@ def xrf2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
"""XrfCollection to sample alignment"""
|
||||
pass
|
||||
|
||||
|
||||
#todo CONNECT WS AND BA MODES
|
||||
def sa2ws(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
pass
|
||||
|
||||
@@ -209,16 +158,17 @@ def ba2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
def sa2bl(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
devs.bec_worker.move_to(BeamlineState.BEAM_VISUALISATION)
|
||||
devs.samcam_settings.exposure = 0.001
|
||||
#TODO SAMCAM SETTINGS SHOULD BE HARDCODED FOR BEAM VISUALISATION STATE NOT AUTO
|
||||
|
||||
def bl2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
devs.bec_worker.move_to(BeamlineState.SAMPLE_ALIGNMENT)
|
||||
devs.samcam_auto(AutoEnum.ONCE)
|
||||
|
||||
def bl2ba(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
devs.scintillator = 20.0
|
||||
pass
|
||||
|
||||
def ba2bl(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
devs.scintillator = 20.0
|
||||
pass
|
||||
|
||||
def sa2dh(devs: BeamlineDevices, cfg: BeamlineConfig):
|
||||
common2dh(devs, cfg)
|
||||
|
||||
Reference in New Issue
Block a user