@@ -62,8 +62,8 @@ from debye_bec.bec_widgets.widgets.digital_twin.widgets.qt_widgets import ComboB
|
||||
|
||||
logger = bec_logger.logger
|
||||
|
||||
OFFSET_FILE = Path(__file__).with_name("x01da_offsets.yaml")
|
||||
|
||||
OFFSET_FILE_X01DA = Path(__file__).with_name("x01da_offsets.yaml")
|
||||
OFFSET_FILE_X10DA = Path(__file__).with_name("x10da_offsets.yaml")
|
||||
|
||||
class DigitalTwin(BECWidget, QWidget):
|
||||
"""
|
||||
@@ -78,12 +78,15 @@ class DigitalTwin(BECWidget, QWidget):
|
||||
self.get_bec_shortcuts()
|
||||
|
||||
self.beamline = self.get_beamline_id()
|
||||
|
||||
# Debugging, override beamline!
|
||||
# self.beamline = BeamlineId.X10DA
|
||||
|
||||
self.offset_fie = None
|
||||
self.set_offset_file()
|
||||
self.offset_file = Path()
|
||||
match self.beamline:
|
||||
case "x01da":
|
||||
self.offset_file = OFFSET_FILE_X01DA
|
||||
case "x10da":
|
||||
self.offset_file = OFFSET_FILE_X10DA
|
||||
|
||||
# Check if devices are all in config
|
||||
self.check_bec_config()
|
||||
@@ -218,16 +221,6 @@ class DigitalTwin(BECWidget, QWidget):
|
||||
else:
|
||||
raise ValueError(f"Failed to extract beamline from bec server hostname {bec_hostname}")
|
||||
|
||||
def set_offset_file(self):
|
||||
"""
|
||||
Depending on the beamline, set the offset file path accordingly.
|
||||
"""
|
||||
files: dict[BeamlineId, str] = {
|
||||
BeamlineId.X01DA: "debye_bec/debye_bec/bec_widgets/widgets/digital_twin/x01da_offsets.yaml",
|
||||
BeamlineId.X10DA: "superxas_bec/superxas_bec/bec_widgets/widgets/digital_twin/x10da_offsets.yaml",
|
||||
}
|
||||
self.offset_file = files[self.beamline]
|
||||
|
||||
@SafeSlot()
|
||||
def check_bec_config(self, *args):
|
||||
"""
|
||||
@@ -667,10 +660,10 @@ class DigitalTwin(BECWidget, QWidget):
|
||||
|
||||
if self.offsets == {}:
|
||||
# Load offsets
|
||||
if not OFFSET_FILE.exists():
|
||||
raise FileNotFoundError(f"Offset file not found: {OFFSET_FILE}")
|
||||
|
||||
with OFFSET_FILE.open("r", encoding="utf-8") as f:
|
||||
if not self.offset_file.exists():
|
||||
raise FileNotFoundError(f"Offset file not found: {self.offset_file}")
|
||||
|
||||
with self.offset_file.open("r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f)
|
||||
|
||||
if not isinstance(data, dict):
|
||||
@@ -711,7 +704,7 @@ class DigitalTwin(BECWidget, QWidget):
|
||||
intro_label.setWordWrap(True)
|
||||
layout.addWidget(intro_label)
|
||||
|
||||
file = QLabel(str(OFFSET_FILE))
|
||||
file = QLabel(str(self.offset_file))
|
||||
file.setWordWrap(True)
|
||||
font = QFont()
|
||||
font.setItalic(True)
|
||||
|
||||
Reference in New Issue
Block a user