Initial commit

This commit is contained in:
2024-03-19 10:20:50 +01:00
commit 8755e30d3d
17 changed files with 153 additions and 0 deletions

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# TOMCAT BEC
Tomcat specific plugins and configs for BEC

0
bec_plugins/__init__.py Normal file
View File

View File

View File

@@ -0,0 +1,63 @@
"""
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
# 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 *
# SETUP BEAMLINE INFO
# from bec_client.plugins.SLS.sls_info import OperatorInfo, SLSInfo
# from bec_plugins.bec_client.plugins.MyBeamline.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
# REGISTER BEAMLINE CHECKS
# from bec_lib.bl_conditions import (
# LightAvailableCondition,
# ShutterCondition,
# )
# _light_available_condition = LightAvailableCondition(dev.sls_machine_status)
# _shutter_condition = ShutterCondition(dev.x12sa_es1_shutter_status)
# bec.bl_checks.register(_light_available_condition)
# bec.bl_checks.register(_shutter_condition)

View File

@@ -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)

View File

View File

View File

View File

View File

View File

@@ -0,0 +1,32 @@
"""
SCAN PLUGINS
All new scans should be derived from ScanBase. ScanBase provides various methods that can be customized and overriden
but they are executed in a specific order:
- self.initialize # initialize the class if needed
- self.read_scan_motors # used to retrieve the start position (and the relative position shift if needed)
- self.prepare_positions # prepare the positions for the scan. The preparation is split into multiple sub fuctions:
- self._calculate_positions # calculate the positions
- self._set_positions_offset # apply the previously retrieved scan position shift (if needed)
- self._check_limits # tests to ensure the limits won't be reached
- self.open_scan # send an open_scan message including the scan name, the number of points and the scan motor names
- self.stage # stage all devices for the upcoming acquisiton
- self.run_baseline_readings # read all devices to get a baseline for the upcoming scan
- self.pre_scan # perform additional actions before the scan starts
- self.scan_core # run a loop over all position
- self._at_each_point(ind, pos) # called at each position with the current index and the target positions as arguments
- self.finalize # clean up the scan, e.g. move back to the start position; wait everything to finish
- self.unstage # unstage all devices that have been staged before
- self.cleanup # send a close scan message and perform additional cleanups if needed
"""
# import time
# import numpy as np
# from bec_lib import MessageEndpoints, bec_logger, messages
# from scan_server.errors import ScanAbortion
# from scan_server.scans import FlyScanBase, RequestBase, ScanArgType, ScanBase
# logger = bec_logger.logger

21
setup.cfg Normal file
View File

@@ -0,0 +1,21 @@
[metadata]
name = bec_plugins
description = BEC plugins to modify the behaviour of services within the BEC framework
long_description = file: README.md
long_description_content_type = text/markdown
url = https://gitlab.psi.ch/bec/bec
project_urls =
Bug Tracker = https://gitlab.psi.ch/bec/bec/issues
classifiers =
Programming Language :: Python :: 3
Development Status :: 3 - Alpha
Topic :: Scientific/Engineering
[options]
package_dir =
= .
packages = find:
python_requires = >=3.10
[options.packages.find]
where = .

9
setup.py Normal file
View File

@@ -0,0 +1,9 @@
from setuptools import setup
if __name__ == "__main__":
setup(
# specify the additional dependencies
install_requires=[],
# if you have additional dependencies for development, specify them here
extras_require={"dev": ["pytest", "pytest-random-order", "coverage"]},
)