From faffe10be519d14045961d499b5bc3c88f28aebc Mon Sep 17 00:00:00 2001 From: Alexander Steppke Date: Mon, 27 May 2024 17:31:44 +0200 Subject: [PATCH] reorganized channels and shutter --- beamline/components.py | 14 ++++++- channels/pv_channels.py | 2 +- cristallina.py | 89 +++++++++++++++++++---------------------- 3 files changed, 56 insertions(+), 49 deletions(-) diff --git a/beamline/components.py b/beamline/components.py index b74e926..9afaf81 100644 --- a/beamline/components.py +++ b/beamline/components.py @@ -1,3 +1,5 @@ +from loguru import logger + from slic.devices.xoptics.aramis_attenuator import Attenuator from slic.devices.xoptics.pulsepicker import PulsePicker from slic.devices.xdiagnostics.intensitymonitor import IntensityMonitorPBPS @@ -12,8 +14,18 @@ from .pp_shutter import PP_Shutter upstream_attenuator = Attenuator("SARFE10-OATT053", description="Aramis attenuator OATT053") attenuator = Attenuator("SAROP31-OATA150", description="Cristallina attenuator OATA150") +def test_attenuators(): + for att in (upstream_attenuator, attenuator): + tfundamental = att.get_transmission() + try: + assert tfundamental > 0 + except TypeError: + logger.warning("No transmission value reported from {att.ID}") + +test_attenuators() + # Shutter -shutter = PP_Shutter( +pp_shutter = PP_Shutter( "SARES30-LTIM01-EVR0:RearUniv0-Ena-SP", name="Cristallina pulse picker shutter" ) # Shutter button when using the pulse picker diff --git a/channels/pv_channels.py b/channels/pv_channels.py index 270dce8..4c49ea0 100644 --- a/channels/pv_channels.py +++ b/channels/pv_channels.py @@ -457,7 +457,7 @@ pvs_diffractometer_1 = [ "SARES30-CPCL-ECMC02:TD-PosAct", ] -pvs = ( +pv_channels = ( pvs_machine # + pvs_RF # + pvs_undulator diff --git a/cristallina.py b/cristallina.py index a2d90ae..2956935 100644 --- a/cristallina.py +++ b/cristallina.py @@ -9,8 +9,8 @@ os.chdir("/sf/cristallina/applications/slic/cristallina") def setup_general_logging(): - """ Setup logging to console and files in both the snapshots and - the respective pgroup. + """Setup logging to console and files in both the snapshots and + the respective pgroup. """ logger.remove() @@ -34,6 +34,7 @@ def setup_general_logging(): logger.warning("Cannot write log file to snapshots.") logger.warning(e) + def setup_logging_pgroup(pgroup, level="INFO"): try: logger.add( @@ -68,14 +69,13 @@ from slic.core.acquisition.fakeacquisition import FakeAcquisition from channels.bs_channels import ( - detectors, detectors, detectors_MX, bs_channels, camera_channels, ) -from channels.pv_channels import pvs +from channels.pv_channels import pv_channels from spreadsheet import overview # from channels_minimal import detectors_min, channels_min, pvs_min @@ -85,12 +85,20 @@ from spreadsheet import overview dummy = DummyAdjustable(units="au") -#from devices.knife_edge import KnifeEdge -#from devices.standa import standa -#from devices.newport import newport +# from devices.knife_edge import KnifeEdge +# from devices.standa import standa +# from devices.newport import newport -from beamline.components import upstream_attenuator, attenuator, shutter, pulsepicker, front_end_attenuator +from beamline.components import ( + upstream_attenuator, + attenuator, + pp_shutter, + pulsepicker, + alignment_laser, + pbps113, + pbps149, +) from beamline.components import kbHor, kbVer @@ -99,24 +107,11 @@ from systems.components import cta from gp_exp.components import Newport_large, OWIS - -def test_attenuator(): - tfundamental = attenuator.get_transmission() - try: - assert tfundamental > 0 - except TypeError: - logger.warning("No transmission value reported from {attenuator.ID}") - - -test_attenuator() - # Undulators from beamline import undulator undulators = undulator.Undulators() -logger.info( - f"Using undulator (Aramis) offset to PSSS energy of {undulator.energy_offset} eV." -) +logger.info(f"Using undulator (Aramis) offset to PSSS energy of {undulator.energy_offset} eV.") ## Slits @@ -139,6 +134,7 @@ diffractometer = Diffractometer("diffractometer") from crq_exp.dilsc import Dilution + dilution = Dilution() @@ -149,28 +145,27 @@ from slic.core.acquisition.spreadsheet import Spreadsheet # setup spreadsheet for transmission to stand spreadsheet = Spreadsheet( - { - "Transmission" : attenuator.trans1st, - "Upstream Transmission": upstream_attenuator.trans1st, - "Energy_setpoint" : undulators, - "Energy_offset": undulator.energy_offset, - "TD": diffractometer.td, - "TRX": diffractometer.tr_x, - "TRY": diffractometer.tr_y, - "TRXBASE": diffractometer.trx_base, - "TRYBASE": diffractometer.try_base, - "THETA": diffractometer.theta, - "TWOTHETA": diffractometer.twotheta, - "Magnet_X": dilution.x, - "Magnet_Y": dilution.y, - "Magnet_Z": dilution.z, - "DilSc_T_plato": dilution.T_plato, - "DilSc_T_pucksensor": dilution.T_pucksensor, - }, - - placeholders=("comment", "sample", "run_usable"), - host="saresc-vcons-02.psi.ch", - port=9090, + { + "Transmission": attenuator.trans1st, + "Upstream Transmission": upstream_attenuator.trans1st, + "Energy_setpoint": undulators, + "Energy_offset": undulator.energy_offset, + "TD": diffractometer.td, + "TRX": diffractometer.tr_x, + "TRY": diffractometer.tr_y, + "TRXBASE": diffractometer.trx_base, + "TRYBASE": diffractometer.try_base, + "THETA": diffractometer.theta, + "TWOTHETA": diffractometer.twotheta, + "Magnet_X": dilution.x, + "Magnet_Y": dilution.y, + "Magnet_Z": dilution.z, + "DilSc_T_plato": dilution.T_plato, + "DilSc_T_pucksensor": dilution.T_pucksensor, + }, + placeholders=("comment", "sample", "run_usable"), + host="saresc-vcons-02.psi.ch", + port=9090, ) try: @@ -183,7 +178,7 @@ try: except Exception as error: # catching excpetions with a broad net because different connection errors can occur. logger.warning(f"Cannot connect to stand server on {stand_host}. Disabling spreadsheet.") - spreadsheet = None + spreadsheet = None # spreadsheet = Spreadsheet(adjs, placeholders=PLACEHOLDERS, host="127.0.0.1", port=8080)) @@ -200,7 +195,7 @@ daq = SFAcquisition( instrument, pgroup, default_channels=bs_channels, - default_pvs=pvs, + default_pvs=pv_channels, default_detectors=detectors, rate_multiplicator=1, spreadsheet=spreadsheet, @@ -212,7 +207,7 @@ daq.update_config_pvs() from acquisition import multiple_daqs -DAQS = multiple_daqs.generate_DAQS(instrument, pgroup,bs_channels, pvs, detectors, spreadsheet) +DAQS = multiple_daqs.generate_DAQS(instrument, pgroup, bs_channels, pv_channels, detectors, spreadsheet) # daq_fake = FakeAcquisition(instrument, pgroup) # daq_PV_only = PVAcquisition(instrument, pgroup, default_channels=channels_ks) # workaround for KS not going to DB