pre-cleanup
This commit is contained in:
121
adhoc.py
121
adhoc.py
@ -1,5 +1,9 @@
|
||||
from types import SimpleNamespace
|
||||
from time import sleep
|
||||
|
||||
from epics import PV
|
||||
|
||||
from slic.core.adjustable import Adjustable
|
||||
from slic.devices.device import Device
|
||||
from slic.devices.simpledevice import SimpleDevice
|
||||
from slic.devices.general.motor import Motor
|
||||
@ -60,3 +64,120 @@ txs = TXS()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CoupledDoubleCrystalMonoEnergyWithTimeCorrection(Adjustable):
|
||||
|
||||
def __init__(self, Id="CDCMEWTC", name="Alvra DCM coupled to FEL energy with time correction", limit_low=None, limit_high=None):
|
||||
self.limit_low = limit_low
|
||||
self.limit_high = limit_high
|
||||
|
||||
pvname_setvalue = "SAROP11-ARAMIS:ENERGY_SP" #_USER" #TODO: where did the _USER go?
|
||||
pvname_readback = "SAROP11-ARAMIS:ENERGY"
|
||||
# pvname_moving = "SGE-OP2E-ARAMIS:MOVING"
|
||||
pvname_moving = "SAROP11-ODCM105:MOVING"
|
||||
pvname_coupling = "SGE-OP2E-ARAMIS:MODE_SP"
|
||||
|
||||
pv_setvalue = PV(pvname_setvalue)
|
||||
pv_readback = PV(pvname_readback)
|
||||
pv_moving = PV(pvname_moving)
|
||||
pv_coupling = PV(pvname_coupling)
|
||||
|
||||
self.timing = Motor("SLAAR11-LMOT-M452:MOTOR_1")
|
||||
self.electron_energy_rb = PV("SARCL02-MBND100:P-READ")
|
||||
self.electron_energy_sv = PV("SGE-OP2E-ARAMIS:E_ENERGY_SP")
|
||||
|
||||
name = name or Id
|
||||
units = pv_readback.units
|
||||
super().__init__(name=name, units=units)
|
||||
|
||||
self.pvnames = SimpleNamespace(
|
||||
setvalue = pvname_setvalue,
|
||||
readback = pvname_readback,
|
||||
moving = pvname_moving,
|
||||
coupling = pvname_coupling
|
||||
)
|
||||
|
||||
self.pvs = SimpleNamespace(
|
||||
setvalue = pv_setvalue,
|
||||
readback = pv_readback,
|
||||
moving = pv_moving,
|
||||
coupling = pv_coupling
|
||||
)
|
||||
|
||||
|
||||
def get_current_value(self):
|
||||
return self.pvs.readback.get()
|
||||
|
||||
def set_target_value(self, value, hold=False):
|
||||
ll = self.limit_low
|
||||
if ll is not None:
|
||||
if value < ll:
|
||||
msg = f"requested value is outside the allowed range: {value} < {ll}"
|
||||
print(msg)
|
||||
raise KeyboardInterrupt(msg)
|
||||
lh = self.limit_high
|
||||
if lh is not None:
|
||||
if value > lh:
|
||||
msg = f"requested value is outside the allowed range: {value} > {lh}"
|
||||
print(msg)
|
||||
raise KeyboardInterrupt(msg)
|
||||
changer = lambda: self.move_and_wait(value)
|
||||
return self._as_task(changer, hold=hold, stopper=self.stop)
|
||||
|
||||
|
||||
def move_and_wait(self, value, wait_time=0.1):
|
||||
self.enable_coupling()
|
||||
|
||||
current_energy = self.get_current_value()
|
||||
delta_energy = value - current_energy
|
||||
|
||||
timing = self.timing
|
||||
current_delay = timing.get_current_value()
|
||||
delta_delay = convert_E_to_distance(delta_energy)
|
||||
target_delay = current_delay + delta_delay
|
||||
|
||||
print(f"Energy = {current_energy} -> delta = {delta_energy} -> {value}")
|
||||
print(f"Delay = {current_delay} -> delta = {delta_delay} -> {target_delay}")
|
||||
|
||||
timing.set_target_value(target_delay).wait()
|
||||
|
||||
self.pvs.setvalue.put(value)
|
||||
sleep(3) # wait so that the set value has changed
|
||||
|
||||
print("start waiting for DCM")
|
||||
while self.is_moving(): #TODO: moving PV seems broken
|
||||
sleep(wait_time)
|
||||
print("start waiting for electron beam")
|
||||
while abs(self.electron_energy_rb.get() - self.electron_energy_sv.get()) > 0.25:
|
||||
sleep(wait_time)
|
||||
sleep(wait_time)
|
||||
|
||||
|
||||
def is_moving(self):
|
||||
moving = self.pvs.moving.get()
|
||||
return bool(moving)
|
||||
|
||||
def enable_coupling(self):
|
||||
self.pvs.coupling.put(1)
|
||||
|
||||
def disable_coupling(self):
|
||||
self.pvs.coupling.put(0)
|
||||
|
||||
@property
|
||||
def coupling(self):
|
||||
return self.pvs.coupling.get(as_string=True)
|
||||
|
||||
|
||||
|
||||
def convert_E_to_distance(E):
|
||||
return 0.0061869 * E
|
||||
|
||||
|
||||
CDCMEWTC = CoupledDoubleCrystalMonoEnergyWithTimeCorrection(limit_low=2450, limit_high=2520)
|
||||
|
||||
|
||||
PSSS = Motor("SARFE10-PSSS059:MOTOR_Y3", name="PSSS XTAL y")
|
||||
|
||||
|
||||
|
||||
|
36
alvra.py
36
alvra.py
@ -1,9 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from slic.core.acquisition import BSAcquisition, DBAcquisition, DIAAcquisition, PVAcquisition, SFAcquisition
|
||||
from slic.core.acquisition.bschannels import BSChannels
|
||||
from slic.core.scanner import Scanner
|
||||
from slic.utils import Channels, Config, Elog, Screenshot, PV
|
||||
from slic.core.condition import PVCondition
|
||||
from slic.gui import GUI
|
||||
|
||||
from slic.utils import devices
|
||||
|
||||
@ -11,6 +13,14 @@ from devices import *
|
||||
from adhoc import *
|
||||
|
||||
|
||||
#TODO: why do we need this suddenly?
|
||||
try:
|
||||
from IPython import get_ipython
|
||||
get_ipython().Completer.use_jedi = False
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
#fn_cfg = "/sf/alvra/config/exp/current_experiment.json"
|
||||
fn_cfg = "/sf/alvra/config/src/python/slic/alvra/config/config.json"
|
||||
cfg = Config(fn_cfg)
|
||||
@ -21,13 +31,29 @@ screenshot = Screenshot(cfg.screenshot_directory)
|
||||
|
||||
fn_channels = "/sf/alvra/config/com/channel_lists/default_channel_list"
|
||||
#fn_channels = "/sf/alvra/config/src/python/slic/alvra/config/channel_list"
|
||||
channels = Channels(fn_channels)
|
||||
fn_detectors = "/sf/alvra/config/com/detector_lists/default_detector_list"
|
||||
fn_PV = "/sf/alvra/config/com/channel_lists/very_long_channel_list_CA"
|
||||
channels = Channels(fn_channels)
|
||||
detectors = Channels(fn_detectors)
|
||||
pvs = Channels(fn_PV)
|
||||
|
||||
detectors_disable_modules = {
|
||||
"JF02T09V02": {
|
||||
"disabled_modules": [0, 1, 2, 3, 6, 8]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
check_intensity = PVCondition("SARFE10-PBPG050:HAMP-INTENSITY-CAL", vmin=-100, vmax=300, wait_time=3, required_fraction=0.8)
|
||||
## this is probably too clever for its own good:
|
||||
#bschs = BSChannels.from_file("/sf/alvra/config/com/channel_lists/very_long_channel_list")
|
||||
#channels, pvs = bschs.online, bschs.offline
|
||||
|
||||
#bsdaqJF = DIAAcquisition(cfg.instrument, cfg.pgroup, default_channels=channels)
|
||||
bsdaqJF = SFAcquisition(cfg.instrument, cfg.pgroup, default_channels=channels)
|
||||
#channels = Channels("/sf/alvra/config/com/channel_lists/very_long_channel_list_BS")
|
||||
#pvs = Channels("/sf/alvra/config/com/channel_lists/very_long_channel_list_CA")
|
||||
|
||||
check_intensity = PVCondition("SARFE10-PBPG050:HAMP-INTENSITY-CAL", vmin=0, vmax=1500, wait_time=3, required_fraction=0.8)
|
||||
|
||||
bsdaqJF = SFAcquisition(cfg.instrument, cfg.pgroup, default_channels=channels, default_pvs=pvs, default_detectors=detectors)
|
||||
|
||||
scansJF = Scanner(
|
||||
scan_info_dir="/sf/alvra/data/{}/res/scan_info".format(cfg.pgroup),
|
||||
@ -50,7 +76,7 @@ bsdaqDB = DBAcquisition(cfg.instrument, cfg.pgroup, default_channels=channels)
|
||||
bsdaqPV = PVAcquisition(cfg.instrument, cfg.pgroup, default_channels=channels)
|
||||
|
||||
|
||||
|
||||
gui = GUI(scansJF)
|
||||
|
||||
|
||||
#for k, v in sorted(dict(globals()).items()):
|
||||
|
@ -4,7 +4,7 @@
|
||||
"elog_url": "https://elog-gfa.psi.ch/Alvra",
|
||||
"user": "gac-alvra",
|
||||
"screenshot_directory": "/sf/alvra/config/screenshots",
|
||||
"pgroup": "p17589"
|
||||
"pgroup": "p18955"
|
||||
}
|
||||
|
||||
|
||||
|
38
devices.py
38
devices.py
@ -31,18 +31,24 @@ xmic = sd.general.smaract.SmarActStage(
|
||||
|
||||
primeSample = sd.endstations.alvra_prime.Huber(
|
||||
"SARES11-XSAM125",
|
||||
z_undulator=127,
|
||||
description="Sample XYZ manipulator"
|
||||
z_undulator=125,
|
||||
name="Prime Sample Manipulator"
|
||||
)
|
||||
|
||||
primeMicroscope = sd.endstations.alvra_prime.Microscope(
|
||||
"SARES11-XMI125",
|
||||
gonio="SARES11-CMOV-SMA691113",
|
||||
rotat="SARES11-CMOV-SMA691114",
|
||||
z_undulator=127,
|
||||
description="Microscope focus and zoom"
|
||||
flexSample = sd.endstations.alvra_prime.Huber(
|
||||
"SARES12-XSAM128",
|
||||
z_undulator=128,
|
||||
name="Flex Sample Manipulator"
|
||||
)
|
||||
|
||||
#primeMicroscope = sd.endstations.alvra_prime.Microscope(
|
||||
# "SARES11-XMI125",
|
||||
# gonio="SARES11-CMOV-SMA691113",
|
||||
# rotat="SARES11-CMOV-SMA691114",
|
||||
# z_undulator=127,
|
||||
# description="Microscope focus and zoom"
|
||||
#)
|
||||
|
||||
primeTable = sd.endstations.alvra_prime.Table(
|
||||
"SARES11-XOTA125",
|
||||
z_undulator=127,
|
||||
@ -123,10 +129,10 @@ kbHor = sd.xoptics.kbhor.KBhor(
|
||||
description="Alvra horizontal KB mirror"
|
||||
)
|
||||
|
||||
kbVer = sd.xoptics.kbver.KBver(
|
||||
"SAROP11-OKBV123",
|
||||
description="Alvra vertical KB mirror"
|
||||
)
|
||||
#kbVer = sd.xoptics.kbver.KBver(
|
||||
# "SAROP11-OKBV123",
|
||||
# description="Alvra vertical KB mirror"
|
||||
#)
|
||||
|
||||
attFE = sd.xoptics.attenuator_aramis.AttenuatorAramis(
|
||||
"SARFE10-OATT053",
|
||||
@ -158,10 +164,10 @@ slitSwitch = sd.xoptics.slits.SlitBlades_old(
|
||||
description="Slit in Optics hutch after Photon switchyard and before Alvra mono"
|
||||
)
|
||||
|
||||
#slitUnd = sd.xoptics.slits.SlitFourBlades_old(
|
||||
# "SARFE10-OAPU044",
|
||||
# description="Slit after Undulator"
|
||||
#)
|
||||
slitUnd = sd.xoptics.slits.SlitFourBlades_old(
|
||||
"SARFE10-OAPU044",
|
||||
description="Slit after Undulator"
|
||||
)
|
||||
|
||||
slitAttExp = sd.xoptics.slits.SlitPosWidth_old(
|
||||
"SAROP11-OAPU120",
|
||||
|
Reference in New Issue
Block a user