bec: debugging

This commit is contained in:
2026-06-03 09:41:50 +02:00
parent fec2bd6f8f
commit 8097fd147f
+18 -6
View File
@@ -58,30 +58,36 @@ class BECClientWorker:
BEAMLINE = beamline.value.lower()
if beamline is MXBeamline.SIMULATED:
self.simulated = True
elif beamline is MXBeamline.X06DA:
self.simulated = True
logger.debug("simulating BECClientWorker on X06DA")
else:
self.simulated = False
logger.debug(f"Initializing BECClientWorker for {BEAMLINE} beamline")
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'
#service_config.config["user_macros"]["base_path"]=f'/sls/{BEAMLINE}/config/bec/production/pxiii_bec/pxiii_bec'
#print(service_config.config)
self.client = BECIPythonClient(config=service_config,mode=OperationMode.Procedure)
self.client.start()
#self.client.config.update_session_with_file("/sls/x10sa/config/bec/production/bec/bec_lib/bec_lib/config_helper.py")
self.dev = self.client.device_manager.devices
print(self.dev.keys())
self.scans = self.client.scans
self.macros = self.client.macros
self.load_user_macros()
print(self.list_all_macros())
self.helper = FrontendProcedureHelper(self.client.connector)
self.__set_scilog_tags()
try:
self.position_devices = self.__initialise_sample_environment_devices()
self.planner = self.__planner()
if beamline is MXBeamline.X06DA:
self.position_devices, self.planner = self.__init_beamline_environment()
else:
self.position_devices = self.__initialise_sample_environment_devices()
self.planner = self.__planner()
self.__backlight_brightness = self.position_devices['bl_bright']
self.__detector_cover = self.position_devices['det_cov']
except Exception as e:
logger.error(f"Error initialising BEC devices: {e}")
#raise self._raise_bec_error(e, operation="create planner")
self.planner = None
self.simulated = True
@@ -90,6 +96,12 @@ class BECClientWorker:
self.ring_current = self.dev.sls_current.get()
logger.debug(f"simulated is {self.simulated}")
def __init_beamline_environment(self):
try:
return init_beamline_environment()
except Exception as e:
raise Exception(f"Error initialising BEC devices: {e}")
def _raise_bec_error(self, exc: Exception, *, operation: str, tags:Optional[List[str]] = None) -> None:
message = f"BEC operation '{operation}' failed: {type(exc).__name__}: {exc}"
#logger.exception(message)
@@ -510,7 +522,7 @@ if __name__ == "__main__":
# print(client.backlight_brightness)
# print('setting to OFF')
# client.backlight_brightness = BrightnessEnum.OFF
client.backlight_toggle()
#client.backlight_toggle()
print(client.get_backlight_pos())
print(client.backlight_brightness)
#client.scilog_msg("Testing scilog messages with color = yellow and italic", italic=True,