Add documentation folder, some changes to falcon_phoenix.py, phoenixtrigger.py, post_startup.py

This commit is contained in:
gac-x07mb
2024-10-15 15:39:02 +02:00
committed by wakonig_k
parent e5f004258a
commit d4b74302ef
4 changed files with 28 additions and 35 deletions

Binary file not shown.

View File

@ -160,15 +160,11 @@ def ph_create_config(line):
@register_line_magic @register_line_magic
def ph_restart_bec_server(line): def ph_restart_bec_server(line):
os.system("bec-server restart") os.system("bec-server restart")
os.system('gnome-terminal --geometry 120X50 -- bash -c "bec-server attach; exec bash"') os.system(
'gnome-terminal --geometry 120X50 -- bash -c "source /data/test/x07mb-test-bec/bec_deployment/bec_venv/bin/activate ; bec-server attach; exec bash"'
)
### enddef
##@register_line_magic
# def ph_post_startup(line):
# print('import phoenix_bec.bec_ipython_client.startup.post_startup does not work caused loop ')
# #import phoenix_bec.bec_ipython_client.startup.post_startup # #import phoenix_bec.bec_ipython_client.startup.post_startup
# does not work seems to build a infinite stack... # does not work seems to build a infinite stack...
@ -177,15 +173,15 @@ def ph_restart_bec_server(line):
# init phoenix.py from server version as # init phoenix.py from server version as
# .................. phoenix_server=PhoenixBL() # .................. phoenix_server=PhoenixBL()
# and in ipython shell only as # and in ipython shell only as
# .............. phoenix = Ph.Pheonix(BL() # .............. phoenix = Ph.Phoenix(BL()
## ##
##################################################################################### #####################################################################################
print("###############################################################") print("###############################################################")
print("init phoenix_bec/scripts/phoenix.py in two different ways") print("init phoenix_bec/scripts/phoenix.py in two different ways")
print(" 1) phoenix_server = PhoenixBL() ... takes code from server version ") print(" 1) phoenix_server = PhoenixBL() ... takes code from server version ")
print("SERBVR VERSION DOES NOT WORK ANYMORE ") print("SERVR VERSION DOES NOT WORK ANYMORE ")
print("FOLDER SCRUIPT SEEMS TO BE NON_STANDARD!!!!!!! ") print("FOLDER SCRIPT SEEMS TO BE NON_STANDARD!!!!!!! ")
phoenix_server = PhoenixBL() phoenix_server = PhoenixBL()

View File

@ -49,8 +49,10 @@ CHANGES LOG and
import enum import enum
import os import os
import threading import threading
import time
from bec_lib.logger import bec_logger from bec_lib.logger import bec_logger
from ophyd import Component as Cpt from ophyd import Component as Cpt
from ophyd import Device, EpicsSignal, EpicsSignalRO, EpicsSignalWithRBV from ophyd import Device, EpicsSignal, EpicsSignalRO, EpicsSignalWithRBV
from ophyd.mca import EpicsMCARecord from ophyd.mca import EpicsMCARecord
@ -147,7 +149,7 @@ class FalconHDF5Plugins(Device):
class FalconSetup(CustomDetectorMixin): class FalconSetup(CustomDetectorMixin):
""" """
Falcon setup class for cSAXS Falcon setup class for Phoenix
Parent class: CustomDetectorMixin Parent class: CustomDetectorMixin
@ -172,7 +174,7 @@ class FalconSetup(CustomDetectorMixin):
- value_pixel_per_buffer (int): number of spectra in buffer of Falcon Sitoro - value_pixel_per_buffer (int): number of spectra in buffer of Falcon Sitoro
""" """
self.parent.value_pixel_per_buffer = 20 # self.parent.value_pixel_per_buffer = 20
self.update_readout_time() self.update_readout_time()
def update_readout_time(self) -> None: def update_readout_time(self) -> None:
@ -186,8 +188,16 @@ class FalconSetup(CustomDetectorMixin):
def initialize_detector(self) -> None: def initialize_detector(self) -> None:
"""Initialize Falcon detector""" """Initialize Falcon detector"""
pass
"""
THIS IS THE OLD CSACS CODE. uncomment for now, as we consider EPICS as the boss
for initialization
self.stop_detector() self.stop_detector()
self.stop_detector_backend() self.stop_detector_backend()
self.set_trigger( self.set_trigger(
mapping_mode=MappingSource.MAPPING, trigger_source=TriggerSource.GATE, ignore_gate=0 mapping_mode=MappingSource.MAPPING, trigger_source=TriggerSource.GATE, ignore_gate=0
) )
@ -199,6 +209,7 @@ class FalconSetup(CustomDetectorMixin):
self.parent.auto_pixels_per_buffer.put(0) self.parent.auto_pixels_per_buffer.put(0)
# Sets the number of pixels/spectra in the buffer # Sets the number of pixels/spectra in the buffer
self.parent.pixels_per_buffer.put(self.parent.value_pixel_per_buffer) self.parent.pixels_per_buffer.put(self.parent.value_pixel_per_buffer)
"""
def initialize_detector_backend(self) -> None: def initialize_detector_backend(self) -> None:
"""Initialize the detector backend for Falcon.""" """Initialize the detector backend for Falcon."""

