COMMON: updated yamls, implemented hardware url for gui, jfjoch, aerotech, bec, smargon and tell.

This commit is contained in:
appleb_m committed 2026-05-13 10:41:34 +02:00
1 parent dcdddbd546
commit 492ed28a8a
10 files changed
+250 -123

No files matched your search

+95 -4
View File
@@ -1,5 +1,8 @@
import os
from enum import Enum
from pathlib import Path
import yaml
from typing import Any, Dict
class MXBeamline(Enum):
@@ -9,6 +12,25 @@ class MXBeamline(Enum):
SIMULATED = "SIMULATED"
class BeamlineConfig:
def __init__(self):
self.beamline: MXBeamline = mx_beamline()
self.config = self._load_config()
def _load_config(self) -> Dict[str, Any]:
config_dir = Path(__file__).parent / "config"
yaml_file = config_dir / f"{self.beamline.value.lower()}.yaml"
if not yaml_file.exists():
raise FileNotFoundError(f"Config file not found: {yaml_file}")
with open(yaml_file, "r") as f:
return yaml.safe_load(f)
def get(self, key: str, default: Any = None) -> Any:
return self.config.get(key, default)
def mx_beamline() -> MXBeamline:
name = os.getenv("BEAMLINE")
if name is None:
@@ -20,12 +42,81 @@ def get_jfjoch_url(bl: MXBeamline) -> str:
"""Centralized URL resolution for JFJoch services."""
match bl:
case MXBeamline.X10SA:
return "http://sls-gpu-002:8080"
return cfg_get("daq.hardware.jfjoch_url", "http://sls-gpu-002:8080")
case MXBeamline.X06DA:
return "http://sls-gpu-001:8080"
return cfg_get("daq.hardware.jfjoch_url", "http://sls-gpu-001:8080")
case MXBeamline.SIMULATED:
return "http://localhost:8080"
return cfg_get("daq.hardware.jfjoch_url", "http://localhost:8080")
case MXBeamline.X06SA:
raise NotImplementedError("X06SA beamline not supported yet")
case _:
raise ValueError(f"unknown beamline {bl}")
raise ValueError(f"unknown beamline {bl}")
def get_beamline_config() -> BeamlineConfig:
beamline_config = BeamlineConfig()
return beamline_config
def cfg_get(path: str, default: Any = None) -> Any:
"""
Hierarchical getter for YAML entries using dotted paths, e.g.:
cfg_get("endpoints.smargon_base")
cfg_get("epics.pv_prefix")
"""
beamline_config = get_beamline_config()
node = beamline_config.config
for part in path.split("."):
if not isinstance(node, dict) or part not in node:
return default
node = node[part]
return node
def jfjoch_url() -> str | None:
return cfg_get("shared.jfjoch.jfjoch_url")
def smargon_url() -> str | None:
return cfg_get("daq.hardware.smargon_url")
def aerotech_url() -> str | None:
return cfg_get("daq.hardware.aerotech_url")
def tell_url() -> str | None:
return cfg_get("daq.hardware.tell_url")
def bec_host() -> str | None:
return cfg_get("daq.hardware.bec_url")
def redis_host() -> str | None:
return cfg_get("daq.hardware.redis_url")
def gui_sample_camera_zmq() -> str | None:
return cfg_get("gui.cameras.sample_camera_zmq_url")
def gui_prediction_zmq() -> str | None:
return cfg_get("gui.cameras.prediction_zmq_url")
def gui_beamline_camera_addr() -> str | None:
return cfg_get("gui.cameras.beamline_camera_url")
def gui_gonio_camera_addr() -> str | None:
return cfg_get("gui.cameras.gonio_camera_url")
def gui_gonio_camera_id() -> int | None:
return cfg_get("gui.cameras.gonio_camera_id")
def daq_base_url() -> str | None:
return cfg_get("gui.daq.daq_url")
# Global instance for easy import
if __name__ == "__main__":
beamline_config = BeamlineConfig()
+40 -18
View File
@@ -1,22 +1,44 @@
beamline_id: "X06DA"
gui:
cameras:
sample_camera_zmq_url: "tcp://x06da-pserv-01:9089"
prediction_zmq_url: "tcp://mx-ml:9091"
beamline_camera_url: "x06da-axis-1.psi.ch"
gonio_camera_url: "axis-accc8ed2972e.psi.ch"
gonio_camera_id: "3"
daq:
daq_url: "http://mx-x06da-queue-01.psi.ch:5210"
cameras:
sample_camera_zmq_url: "tcp://x06da-pserv-01:9089"
prediction_zmq_url: "tcp://mx-ml:9091"
beamline_camera_url: "x06da-axis-1.psi.ch"
gonio_camera_url: "axis-accc8ed2972e.psi.ch"
gonio_camera_id: "3"
daq:
daq_url: "http://mx-x06da-queue-01.psi.ch:5210"
shared:
jfjoch:
jfjoch_url: "http://sls-gpu-001:8080"
jfjoch:
jfjoch_url: "http://sls-gpu-001:8080"
daq:
hardware:
smargon_url: "http://x06da-smargopolo.psi.ch:3000"
aerotech_url: "http://x06da-smargopolo.psi.ch:5234" # Adjust if needed
tell_url: "http://x06da-tell.psi.ch:22222"
bec_url: "x06da-bec-001.psi.ch"
redis_url: "x06da-redis.psi.ch"
db:
aaredb_url: "https://mx-aaredb-dmz-01.psi.ch/dispatcher"
hardware:
smargon_url: "http://x06da-smargopolo.psi.ch:3000"
aerotech_url: "http://x06da-smargopolo.psi.ch:5234" # Adjust if needed
tell_url: "http://x06da-tell.psi.ch:22222"
bec_url: "x06da-bec-001.psi.ch"
redis_url: "x06da-redis.psi.ch"
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"
data_collection_settings:
default_raster_scan_settings:
exp_time_s: 0.02
transmission: 1.0
dtz: 150.0
default_rotation_settings:
exp_time_s: 0.02
transmission: 1.0
dtz: 150.0
start_omega_deg: 0.0
increment_omega_deg: 0.2
steps: 1800
+39 -20
View File
@@ -1,24 +1,43 @@
beamline_id: "X06SA"
redis_host:
gui:
cameras:
sample_camera_zmq_url: "tcp://x06sa-pserv-01:9089"
prediction_zmq_url: ""
beamline_camera_url: ""
gonio_camera_url: ""
gonio_camera_id: ""
daq:
daq_url: "http://mx-x06sa-queue-01.psi.ch:5210"
cameras:
sample_camera_zmq_url: "tcp://x06sa-pserv-01:9089"
prediction_zmq_url: ""
beamline_camera_url: ""
gonio_camera_url: ""
gonio_camera_id: ""
daq:
daq_url: "http://mx-x06sa-queue-01.psi.ch:5210"
shared:
jfjoch:
jfjoch_url: ""
jfjoch:
jfjoch_url: ""
daq:
hardware:
smargon_url: "http://x06sa-smargopolo.psi.ch:3000"
aerotech_url: "http://x06sa-queue-01.psi.ch:5234" # Adjust if needed
tell_url: ""
bec_url: "x06sa-bec-001.psi.ch"
redis_url: ""
db:
aaredb_url: "https://mx-aaredb-dmz-01.psi.ch/dispatcher"
hardware:
smargon_url: "http://x06sa-smargopolo.psi.ch:3000"
aerotech_url: "http://x06sa-queue-01.psi.ch:5234" # Adjust if needed
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"
data_collection_settings:
default_raster_scan_settings:
exp_time_s: 0.02
transmission: 1.0
dtz: 150.0
default_rotation_settings:
exp_time_s: 0.02
transmission: 1.0
dtz: 150.0
start_omega_deg: 0.0
increment_omega_deg: 0.2
steps: 1800
+33 -43
View File
@@ -1,54 +1,44 @@
beamline_id: "X10SA"
gui:
cameras:
sample_camera_zmq_url: "tcp://x10sa-spark-01:9091"
prediction_zmq_url: "tcp://x10sa-spark-01:9091"
beamline_camera_url: "axis-accc8eb02488.psi.ch"
gonio_camera_url: "axis-accc8ea5e463.psi.ch"
gonio_camera_id: "1"
cameras:
sample_camera_zmq_url: "tcp://x10sa-spark-01:9091"
prediction_zmq_url: "tcp://x10sa-spark-01:9091"
beamline_camera_url: "axis-accc8eb02488.psi.ch"
gonio_camera_url: "axis-accc8ea5e463.psi.ch"
gonio_camera_id: "1"
daq:
daq_url: "http://mx-x10sa-queue-01.psi.ch:5210"
daq:
daq_url: "http://mx-x10sa-queue-01.psi.ch:5210"
shared:
jfjoch:
jfjoch_url: "http://sls-gpu-002:8080"
jfjoch:
jfjoch_url: "http://sls-gpu-002:8080"
daq:
hardware:
smargon_url: "http://x10sa-smargopolo.psi.ch:3000"
aerotech_url: "http://mx-x10sa-queue-01.psi.ch:5234" # Adjust if needed
tell_url: "http://PC17488:22222"
bec_url: "x10sa-bec-001.psi.ch"
redis_url: "x10sa-redis.psi.ch"
states:
backlight_levels: {off: 0.0, half: 0.98, max: 1.2}
frontlight_levels: {off: 1.49, half: 2.0, max: 3.0}
hardware:
db:
aaredb_url: "https://mx-aaredb-dmz-01.psi.ch/dispatcher"
smargon_url: "http://x10sa-smargopolo.psi.ch:3000"
aerotech_url: "http://mx-x10sa-queue-01.psi.ch:5234" # Adjust if needed
tell_url: "http://PC17488:22222"
bec_url: "x10sa-bec-001.psi.ch"
redis_url: "x10sa-redis.psi.ch"
states:
backlight_levels: {off: 0.0, half: 0.98, max: 1.2}
frontlight_levels: {off: 1.49, half: 2.0, max: 3.0}
data_collection_settings:
default_raster_scan_settings:
exp_time_s: 0.01
transmission: 1.0
dtz: 150.0
db:
aaredb_url: "https://mx-aaredb-dmz-01.psi.ch/dispatcher"
data_collection_settings:
default_raster_scan_settings:
exp_time_s: 0.01
transmission: 1.0
dtz: 150.0
default_rotation_settings:
exp_time_s: 0.01
transmission: 1.0
dtz: 150.0
start_omega_deg: 0.0
increment_omega_deg: 1.0
steps: 1800
default_rotation_settings:
exp_time_s: 0.01
transmission: 1.0
dtz: 150.0
start_omega_deg: 0.0
increment_omega_deg: 0.2
steps: 1800
+2 -2
View File
@@ -35,7 +35,7 @@ from aare.common.auth_models import (
BatonRequestStatus,
BatonTransferQueue,
)
from aare.common.beamline import MXBeamline
from aare.common.beamline import MXBeamline, cfg_get
from aare.common.logger_config import setup_logger
from aare.common.exception_handler import BeamlineBusyException
@@ -96,7 +96,7 @@ class BeamlineConfig:
if bl is MXBeamline.SIMULATED:
host = "localhost"
else:
host = f"{self.__bl}-redis.psi.ch"
host = cfg_get("daq.hardware.redis_url", f"{self.__bl}-redis.psi.ch")
self.__client = redis.Redis(host=host, port=6379, db=0, decode_responses=True)
self.simulated_detector = bl is MXBeamline.SIMULATED
+5 -3
View File
@@ -3,7 +3,7 @@ from typing import Optional, Union
from aarescan_client.models.grid_request import GridRequest
from aarescan_client.models.screen_request import ScreenRequest
from aare.common.beamline import MXBeamline, mx_beamline
from aare.common.beamline import MXBeamline, mx_beamline, cfg_get
from aarescan_client import ApiClient, Status, RotationRequest, Configuration, DefaultApi, AxisStatus, Target
from aare.common.coordinate import AerotechCoordinate, Coordinate
@@ -17,10 +17,12 @@ class AerotechController(object):
def __init__(self, bl: MXBeamline):
if bl == MXBeamline.X06DA:
self.__simulated = False
self.__base = "http://x06da-smargopolo.psi.ch:5234"
self.__base = cfg_get("daq.hardware.aerotech_url", "http://x06da-smargopolo.psi.ch:5234")
elif bl == MXBeamline.X10SA:
self.__simulated = False
self.__base = "http://mx-x10sa-queue-01.psi.ch:5234"
self.__base = cfg_get("daq.hardware.aerotech_url", "http://mx-x10sa-queue-01.psi.ch:5234")
elif bl == MXBeamline.X06SA:
raise NotImplementedError("Not implemented aerotech url for X06SA")
elif bl == MXBeamline.SIMULATED:
self.__simulated = True
self.__pos = AEROTECH_HOME
+3 -2
View File
@@ -5,7 +5,7 @@ from bec_ipython_client.signals import OperationMode
from bec_lib.service_config import ServiceConfig
from bec_lib.procedures.helper import FrontendProcedureHelper, BackendProcedureHelper
from aare.common.beamline import MXBeamline, mx_beamline
from aare.common.beamline import MXBeamline, mx_beamline, cfg_get
from aare.common.logger_config import setup_logger
logger = setup_logger("aareDAQ")
@@ -45,7 +45,8 @@ class BECClientWorker:
self.simulated = True
else:
self.simulated = False
service_config = ServiceConfig(redis={"host": f"{BEAMLINE}-bec-001.psi.ch", "port": 6379})
host = cfg_get("daq.hardware.bec_url", f"{BEAMLINE}-bec-001.psi.ch")
service_config = ServiceConfig(redis={"host": host, "port": 6379})
service_config.config["log_writer"]["base_path"]='/tmp/logs'
self.client = BECIPythonClient(config=service_config,mode=OperationMode.Procedure)
self.client.start()
+5 -3
View File
@@ -3,7 +3,7 @@ from time import sleep, time, perf_counter
import requests
from aare.common.beamline import MXBeamline
from aare.common.beamline import MXBeamline, cfg_get
from aare.common.coordinate import SmargonCoordinate, Coordinate, AerotechCoordinate
from aare.common.exception_handler import SmargonCommunicationError
@@ -24,10 +24,12 @@ class Smargon(object):
def __init__(self, bl: MXBeamline):
if bl == MXBeamline.X06DA:
self.__simulated = False
self.__base = "http://x06da-smargopolo.psi.ch:3000"
self.__base = cfg_get("daq.hardware.smargon_url", "http://x06da-smargopolo.psi.ch:3000")
elif bl == MXBeamline.X10SA:
self.__simulated = False
self.__base = "http://x10sa-smargopolo.psi.ch:3000"
self.__base = cfg_get("daq.hardware.smargon_url", "http://x10sa-smargopolo.psi.ch:3000")
elif bl == MXBeamline.X06SA:
raise NotImplementedError("Not implemented smargon url for X06SA")
elif bl == MXBeamline.SIMULATED:
self.__simulated = True
else:
+3 -3
View File
@@ -10,7 +10,7 @@ import requests
from aare.common.exception_handler import TellCommunicationError
from aare.common.logger_config import setup_logger
from aare.common.beamline import MXBeamline # noqa: F401
from aare.common.beamline import MXBeamline, cfg_get # noqa: F401
from pshell import PShellClient
@@ -97,9 +97,9 @@ class PShellTellBackend:
def _resolve_url(bl: MXBeamline) -> str:
beamline = bl.value.lower()
if bl == MXBeamline.X06DA:
return f"http://{beamline}-tell.psi.ch:22222"
return cfg_get("daq.hardware.tell_url",f"http://{beamline}-tell.psi.ch:22222")
if bl == MXBeamline.X10SA:
return "http://PC17488:22222"
return cfg_get("daq.hardware.tell_url","http://PC17488:22222")
if bl == MXBeamline.X06SA:
raise NotImplementedError(f"TellClient not implemented for {beamline}")
if bl == MXBeamline.SIMULATED:
+25 -25
View File
@@ -8,7 +8,7 @@ from PySide6.QtWidgets import QApplication, QMessageBox
from aare.common.logger_config import setup_logger
from aare.gui.main_window import MainWindow
#from aaregui.widgets.login import LoginDialog
from aare.common.beamline import MXBeamline, mx_beamline
from aare.common.beamline import MXBeamline, mx_beamline, cfg_get
from aare.gui.auth import auth
logger = setup_logger("aareGUI")
@@ -29,33 +29,33 @@ def main():
#TODO if zmq and pred stream come from same source, do not need images from both streams, can combine
match mx_beamline():
case MXBeamline.X06DA:
default_url = "http://mx-x06da-queue-01.psi.ch:5210"
default_zmq_addr = "tcp://x06da-pserv-01:9089" #129.129.110.12:9089
default_pred_zmq_addr = "tcp://mx-ml:9091"
default_beamline_cam_addr = "x06da-axis-1.psi.ch"
default_gonio_cam_addr = "axis-accc8ed2972e.psi.ch"
default_gonio_camera_id = 3
default_url = cfg_get("gui.daq.daq_url", "http://mx-x06da-queue-01.psi.ch:5210")
default_zmq_addr = cfg_get("gui.cameras.sample_camera_zmq_url", "tcp://x06da-pserv-01:9089")
default_pred_zmq_addr = cfg_get("gui.cameras.prediction_zmq_url", "tcp://mx-ml:9091")
default_beamline_cam_addr = cfg_get("gui.cameras.beamline_camera_url", "x06da-axis-1.psi.ch")
default_gonio_cam_addr = cfg_get("gui.cameras.gonio_camera_url", "axis-accc8ed2972e.psi.ch")
default_gonio_camera_id = int(cfg_get("gui.cameras.gonio_camera_id", 3))
case MXBeamline.X10SA:
default_url = "http://mx-x10sa-queue-01.psi.ch:5210" #"http://127.0.0.1:5210"#
default_zmq_addr = "tcp://x10sa-spark-01:9091" # "tcp://x10sa-spark-01:9091" #
default_pred_zmq_addr = "tcp://x10sa-spark-01:9091" #"tcp://sls-gpu-003:9089"#""
default_beamline_cam_addr = "axis-accc8eb02488.psi.ch"
default_gonio_cam_addr = "axis-accc8ea5e463.psi.ch"
default_gonio_camera_id = 1
default_url = cfg_get("gui.daq.daq_url", "http://mx-x10sa-queue-01.psi.ch:5210")
default_zmq_addr = cfg_get("gui.cameras.sample_camera_zmq_url", "tcp://x10sa-spark-01:9091")
default_pred_zmq_addr = cfg_get("gui.cameras.prediction_zmq_url", "tcp://x10sa-spark-01:9091")
default_beamline_cam_addr = cfg_get("gui.cameras.beamline_camera_url", "axis-accc8eb02488.psi.ch")
default_gonio_cam_addr = cfg_get("gui.cameras.gonio_camera_url", "axis-accc8ea5e463.psi.ch")
default_gonio_camera_id = int(cfg_get("gui.cameras.gonio_camera_id", 1))
case MXBeamline.X06SA:
default_url = "http://mx-x06sa-queue-01.psi.ch:5210"
default_zmq_addr = ""
default_pred_zmq_addr = ""
default_beamline_cam_addr = ""
default_gonio_cam_addr = ""
default_gonio_camera_id = 1
default_url = cfg_get("gui.daq.daq_url", "http://mx-x06sa-queue-01.psi.ch:5210")
default_zmq_addr = cfg_get("gui.cameras.sample_camera_zmq_url", "")
default_pred_zmq_addr = cfg_get("gui.cameras.prediction_zmq_url", "")
default_beamline_cam_addr = cfg_get("gui.cameras.beamline_camera_url", "")
default_gonio_cam_addr = cfg_get("gui.cameras.gonio_camera_url", "")
default_gonio_camera_id = int(cfg_get("gui.cameras.gonio_camera_id", 1))
case _:
default_url = ""
default_zmq_addr = ""
default_pred_zmq_addr = ""
default_beamline_cam_addr = ""
default_gonio_cam_addr = ""
default_gonio_camera_id = 1
default_url = cfg_get("gui.daq.daq_url", "")
default_zmq_addr = cfg_get("gui.cameras.sample_camera_zmq_url", "")
default_pred_zmq_addr = cfg_get("gui.cameras.prediction_zmq_url", "")
default_beamline_cam_addr = cfg_get("gui.cameras.beamline_camera_url", "")
default_gonio_cam_addr = cfg_get("gui.cameras.gonio_camera_url", "")
default_gonio_camera_id = int(cfg_get("gui.cameras.gonio_camera_id", 1))
# Add custom options as needed
urlOption = QCommandLineOption(["u", "aaredaq-url"],