Files
SwissMX/deltatau.py
2022-09-09 15:54:18 +02:00

43 lines
1.4 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('/tmp/zamofing_t/PBTools/'))
sys.path.insert(0, os.path.expanduser('/sf/cristallina/applications/mx/zamofing_t/PBTools/'))
import logging
_log=logging.getLogger(__name__)
from PyQt5.QtWidgets import (QApplication,)
from app_config import AppCfg #settings, option, toggle_option
from pbtools.misc.pp_comm import PPComm
from pbtools.misc.gather import Gather
import shapepath
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)