101 lines
3.5 KiB
Python
101 lines
3.5 KiB
Python
import sys,os,socket
|
|
sys.path.insert(0, os.path.expanduser('..'))
|
|
hostname=socket.gethostname()
|
|
if hostname=='ganymede':
|
|
sys.path.insert(0, os.path.expanduser('~/Documents/prj/SwissFEL/PBTools/'))
|
|
else:
|
|
sys.path.insert(0, os.path.expanduser('/sf/cristallina/applications/mx/zamofing_t/PBTools/'))
|
|
sys.path.insert(0, os.path.expanduser("/photonics/home/gac-cristall/Documents/swissmx_cristallina/slic/"))
|
|
#from slic.core.acquisition import SFAcquisition
|
|
|
|
|
|
import logging
|
|
_log=logging.getLogger(__name__)
|
|
|
|
from PyQt5.QtWidgets import (QApplication,)
|
|
from app_config import AppCfg #settings, option, toggle_option
|
|
|
|
import epics
|
|
from pbtools.misc.pp_comm import PPComm
|
|
from pbtools.misc.gather import Gather
|
|
import shapepath
|
|
|
|
try:
|
|
from slic.core.acquisition import SFAcquisition
|
|
except ImportError as e:
|
|
_log.warning(e)
|
|
|
|
|
|
class Deltatau:
|
|
def __init__(self):
|
|
app=QApplication.instance()
|
|
cfg=app._cfg
|
|
host=cfg.value(AppCfg.DT_HOST)
|
|
|
|
hpp=host.split(':')
|
|
param={'host':hpp[0]}
|
|
if len(hpp)>1:
|
|
param['port']=int(hpp[1])
|
|
if len(hpp)>2:
|
|
param['fast_gather_port']=int(hpp[2])
|
|
_log.info(' -> ssh-tunneling PPComm({host}:{port} {host}:{fast_gather_port})'.format(**param))
|
|
try:
|
|
self._comm=comm=PPComm(**param,timeout=2.0)
|
|
self._gather=gather=Gather(comm)
|
|
except (socket.timeout,socket.gaierror) as e:
|
|
_log.critical(f'can not connect to deltatau:"{host}" -> {e}')
|
|
self._comm=comm=None
|
|
self._gather=gather=None
|
|
#return
|
|
self._shapepath=sp=shapepath.ShapePath(comm, gather, verbose=0xff, sync_mode=1, sync_flag=3)
|
|
|
|
class Jungfrau:
|
|
def __init__(self):
|
|
#python /sf/jungfrau/applications/daq_client/daq_client.py -h
|
|
#python /sf/jungfrau/applications/daq_client/daq_client.py -p p19739 -t no_beam_test
|
|
# -c/sf/cristallina/config/channel_lists/channel_list_bs-e/sf/cristallina/config/channel_lists/channel_list_ca
|
|
# -f/sf/cristallina/config/jungfrau/jf_1d5M.json
|
|
# --start_pulseid 15382163895 --stop_pulseid 15382163905
|
|
#rsync -vai gac-cristall@saresc-cons-03:/sf/jungfrau/applications/daq_client/daq_client.py .
|
|
|
|
|
|
# setup slic parameters
|
|
detectors = [ { "name" : "JF17T16V01",
|
|
"adc_to_energy" : True,
|
|
"compression" : True,
|
|
"factor" : 11.33,
|
|
"geometry" : True,
|
|
"double_pixel_action" : "mask",
|
|
"remove_raw_files" : False
|
|
} ] #["JF17T16V01"]
|
|
bs_channels = [ # have timing signitures
|
|
"SARES30-LSCP1-CRISTA1:CH0:1",
|
|
# "SARES30-CAMS156-SMX-OAV:FPICTURE"
|
|
]
|
|
epics_channels = [ # no time signitures
|
|
]
|
|
|
|
try:
|
|
self._daq=SFAcquisition(
|
|
"cristallina", "p20516",
|
|
default_detectors=detectors, default_channels=bs_channels, default_pvs=epics_channels,
|
|
rate_multiplicator=1, append_user_tag_to_data_dir=True
|
|
)
|
|
except NameError as e:
|
|
_log.warning(f'Jungfrau not connected: {e}')
|
|
self._daq=None
|
|
self._pv_pulse_id=epics.PV('SAR-EXPMX-EVR0:RX-PULSEID')
|
|
self._pv_pulse_id.connect()
|
|
|
|
def acquire(self,run_name, n_pulses, wait=False):
|
|
self._pulse_id_start=int(self._pv_pulse_id.value)
|
|
if self._daq is not None:
|
|
self._daq.acquire(run_name, n_pulses=n_pulses, wait=False)
|
|
pass
|
|
|
|
def gather_upload(self):
|
|
self._pulse_id_end=int(self._pv_pulse_id.value)
|
|
_log.debug(f'pulse_id: {self._pulse_id_start}..{self._pulse_id_end}')
|
|
|
|
|