cleanup part 2
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
# Cristallina SLIC code
|
||||
|
||||
The basic setup to control the devices at the Cristallina endstation using mostly SLIC and EPICS behind the scenes.
|
107
cristallina.py
107
cristallina.py
@ -1,39 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from time import sleep
|
||||
|
||||
from tracemalloc import start
|
||||
import numpy as np
|
||||
|
||||
os.chdir("/sf/cristallina/applications/slic/cristallina_cleanup")
|
||||
|
||||
# at the moment this allows us to group the subdirectories as modules easily
|
||||
# TODO: a more general way would be to have this cristallina as a installed package
|
||||
os.chdir("/sf/cristallina/applications/slic/cristallina")
|
||||
|
||||
# setup logging
|
||||
from loguru import logger
|
||||
|
||||
logger.remove()
|
||||
logger.add(
|
||||
sys.stderr,
|
||||
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
|
||||
level="INFO",
|
||||
)
|
||||
logger.info("Loading started.")
|
||||
|
||||
# create file handler which logs
|
||||
# TODO: better directory for log files? should not be pgroup specific so that this always works
|
||||
try:
|
||||
def setup_logging():
|
||||
logger.remove()
|
||||
logger.add(
|
||||
"/sf/cristallina/applications/slic/cristallina/log/cristallina.log",
|
||||
sys.stderr,
|
||||
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
|
||||
level="DEBUG",
|
||||
level="INFO",
|
||||
)
|
||||
except PermissionError as e:
|
||||
logger.warning("Cannot write log file.")
|
||||
logger.warning(e)
|
||||
logger.info("Loading started.")
|
||||
|
||||
# create file handler which logs
|
||||
# TODO: better directory for log files? should not be pgroup specific so that this always works
|
||||
try:
|
||||
logger.add(
|
||||
"/sf/cristallina/applications/slic/cristallina/log/cristallina.log",
|
||||
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
|
||||
level="DEBUG",
|
||||
)
|
||||
except PermissionError as e:
|
||||
logger.warning("Cannot write log file.")
|
||||
logger.warning(e)
|
||||
|
||||
|
||||
# We setup the logging before going further so that
|
||||
# other modules can write startup messages into the log file.
|
||||
setup_logging()
|
||||
|
||||
# TODO: this is later overwritten, probably not intended that way?
|
||||
from epics import PV
|
||||
|
||||
from devices.alignment_laser import AlignmentLaser
|
||||
@ -55,6 +63,7 @@ from slic.devices.timing.events import CTASequencer
|
||||
from channels.bs_channels import detectors, bs_channels, camera_channels
|
||||
from channels.pv_channels import pvs
|
||||
from spreadsheet import overview
|
||||
|
||||
# from channels_minimal import detectors_min, channels_min, pvs_min
|
||||
from devices.pp_shutter import PP_Shutter
|
||||
|
||||
@ -69,13 +78,13 @@ try:
|
||||
stand_client = Client(host=stand_host, port=9090)
|
||||
response = stand_client.get()
|
||||
logger.info("Connected to stand server")
|
||||
except Exception as error:
|
||||
except Exception as error:
|
||||
# catching with a broad net because different connection errors can occur.
|
||||
logger.warning(f"Cannot connect to stand server on {stand_host}. Caught {error}.")
|
||||
|
||||
|
||||
# spreadsheet = Spreadsheet(adjs, placeholders=PLACEHOLDERS, host="127.0.0.1", port=8080))
|
||||
|
||||
################# DEVICES #################
|
||||
################# DEVICES #################
|
||||
dummy = DummyAdjustable(units="au")
|
||||
|
||||
# Attenuators
|
||||
@ -88,6 +97,7 @@ OWIS = Motor("SARES30-MOBI1:MOT_6") # small OWIS linear stage
|
||||
|
||||
attenuator = Attenuator("SAROP31-OATA150", description="Cristallina attenuator OATA150")
|
||||
|
||||
|
||||
def test_attenuator():
|
||||
tfundamental = attenuator.get_transmission()
|
||||
try:
|
||||
@ -98,7 +108,9 @@ def test_attenuator():
|
||||
|
||||
test_attenuator()
|
||||
|
||||
front_end_attenuator = Attenuator("SARFE10-OATT053", description="Front end attenuator OATT053")
|
||||
front_end_attenuator = Attenuator(
|
||||
"SARFE10-OATT053", description="Front end attenuator OATT053"
|
||||
)
|
||||
cta = CTASequencer("SAR-CCTA-ESC")
|
||||
|
||||
pbps113 = IntensityMonitorPBPS(
|
||||
@ -120,13 +132,16 @@ pbps149 = IntensityMonitorPBPS(
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
# Shutter
|
||||
shutter = PP_Shutter(
|
||||
"SARES30-LTIM01-EVR0:RearUniv0-Ena-SP", name="Cristallina pulse picker shutter"
|
||||
) # Shutter buttton when using the pulse picker
|
||||
) # Shutter button when using the pulse picker
|
||||
|
||||
pulsepicker = PulsePicker(
|
||||
"SAROP31-OPPI151",
|
||||
"SARES30-LTIM01-EVR0:Pul3",
|
||||
@ -134,7 +149,9 @@ pulsepicker = PulsePicker(
|
||||
)
|
||||
|
||||
# Alignment laser
|
||||
alaser = AlignmentLaser("SAROP31-OLAS147:MOTOR_1", name="Cristallina alignment laser OLAS147")
|
||||
alignment_laser = AlignmentLaser(
|
||||
"SAROP31-OLAS147:MOTOR_1", name="Cristallina alignment laser OLAS147"
|
||||
)
|
||||
|
||||
## Slits
|
||||
from slic.devices.xoptics import slits
|
||||
@ -152,10 +169,11 @@ kbVer = KBVer("SAROP31-OKBV153", description="Cristallina vertical KB mirror")
|
||||
|
||||
# Bernina monochromator
|
||||
from beamline.bernina_mono import BerninaMono
|
||||
|
||||
BerninaDCM = BerninaMono("SAROP21-ODCM098")
|
||||
|
||||
|
||||
################# DAQ Setup #################
|
||||
################# DAQ Setup #################
|
||||
instrument = "cristallina"
|
||||
|
||||
# pgroup = "p19739" # commissioning March 2022 -- July 2022
|
||||
@ -165,8 +183,8 @@ instrument = "cristallina"
|
||||
# pgroup = "p20557" # CrQ PMS commisioning 1
|
||||
# pgroup = "p20509" # CrQ commissoing DilSc1
|
||||
# pgroup = "p20519" # beamline commissioning 2
|
||||
# pgroup = "p20841" # CrQ PMS commisioning 2 (Jan 2023)
|
||||
# pgroup = "p20993" # CrQ commissoing DilSc2 (March 2023)
|
||||
# pgroup = "p20841" # CrQ PMS commisioning 2 (Jan 2023)
|
||||
# pgroup = "p20993" # CrQ commissoing DilSc2 (March 2023)
|
||||
# pgroup = "p21147" # SAXS
|
||||
# pgroup = "p21238" # Cristallina photon diagnostics p-group with Chris
|
||||
# pgroup = "p21224" # SwissMX commissioning 7
|
||||
@ -174,7 +192,7 @@ instrument = "cristallina"
|
||||
pgroup = "p19150" # Scratch
|
||||
# pgroup = "p19152" # Scratch
|
||||
|
||||
# pgroup = "p20840" # Cr beamline commisioning (Jan-Feb 2023)
|
||||
# pgroup = "p20840" # Cr beamline commisioning (Jan-Feb 2023)
|
||||
# pgroup = "p21261" # CrQ PMS-3 July 2023
|
||||
|
||||
# pgroup = "p21528" # Cr-MX Colletier 2023-09-05
|
||||
@ -190,6 +208,16 @@ daq = SFAcquisition(
|
||||
# There is a new EPICS buffer, so the archiver is no longer used. This makes sure we are taking PVs from the right place.
|
||||
daq.update_config_pvs()
|
||||
|
||||
slow_daq_test = SFAcquisition(
|
||||
instrument,
|
||||
"p19150",
|
||||
default_channels=bs_channels,
|
||||
default_pvs=pvs,
|
||||
default_detectors=detectors,
|
||||
rate_multiplicator=100,
|
||||
)
|
||||
|
||||
|
||||
# daq = FakeAcquisition(instrument, pgroup)
|
||||
# daqPV = PVAcquisition(instrument, pgroup, default_channels=channels_ks) # workaround for KS not going to DB
|
||||
|
||||
@ -208,24 +236,3 @@ gui = GUI(scan, show_goto=True, show_spec=True)
|
||||
|
||||
logger.info(f"Running at {instrument} with pgroup {pgroup}.")
|
||||
logger.info("Loading finished.")
|
||||
|
||||
|
||||
|
||||
slow_daq_test = SFAcquisition(
|
||||
instrument,
|
||||
"p19150",
|
||||
default_channels=bs_channels,
|
||||
default_pvs=pvs,
|
||||
default_detectors=detectors,
|
||||
rate_multiplicator=100,
|
||||
)
|
||||
|
||||
slow_daq = SFAcquisition(
|
||||
instrument,
|
||||
pgroup,
|
||||
default_channels=bs_channels,
|
||||
default_pvs=pvs,
|
||||
default_detectors=detectors,
|
||||
rate_multiplicator=100,
|
||||
)
|
||||
|
||||
|
2646
log/cristallina.log
2646
log/cristallina.log
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user