testing deployment
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .bec_client import *
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from .plugins import *
|
||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,2 @@
|
||||
from .load_additional_correction import lamni_read_additional_correction
|
||||
from .x_ray_eye_align import LamNI, XrayEyeAlign, MagLamNI, DataDrivenLamNI
|
||||
+26
-19
@@ -1,9 +1,16 @@
|
||||
import builtins
|
||||
import time
|
||||
|
||||
from rich import box
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from rich import box
|
||||
|
||||
from bec_client.plugins.cSAXS import fshclose
|
||||
from bec_client.plugins.cSAXS import epics_get, epics_put, fshclose
|
||||
|
||||
# import builtins to avoid linter errors
|
||||
dev = builtins.__dict__.get("dev")
|
||||
umv = builtins.__dict__.get("umv")
|
||||
bec = builtins.__dict__.get("bec")
|
||||
|
||||
|
||||
class LamNIOpticsMixin:
|
||||
@@ -14,18 +21,22 @@ class LamNIOpticsMixin:
|
||||
raise ValueError(f"Device {device} has no user parameter definition for {var}.")
|
||||
return param.get(var)
|
||||
|
||||
def leyey_out(self):
|
||||
def leye_out(self):
|
||||
self.loptics_in()
|
||||
fshclose()
|
||||
leyey_out = self._get_user_param_safe("leyey", "out")
|
||||
umv(dev.leyey, leyey_out)
|
||||
|
||||
epics_put("XOMNYI-XEYE-ACQ:0", 2)
|
||||
umv(dev.dttrz, 5830, dev.fttrz, 3338)
|
||||
# move rotation stage to zero to avoid problems with wires
|
||||
umv(dev.lsamrot, 0)
|
||||
umv(dev.dttrz, 5854, dev.fttrz, 2395)
|
||||
|
||||
def leye_in(self):
|
||||
bec.queue.next_dataset_number += 1
|
||||
umv(dev.dttrz, 5830 + 600, dev.fttrz, 3338 + 600)
|
||||
# move rotation stage to zero to avoid problems with wires
|
||||
umv(dev.lsamrot, 0)
|
||||
umv(dev.dttrz, 6419.677, dev.fttrz, 2959.979)
|
||||
while True:
|
||||
moved_out = (input("Did the flight tube move out? (Y/n)") or "y").lower()
|
||||
if moved_out == "y":
|
||||
@@ -50,12 +61,12 @@ class LamNIOpticsMixin:
|
||||
This will disable rt feedback, move the FZP and re-enabled the feedback.
|
||||
"""
|
||||
if "rtx" in dev and dev.rtx.enabled:
|
||||
dev.rtx.feedback_disable()
|
||||
dev.rtx.controller.feedback_disable()
|
||||
|
||||
self._lfzp_in()
|
||||
|
||||
if "rtx" in dev and dev.rtx.enabled:
|
||||
dev.rtx.feedback_enable_with_reset()
|
||||
dev.rtx.controller.feedback_enable_with_reset()
|
||||
|
||||
def loptics_in(self):
|
||||
"""
|
||||
@@ -67,7 +78,7 @@ class LamNIOpticsMixin:
|
||||
def loptics_out(self):
|
||||
"""Move out the lamni optics"""
|
||||
if "rtx" in dev and dev.rtx.enabled:
|
||||
dev.rtx.feedback_disable()
|
||||
dev.rtx.controller.feedback_disable()
|
||||
|
||||
# self.lcs_out()
|
||||
self.losa_out()
|
||||
@@ -77,7 +88,7 @@ class LamNIOpticsMixin:
|
||||
|
||||
if "rtx" in dev and dev.rtx.enabled:
|
||||
time.sleep(1)
|
||||
dev.rtx.feedback_enable_with_reset()
|
||||
dev.rtx.controller.feedback_enable_with_reset()
|
||||
|
||||
def lcs_in(self):
|
||||
# umv lcsx -1.852 lcsy -0.095
|
||||
@@ -114,15 +125,7 @@ class LamNIOpticsMixin:
|
||||
distance = -loptz_val + 85.6 + 52
|
||||
print(f"The sample is in a distance of {distance:.1f} mm from the FZP.")
|
||||
|
||||
diameters = []
|
||||
diameters[0] = 80e-6
|
||||
diameters[1] = 100e-6
|
||||
diameters[2] = 120e-6
|
||||
diameters[3] = 150e-6
|
||||
diameters[4] = 170e-6
|
||||
diameters[5] = 200e-6
|
||||
diameters[6] = 220e-6
|
||||
diameters[7] = 250e-6
|
||||
diameters = [80e-6, 100e-6, 120e-6, 150e-6, 170e-6, 200e-6, 220e-6, 250e-6]
|
||||
|
||||
mokev_val = dev.mokev.read()["mokev"]["value"]
|
||||
console = Console()
|
||||
@@ -142,7 +145,11 @@ class LamNIOpticsMixin:
|
||||
beam_size = (
|
||||
-diameter / (focal_distance * 1000) * (focal_distance * 1000 - distance) * 1e6
|
||||
)
|
||||
table.add_row(f"{diameter}", f"{focal_distance:.2f} mm", f"{beam_size:.2f} microns")
|
||||
table.add_row(
|
||||
f"{diameter*1e6:.2f} microns",
|
||||
f"{focal_distance:.2f} mm",
|
||||
f"{beam_size:.2f} microns",
|
||||
)
|
||||
|
||||
console.print(table)
|
||||
|
||||
+603
-158
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
from .cSAXS import *
|
||||
|
||||
# from .LamNI import *
|
||||
@@ -0,0 +1,108 @@
|
||||
import builtins
|
||||
|
||||
from rich import box
|
||||
from rich.table import Table
|
||||
|
||||
from bec_client.beamline_mixin import BeamlineShowInfo
|
||||
|
||||
|
||||
class BeamlineInfo(BeamlineShowInfo):
|
||||
def show(self):
|
||||
"""Display information about the current beamline status"""
|
||||
console = self._get_console()
|
||||
|
||||
table = Table(title="X12SA Info", box=box.SQUARE)
|
||||
table.add_column("Key", justify="left")
|
||||
table.add_column("Value", justify="left")
|
||||
|
||||
info = self._get_beamline_info_messages()
|
||||
self._add_op_status(table, info)
|
||||
self._add_id_gap(table, info)
|
||||
self._add_storage_ring_vac(table, info)
|
||||
self._add_shutter_status(table, info)
|
||||
self._add_mokev(table, info)
|
||||
self._add_fe_status(table, info)
|
||||
self._add_es1_valve(table, info)
|
||||
self._add_xbox1_pressure(table, info)
|
||||
self._add_xbox2_pressure(table, info)
|
||||
|
||||
console.print(table)
|
||||
|
||||
def _add_op_status(self, table, info):
|
||||
val = self._get_info_val(info, "x12sa_op_status")
|
||||
if val not in ["attended"]:
|
||||
return table.add_row("Beamline operation", val, style=self.ALARM_STYLE)
|
||||
return table.add_row("Beamline operation", val, style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_shutter_status(self, table, info):
|
||||
val = self._get_info_val(info, "x12sa_es1_shutter_status")
|
||||
if val.lower() not in ["open"]:
|
||||
return table.add_row("Shutter", val, style=self.ALARM_STYLE)
|
||||
return table.add_row("Shutter", val, style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_storage_ring_vac(self, table, info):
|
||||
val = self._get_info_val(info, "x12sa_storage_ring_vac")
|
||||
if val.lower() not in ["ok"]:
|
||||
return table.add_row("Storage ring vacuum", val, style=self.ALARM_STYLE)
|
||||
return table.add_row("Storage ring vacuum", val, style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_es1_valve(self, table, info):
|
||||
val = self._get_info_val(info, "x12sa_es1_valve")
|
||||
if val.lower() not in ["open"]:
|
||||
return table.add_row("ES1 valve", val, style=self.ALARM_STYLE)
|
||||
return table.add_row("ES1 valve", val, style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_xbox1_pressure(self, table, info):
|
||||
MAX_PRESSURE = 2e-6
|
||||
val = info["x12sa_exposure_box1_pressure"]["value"]
|
||||
if val > MAX_PRESSURE:
|
||||
return table.add_row(
|
||||
f"Exposure box 1 pressure (limit for opening the valve: {MAX_PRESSURE:.1e} mbar)",
|
||||
f"{val:.1e} mbar",
|
||||
style=self.ALARM_STYLE,
|
||||
)
|
||||
return table.add_row("Exposure box 1 pressure", f"{val:.1e} mbar", style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_xbox2_pressure(self, table, info):
|
||||
MAX_PRESSURE = 2e-6
|
||||
val = info["x12sa_exposure_box2_pressure"]["value"]
|
||||
if val > MAX_PRESSURE:
|
||||
return table.add_row(
|
||||
f"Exposure box 2 pressure (limit for opening the valve: {MAX_PRESSURE:.1e} mbar)",
|
||||
f"{val:.1e} mbar",
|
||||
style=self.ALARM_STYLE,
|
||||
)
|
||||
return table.add_row("Exposure box 2 pressure", f"{val:.1e} mbar", style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_fe_status(self, table, info):
|
||||
val = self._get_info_val(info, "x12sa_fe_status")
|
||||
return table.add_row("Front end shutter", val, style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_id_gap(self, table, info):
|
||||
val = info["x12sa_id_gap"]["value"]
|
||||
if val > 8:
|
||||
return table.add_row("ID gap", f"{val:.3f} mm", style=self.ALARM_STYLE)
|
||||
return table.add_row("ID gap", f"{val:.3f} mm", style=self.DEFAULT_STYLE)
|
||||
|
||||
def _add_mokev(self, table, info):
|
||||
val = info["x12sa_mokev"]["value"]
|
||||
return table.add_row("Selected energy (mokev)", f"{val:.3f} keV", style=self.DEFAULT_STYLE)
|
||||
|
||||
def _get_beamline_info_messages(self) -> dict:
|
||||
dev = builtins.__dict__.get("dev")
|
||||
|
||||
def _get_bl_msg(info, device_name):
|
||||
info[device_name] = dev[device_name].read(cached=True)
|
||||
|
||||
info = {}
|
||||
_get_bl_msg(info, "x12sa_op_status")
|
||||
_get_bl_msg(info, "x12sa_storage_ring_vac")
|
||||
_get_bl_msg(info, "x12sa_es1_shutter_status")
|
||||
_get_bl_msg(info, "x12sa_id_gap")
|
||||
_get_bl_msg(info, "x12sa_mokev")
|
||||
_get_bl_msg(info, "x12sa_fe_status")
|
||||
_get_bl_msg(info, "x12sa_es1_valve")
|
||||
_get_bl_msg(info, "x12sa_exposure_box1_pressure")
|
||||
_get_bl_msg(info, "x12sa_exposure_box2_pressure")
|
||||
|
||||
return info
|
||||
@@ -0,0 +1,61 @@
|
||||
"""
|
||||
Post startup script for the BEC client. This script is executed after the
|
||||
IPython shell is started. It is used to load the beamline specific
|
||||
information and to setup the prompts.
|
||||
|
||||
The script is executed in the global namespace of the IPython shell. This
|
||||
means that all variables defined here are available in the shell.
|
||||
|
||||
If needed, bec command-line arguments can be parsed here. For example, to
|
||||
parse the --session argument, add the following lines to the script:
|
||||
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--session", help="Session name", type=str, default="my_default_session")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.session == "my_session":
|
||||
print("Loading my_session session")
|
||||
from bec_plugins.bec_client.plugins.my_session import *
|
||||
else:
|
||||
print("Loading default session")
|
||||
from bec_plugins.bec_client.plugins.default_session import *
|
||||
"""
|
||||
|
||||
# pylint: disable=invalid-name, unused-import, import-error, undefined-variable, unused-variable, unused-argument, no-name-in-module
|
||||
import argparse
|
||||
|
||||
from bec_lib.core import bec_logger
|
||||
|
||||
logger = bec_logger.logger
|
||||
|
||||
logger.info("Using the cSAXS startup script.")
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--session", help="Session name", type=str, default="cSAXS")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.session == "LamNI":
|
||||
print("Loading LamNI session")
|
||||
from bec_plugins.bec_client.plugins.cSAXS import *
|
||||
from bec_plugins.bec_client.plugins.LamNI import *
|
||||
|
||||
lamni = LamNI(bec)
|
||||
|
||||
elif args.session == "cSAXS":
|
||||
print("Loading cSAXS session")
|
||||
from bec_plugins.bec_client.plugins.cSAXS import *
|
||||
|
||||
|
||||
# SETUP BEAMLINE INFO
|
||||
from bec_client.plugins.SLS.sls_info import OperatorInfo, SLSInfo
|
||||
|
||||
from bec_plugins.bec_client.plugins.cSAXS.beamline_info import BeamlineInfo
|
||||
|
||||
bec._beamline_mixin._bl_info_register(BeamlineInfo)
|
||||
bec._beamline_mixin._bl_info_register(SLSInfo)
|
||||
bec._beamline_mixin._bl_info_register(OperatorInfo)
|
||||
|
||||
# SETUP PROMPTS
|
||||
bec._ip.prompts.username = args.session
|
||||
bec._ip.prompts.status = 1
|
||||
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Pre-startup script for BEC client. This script is executed before the BEC client
|
||||
is started. It can be used to set up the BEC client configuration. The script is
|
||||
executed in the global namespace of the BEC client. This means that all
|
||||
variables defined here are available in the BEC client.
|
||||
|
||||
To set up the BEC client configuration, use the ServiceConfig class. For example,
|
||||
to set the configuration file path, add the following lines to the script:
|
||||
|
||||
import pathlib
|
||||
from bec_lib.core import ServiceConfig
|
||||
|
||||
current_path = pathlib.Path(__file__).parent.resolve()
|
||||
CONFIG_PATH = f"{current_path}/<path_to_my_config_file.yaml>"
|
||||
|
||||
config = ServiceConfig(CONFIG_PATH)
|
||||
|
||||
If this startup script defined a ServiceConfig object, the BEC client will use
|
||||
it to configure itself. Otherwise, the BEC client will use the default config.
|
||||
"""
|
||||
|
||||
# example:
|
||||
# current_path = pathlib.Path(__file__).parent.resolve()
|
||||
# CONFIG_PATH = f"{current_path}/../../../bec_config.yaml"
|
||||
# config = ServiceConfig(CONFIG_PATH)
|
||||
@@ -1,2 +0,0 @@
|
||||
from .load_additional_correction import lamni_read_additional_correction
|
||||
from .x_ray_eye_align import LamNI, XrayEyeAlign
|
||||
@@ -0,0 +1,11 @@
|
||||
# This file is used to select the BEC and Ophyd Devices version for the auto deployment process.
|
||||
# Do not edit this file unless you know what you are doing!
|
||||
|
||||
# The version can be a git tag, branch or commit hash.
|
||||
|
||||
# BEC version to use
|
||||
BEC_AUTODEPLOY_VERSION="cli_launch"
|
||||
|
||||
# ophyd_devices version to use
|
||||
OPHYD_DEVICES_AUTODEPLOY_VERSION="master"
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
# deployment script to be translated to Ansible
|
||||
BEAMLINE_REPO=gitlab.psi.ch:bec/csaxs-bec.git
|
||||
|
||||
# start redis
|
||||
# docker run --network=host --name redis-bec -d redis
|
||||
# alternative:
|
||||
# conda install redis; redis-server &
|
||||
|
||||
git clone git@$BEAMLINE_REPO
|
||||
|
||||
# get the target versions for ophyd_devices and BEC
|
||||
source ./csaxs-bec/deployment/autodeploy_versions
|
||||
|
||||
git clone -b $OPHYD_DEVICES_AUTODEPLOY_VERSION git@gitlab.psi.ch:bec/ophyd_devices.git
|
||||
git clone -b $BEC_AUTODEPLOY_VERSION git@gitlab.psi.ch:bec/bec.git
|
||||
|
||||
# install BEC
|
||||
cd bec
|
||||
source ./bin/install_bec_dev.sh
|
||||
|
||||
cd ../
|
||||
# start the BEC server
|
||||
bec-server start --config ./csaxs-bec/deployment/bec-server-config.yaml
|
||||
|
||||
Reference in New Issue
Block a user