View File

@ -48,8 +48,10 @@ class SAMPLING(int, enum.Enum):
class PhoenixTriggerSetup(CustomDetectorMixin): class PhoenixTriggerSetup(CustomDetectorMixin):
""" """
Mixin Class to setup the PhoenixTrigger device Mixin Class to setup the PhoenixTrigger device
""" """
def on_stage(self) -> None: def on_stage(self) -> None:
@ -93,20 +95,7 @@ class PhoenixTriggerSetup(CustomDetectorMixin):
raise PhoenixTriggerError( raise PhoenixTriggerError(
f"Device {self.parent.name} is not ready to take trigger, timeout due to waiting for Falcon to get ready. Timeout after {timeout}s" f"Device {self.parent.name} is not ready to take trigger, timeout due to waiting for Falcon to get ready. Timeout after {timeout}s"
) )
start_csmpl = Cpt(e is set.
if self.parent.scaninfo.scan_type == "step":
time.sleep(0.2)
self.parent.smpl.put(1)
# Minimum of 1 cycle has to be waited. Cycle == 0.2s
time.sleep(0.2)
# Trigger function from ophyd.Device returns a DeviceStatus. This function
# starts a process that creates a DeviceStatus, and waits for the signal_conditions
# self.parent.smpl_done.get to change to the value SAMPLING.DONE
# Once this takes place, the DeviceStatus.done flag will be set to True.
# When BEC calls trigger() on the devices, this method will be called assuming that
# the devices config softwareTrigger=True is set.
# In ScanBase, the _at_each_point function calls # In ScanBase, the _at_each_point function calls
# self.stubs.wait(wait_type="trigger", group="trigger", wait_time=self.exp_time) # self.stubs.wait(wait_type="trigger", group="trigger", wait_time=self.exp_time)
# which ensures that the DeviceStatus object resolves before continuing, i.e. DeviceStatus.done = True # which ensures that the DeviceStatus object resolves before continuing, i.e. DeviceStatus.done = True
@ -159,8 +148,8 @@ class PhoenixTrigger(PSIDetectorBase):
################################################################## ##################################################################
USER_ACCESS = [] USER_ACCESS = []
#
##################################################################### ####################################################################
# specify Setup class into variable custom_prepare_cls # specify Setup class into variable custom_prepare_cls
# in __init__ of PSIDetectorBase will the initialzed by # in __init__ of PSIDetectorBase will the initialzed by
# self.custom_prepare = self.custom_prepare_cls(parent=self, **kwargs) # self.custom_prepare = self.custom_prepare_cls(parent=self, **kwargs)
@ -168,12 +157,7 @@ class PhoenixTrigger(PSIDetectorBase):
# in PhoenixTriggerSetup. # in PhoenixTriggerSetup.
###################################################################### ######################################################################
custom_prepare_cls = PhoenixTriggerSetup start_csmpl = Cpt(he base class are
#############################################################
#
# Now use Component=Cpt to provide channel access
# when PhoenixTrigger is initialized, the parameters of the base class are
# inherited, most notable prefix, which is here 'X07MB-OP2:' # inherited, most notable prefix, which is here 'X07MB-OP2:'
# #
# The input of Component=Cpt is Cpt(deviceClass,suffix) # The input of Component=Cpt is Cpt(deviceClass,suffix)
@ -213,7 +197,9 @@ class PhoenixTrigger(PSIDetectorBase):
if __name__ == "__main__": if __name__ == "__main__":
# Test the PhoenixTrigger class # Test the PhoenixTrigger class
trigger = PhoenixTrigger(name="trigger", prefix="X07MB-OP2:") trigger = PhoenixTrigger(name="trigger", prefix="X07MB-OP2:")
trigger.wait_for_connection(all_signals=True) trigger.wait_for_connection(all_signals=True)
trigger.read() trigger.read()