From d8399e901cab6278a845fe4c6a256e78dcdd77c7 Mon Sep 17 00:00:00 2001 From: Thierry Zamofing Date: Wed, 21 Sep 2022 16:11:03 +0200 Subject: [PATCH] copy current SwissMX.conf, minor fixes --- Readme.md | 18 ++++++++--------- SwissMX.conf | 31 ++++++++++++++++++++++++++++++ app_config.py | 12 ++++++------ app_utils.py | 4 ++-- epics_widgets/MotorTweak.py | 5 ++--- epics_widgets/SmaractMotorTweak.py | 2 +- psi_device.py | 7 ++++--- swissmx.py | 9 ++++++--- 8 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 SwissMX.conf diff --git a/Readme.md b/Readme.md index 13b511a..9b3dbb2 100644 --- a/Readme.md +++ b/Readme.md @@ -76,11 +76,10 @@ pyqtgraph.examples.run() ``` -Deploy stuff (22.8.22) quick and dirty ----------------------- +Deploy stuff (22.8.22) quick and dirty (21.9.22 rewworked) +---------------------------------------------------------- ``` DST=/sf/cristallina/applications/mx/zamofing_t/ -# /sf/cristallina/applications/mx ssh saresc-cons-03 mkdir /tmp/zamofing_t/ # add '--delete' if needed @@ -88,17 +87,15 @@ rsync -vai ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX saresc-cons-03:$DST rsync -vai ~/Documents/prj/SwissFEL/PBTools saresc-cons-03:$DST cd /sf/cristallina/applications/mx/zamofing_t/ESB_MX/python/SwissMX/ -/opt/gfa/python-3.7/latest/bin/python swissmx.py - /opt/gfa/python-3.8/latest/bin/pip install qtawesome --user /opt/gfa/python-3.8/latest/bin/pip install opencv-python /opt/gfa/python-3.8/latest/bin/python swissmx.py +rsync -vai gac-cristall@saresc-cons-03:~/.config/PSI/SwissMX.conf /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/SwissMX/ + cd $DST /opt/gfa/python-3.8/latest/bin/python -m pdb swissmx.py - rsync -vai saresc-cons-03:/tmp/image*.png ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/SwissMX/scratch/ - /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/SwissMX/scratch/autofocus2 ``` @@ -119,6 +116,7 @@ localhost:10001:10002 (instead SAR-CPPM-EXPMX1) ``` +----------------------------------- SCRATCH ----------------------------------- 14.9.22 external code: ---------------------- @@ -326,8 +324,10 @@ caput SAR-ESPMX:MOT_FX 0.001 caput SAR-ESPMX:MOT_FY 0.001 ---------- TODO ---------- -caput SAR-ESPMX:MOT_FX.VELO 16 -caput SAR-ESPMX:MOT_FY.VELO 16 +caput SAR-EXPMX:MOT_FX.VELO 0.001 +caput SAR-EXPMX:MOT_FX.MDEL 0.001 +caput SAR-EXPMX:MOT_FY.MDEL 0.001 +caput SAR-EXPMX:MOT_CZ.MDEL 0.001 diff --git a/SwissMX.conf b/SwissMX.conf new file mode 100644 index 0000000..2432633 --- /dev/null +++ b/SwissMX.conf @@ -0,0 +1,31 @@ +[General] +last_active=1663769422.4605258 + +[default_position] +backlight="{'pos_in': -29000.0, 'pos_out': 0.0}" +collimator="{'x_in': 10.00044, 'y_in': -2.322981, 'x_out': 10.00044, 'y_out': -2.322981}" +detector="{'pos_in': 5.0, 'pos_out': 10.0}" +post_sample_tube="{'x_in_us': -0.15010000000000012, 'y_in_us': -5.887284999999999, 'x_in_ds': -0.06905500000000053, 'y_in_ds': -5.831288, 'x_out_delta': 0.0, 'y_out_delta': -5.0, 'z_in': -3.53931, 'z_out': -3.53931}" + +[deltatau] +host=SAR-CPPM-EXPMX1 +miscellaneous="{'show_plots': true, 'vel_scl': 1.0, 'pt2pt_time': 10.0, 'sync_mode': 1, 'sync_flag': 3, 'verbose': 89}" + +[geometry] +autofocus="{'range': 1.0, 'velocity': 0.3, 'steps': 40, 'mode': 0}" +beam_pos=86.37327847910599, 189.0894517936895 +beam_size=30.2, 25.6 +cam_param="{'gain': 10.0, 'exposure': 3.0, 'binning': [1, 1], 'roi': [500, 1000, 1200, 1000], 'mono8': true}" +cam_trf="[[-1, 0, 0], [0, -1, 0], [0, 0, 1]]" +find_fiducial="{'sz': 101, 'brd': 8, 'pitch': 120, 'mode': 0}" +opt_ctr=737.1648014091753, 30.84271709492559 +pix2pos="[[1.0, 200.0, 400.0, 600.0, 800.0, 1000.0], [[[0.0011874776687831395, -3.874764193468664e-05], [-5.4202986411567655e-05, -0.0012020847338041858]], [[0.0008127767655446629, -2.5687142750131126e-05], [-3.525888389999674e-05, -0.000811545167142383]], [[0.0004932915647684639, -1.956448914762613e-05], [-2.260500843716497e-05, -0.0004979981531104616]], [[0.0002968132362841801, -1.3764033542843857e-05], [-1.1834139121941054e-05, -0.00030116315471687166]], [[0.00017925202767093252, -6.260148136189963e-06], [-7.57394284404282e-06, -0.00018089723447695783]], [[0.00010341140632662017, -6.93242588696217e-06], [-4.854849034530776e-06, -0.00010722678626793494]]]]" + +[global] +device_prefix=SAR-EXPMX, SARES30-ESBMX +miscellaneous={'img_trace_len': 16} + +[window] +geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc0\0\0\x2\xa0\0\0\v\xd5\0\0\ax\0\0\x4\xc0\0\0\x2\xc5\0\0\v\xd5\0\0\ax\0\0\0\0\0\0\0\0\xf\0) +splitter=534, 871, 397 +state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\0\0\0\a\x16\0\0\x4<\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\xe\0t\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0) diff --git a/app_config.py b/app_config.py index 2c7d36d..7cda7b2 100644 --- a/app_config.py +++ b/app_config.py @@ -96,7 +96,7 @@ class AppCfg(QSettings): if AppCfg.GEO_FND_FID not in keys: dflt.append((AppCfg.GEO_FND_FID, {'sz':101, 'brd':8, 'pitch':120, 'mode':0})) if AppCfg.GEO_AUTOFOC not in keys: - dflt.append((AppCfg.GEO_AUTOFOC, {'range':.4, 'vel':0.3, 'steps':40, 'mode':0})) + dflt.append((AppCfg.GEO_AUTOFOC, {'range':.4, 'velocity':0.3, 'steps':40, 'mode':0})) if AppCfg.GEO_OPT_CTR not in keys: dflt.append((AppCfg.GEO_OPT_CTR, np.array([603.28688025, 520.01112846]) )) if AppCfg.GEO_CAM_TRF not in keys: @@ -279,10 +279,10 @@ verbose bits: {'name':'mode', 'value':geo_fnd_fid['mode'], 'type':'int', 'step':1,'tip':'feature not yet used!'}, ]}, {'name':AppCfg.GEO_AUTOFOC, 'title':'autofocus parameters', 'type':'group', 'expanded':True, 'children':[ - {'name':'range', 'value':geo_af['range'], 'type':'float', 'limits':(0 ,3 ),'step':0.05,'suffix':'mm','decimals':3,'tip':'autofocus range (-rng/2 mm..+rng/2 mm..'}, - {'name':'velocity', 'value':geo_af['vel'] , 'type':'float', 'limits':(0 ,2), 'step':0.05,'suffix':'mm/s','decimals':3}, - {'name':'steps', 'value':geo_af['steps'], 'type':'int', 'limits':(0 ,50),'tip':'numbers of measurements in the range'}, - {'name':'mode', 'value':geo_af['mode'], 'type':'int', 'step':1,'tip':'feature not yet used!'}, + {'name':'range', 'value':geo_af['range'], 'type':'float', 'limits':(0 ,6 ),'step':0.05,'suffix':'mm','decimals':3,'tip':'autofocus range (-rng/2 mm..+rng/2 mm..'}, + {'name':'velocity', 'value':geo_af['velocity'], 'type':'float', 'limits':(0 ,2), 'step':0.05,'suffix':'mm/s','decimals':3}, + {'name':'steps', 'value':geo_af['steps'], 'type':'int', 'limits':(0 ,50),'tip':'numbers of measurements in the range'}, + {'name':'mode', 'value':geo_af['mode'], 'type':'int', 'step':1,'tip':'feature not yet used!'}, ]}, ]}, @@ -430,7 +430,7 @@ verbose bits: cfg.setValue(par_nm, v) elif nm in (AppCfg.DT_HOST): cfg.setValue(nm, param.value()) - elif par_nm in (AppCfg.GBL_MISC,AppCfg.DT_MISC): + elif par_nm in (AppCfg.GBL_MISC,AppCfg.DT_MISC,AppCfg.GEO_FND_FID,AppCfg.GEO_AUTOFOC): d=dict(map(lambda x:(x.name(),x.value()), parent.children())) cfg.setValue(par_nm, d) if par_nm in (AppCfg.GBL_MISC): diff --git a/app_utils.py b/app_utils.py index a4ab985..5b397fe 100644 --- a/app_utils.py +++ b/app_utils.py @@ -32,7 +32,7 @@ def assert_tweaker_positions(targets, timeout=60.0): motor, target, tolerance=m name=motor.short_name pend_event() - cur=motor.get_position() + cur=motor.get_rbv() done=motor.is_done() _log.debug("check {}[done={}]: {} == {}".format(name, done, cur, target)) summary.append("{}[done={}]: {} == {}".format(name, done, cur, target)) @@ -69,7 +69,7 @@ def assert_motor_positions(targets, timeout=60.0): motor, target, tolerance=m name=motor._prefix pend_event() - cur=motor.get_position(readback=True) + cur=motor.get_rbv(readback=True) done=motor.done_moving _log.debug("check {}[done={}]: {} == {}".format(name, done, cur, target)) summary.append("{}[done={}]: {} == {}".format(name, done, cur, target)) diff --git a/epics_widgets/MotorTweak.py b/epics_widgets/MotorTweak.py index a78c3f4..3d91321 100644 --- a/epics_widgets/MotorTweak.py +++ b/epics_widgets/MotorTweak.py @@ -8,9 +8,8 @@ from PyQt5.QtGui import QPainter, QBrush, QColor, QPainterPath, QPen, QDoubleVal from PyQt5.QtWidgets import QMenu, QInputDialog, QAction from PyQt5.uic import loadUiType from epics import Motor -from epics.ca import pend_event -from app_utils import assert_motor_positions +from app_utils import assert_tweaker_positions Ui_MotorTweak, QWidget = loadUiType('epics_widgets/MotorTweak.ui') SPMG_STOP = 0 @@ -150,7 +149,7 @@ class MotorTweak(QWidget, Ui_MotorTweak): m=self._motor m.move(drive, wait=wait, ignore_limits=True, relative=False) if assert_position: - assert_motor_positions([(m, drive, 0.1)], timeout=1) + assert_tweaker_positions([(self, drive, 0.1)], timeout=1) def emit_signals(self, **kw): ''' diff --git a/epics_widgets/SmaractMotorTweak.py b/epics_widgets/SmaractMotorTweak.py index 962cb7b..37f63ae 100644 --- a/epics_widgets/SmaractMotorTweak.py +++ b/epics_widgets/SmaractMotorTweak.py @@ -7,7 +7,7 @@ from PyQt5.QtWidgets import QMenu, QInputDialog, QAction from PyQt5.uic import loadUiType from epics import PV from epics.ca import pend_event -from motor_utils import assert_tweaker_positions +from app_utils import assert_tweaker_positions Ui_MotorTweak, QWidget = loadUiType('epics_widgets/MotorTweak.ui') logger = logging.getLogger(__name__) diff --git a/psi_device.py b/psi_device.py index bee36d9..983b6a5 100644 --- a/psi_device.py +++ b/psi_device.py @@ -88,12 +88,13 @@ class Jungfrau: 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._pulse_id_start=self._pv_pulse_id.value - self._daq.acquire( run_name, n_pulses=n_pulses, wait=False) + self._daq.acquire(run_name, n_pulses=n_pulses, wait=False) + pass def gather_upload(self): - self._pulse_id_end=self._pv_pulse_id.value + self._pulse_id_end=int(self._pv_pulse_id.value) _log.debug(f'pulse_id: {self._pulse_id_start}..{self._pulse_id_end}') diff --git a/swissmx.py b/swissmx.py index fb5c9fa..c6a094f 100755 --- a/swissmx.py +++ b/swissmx.py @@ -1616,7 +1616,7 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) af_range=cfg['range'] n=cfg['steps'] - vel=cfg['vel'] + vel=cfg['velocity'] rng=(-af_range/2, af_range/2) #geo.autofocus(app._camera, self.tweakers['base_z'],rng, n,dlg) af=geometry.autofocus(app._camera, self.tweakers['base_z']) @@ -2090,7 +2090,7 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) geo.least_square_plane(ptFitPlane) def cb_progress(self,i,sz,dlg): - dlg.setValue(int(sz*90/i)) + dlg.setValue(int(i*90/sz)) if dlg.wasCanceled(): raise AttributeError('canceled') @@ -2160,7 +2160,10 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) dlg.setMaximum(sp.points.shape[0]) while True: p=sp.progress() - if p<0 or dlg.wasCanceled(): + if p<0: + break + elif dlg.wasCanceled(): + dt._comm.gpascii.send_block('&1a;Gather.Enable=0') break #_log.info(f'progress {p}/{sp.points.shape[0]}') dlg.setValue(p)