enhance simulation

This commit is contained in:
2023-06-29 10:02:42 +02:00
parent bd7d71b0b0
commit 681b8f2953
2 changed files with 43 additions and 33 deletions

View File

@@ -60,30 +60,30 @@ class Shutter:
_log.info('shutter closed')
class Deltatau:
def __init__(self):
def __init__(self,sim=False):
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}')
if sim:
self._comm=comm=None
self._gather=gather=None
#return
else:
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._shapepath=sp=shapepath.ShapePath(comm, gather, verbose=0xff, sync_mode=1, sync_flag=3)
class Jungfrau:
def __init__(self):
def __init__(self,sim=False):
#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
@@ -91,6 +91,9 @@ class Jungfrau:
# --start_pulseid 15382163895 --stop_pulseid 15382163905
#rsync -vai gac-cristall@saresc-cons-03:/sf/jungfrau/applications/daq_client/daq_client.py .
# setup slic parameters
if sim:
self._daq=None
return
app=QApplication.instance()
cfg=app._cfg
detectors = [ cfg.value(AppCfg.DAQ_DET) ]
@@ -103,13 +106,15 @@ class Jungfrau:
default_detectors=detectors, default_channels=bs_channels, default_pvs=pv_channels,
rate_multiplicator=1, append_user_tag_to_data_dir=True
)
self._pv_pulse_id=epics.PV('SAR-EXPMX-EVR0:RX-PULSEID')
self._pv_pulse_id.connect()
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()
_log.critical(f'Jungfrau not connected: {e}')
def acquire(self, n_pulses, wait=False):
if self._daq is None:
_log.info(f'simulated')
return
app=QApplication.instance()
cfg=app._cfg
run=cfg.value(AppCfg.DAQ_RUN)
@@ -118,14 +123,17 @@ class Jungfrau:
except TypeError as e:
_log.warning(f'failed to get _pulse_id_start: {e}')
if self._daq is not None:
#n_pulses_run = n_pulses + run['padding']
#self._daq.acquire(run['prefix'], n_pulses=min(n_pulses_run, 5000), n_repeat=ceil(n_pulses_run/5000), wait=False, cell_name=run['cell_name'])
self._daq.acquire(run['prefix'], n_pulses=n_pulses, wait=False)
n_pulses_run = n_pulses + run['padding']
self._daq.acquire(run['prefix'], n_pulses=min(n_pulses_run, 5000), n_repeat=ceil(n_pulses_run/5000), wait=False, cell_name=run['cell_name'])
#self._daq.acquire(run['prefix'], n_pulses=n_pulses, wait=False)
pass
#run['id']+=1
cfg.setValue(AppCfg.DAQ_RUN,run)
def gather_upload(self):
if self._daq is None:
_log.info(f'simulated')
return
try:
self._pulse_id_end=int(self._pv_pulse_id.value)
except TypeError as e: