Files
SwissMX/Readme.md

11 KiB

pyqtgraph examples

ipython3
import pyqtgraph.examples
pyqtgraph.examples.run()

EPICS simulator

This provides very dummy images and motor(to be done) records

cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/EpicsSim/iocBoot/iocSwissMxSim
./st.cmd

simulate camera (with EPICS simulator)

cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/SwissMX
EPICS_CA_ADDR_LIST=localhost
./simCam.py 

test camera display

cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/SwissMX
EPICS_CA_ADDR_LIST=localhost
./camera.py -u -b SwissMxSim

test at ESC

https://git.psi.ch/SwissMX/swissmx_cristallina/-/wikis/Instructions%20on%20how%20to%20use%20software

P=ESB_MX/python/SwissMX/
ssh saresc-cons-02 mkdir -p /tmp/zamofing_t/$P
rsync -vai ~/Documents/prj/SwissFEL/epics_ioc_modules/$P saresc-cons-02:/tmp/zamofing_t/$P
cd /tmp/zamofing_t/ESB_MX/python/SwissMX
/opt/gfa/python-3.7/2018.12/bin/python camera.py -u 1 -p SARES30-CAMS156-SMX-OAV

/opt/gfa/python-3.7/2018.12/bin/python swissmx.py


caqtdm -macro 'NAME=SARES30-CAMS156-SMX-OAV,CAMNAME=SARES30-CAMS156-SMX-OAV' /sf/controls/config/qt/Camera/CameraExpert_RF.ui

try revive Zac code

cd /tmp/; git clone https://github.com/malcolmreynolds/transformations.git
cd /tmp/transformations.git
-> modify __init__.py -> .transformation (add dot)
setup.py install --user


cd /tmp/; git clone https://github.com/spyder-ide/qtawesome.git
cd /tmp/qtawesome

#To have epics channels we must be connected to the ESC network
EPICS_CA_ADDR_LIST='129.129.244.255 sf-saresc-cagw.psi.ch:5062 sf-saresc-cagw.psi.ch:5066'
cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/oldRepos/app/src
python swissmx.py 

pyqtgraph examples

import pyqtgraph.examples
pyqtgraph.examples.run() 

Deploy stuff (22.8.22) quick and dirty

DST=/sf/cristallina/applications/mx/zamofing_t/
# /sf/cristallina/applications/mx

ssh saresc-cons-03 mkdir /tmp/zamofing_t/
# add '--delete'  if needed
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 

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

16.9.22 remote Deltatau test:

(s.a. /home/zamofing_t/Documents/prj/SwissFEL/PBTools/pbtools/gather/PBGatherPlot.py

PPMAC=SAR-CPPM-EXPMX1
rsync -va ~/Documents/prj/SwissFEL/PBTools/pbtools/gather/gather_server root@$PPMAC:/tmp/

ssh root@$PPMAC
LD_LIBRARY_PATH=/opt/ppmac/libppmac/ /tmp/gather_server
ssh -L 10001:localhost:22 root@$PPMAC 'uname -a'
ssh -L 10002:localhost:2332 root@$PPMAC 'uname -a'
Deltatau host in config:
localhost:10001:10002 (instead SAR-CPPM-EXPMX1)

14.9.22 external code:


ssh gac-cristall@saresc-cons-03
pw: ValToira_2021
cd Documents/swissmx_cristallina/scripts/

Jungfrau stuff:
https://docs.google.com/document/d/1892j2eMsoFmufg-gdXKcSbOLcTDxLHULiNw-iZWAIVc/edit
'Beam synchronous DAQ with run_control'

Check:
~/Documents/swissmx_cristallina/scripts/Chip_align.py
sys.path.insert(0, os.path.expanduser("/photonics/home/gac-cristall/Documents/swissmx_cristallina/slic/"))
from slic.core.acquisition import SFAcquisition


# 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
] 

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
)


if acquire == "True":
    daq.acquire( run_name, n_pulses=n_pulses, wait=False)




Beam synchronous DAQ with with daq_control (command line)
Python script:
> 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


cd /tmp/; git clone https://github.com/malcolmreynolds/transformations.git cd /tmp/transformations.git -> modify init.py -> .transformation (add dot) setup.py install --user

cd /tmp/; git clone https://github.com/spyder-ide/qtawesome.git cd /tmp/qtawesome

#To have epics channels we must be connected to the ESC network EPICS_CA_ADDR_LIST='129.129.244.255 sf-saresc-cagw.psi.ch:5062 sf-saresc-cagw.psi.ch:5066' cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/oldRepos/app/src python swissmx.py




caQtDM -macro 'P=SAR-EXPMX' /photonics/home/gac-cristall/Documents/swissmx_cristallina/gui/SwissMX_ChipMotion.ui
caQtDM -macro 'P=SAR-EXPMX' ESB_MX_exp.ui

Camera:
caget SARES30-CAMS156-SMX-OAV:CAMERASTATUS
caget SARES30-CAMS156-SMX-OAV:PICTURE

Zoom:
caget  SAR-EXPMX-FETURA:POS_RB


wlp2s0:          MAC: 80:38:fb:d6:01:78   wlan-corp 129.129.64.249
enx00e04c680519: MAC: 00:e0:4c:68:05:19


Benchmark -> VideoSpeedTest

rsync -vai /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/SwissMX/ saresc-cons-02:/tmp/zamofing_t/ 


/opt/gfa/python-3.5/latest/bin/python camera.py --base-pv SARES30-CAMS156-SMX-OAV

BASE=~/Documents/prj/SwissFEL/epics_ioc_modules/LakeShore
cd $BASE/iocBoot/iocLakeShore1
../../bin/UB20-x86_64/LakeShore st.cmd



[saresc-cons-02 ~]$ ioc records 'SARES30-CAMS156-SMX-OAV:.*'


SARES30-CAMS156-SMX-OAV:PICTURE           waveform          CCD Picure Col                            SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:FPICTURE          waveform          CCD Picture                               SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:RF_FPICTURE       waveform          Reduced frequency FPICTURE                SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:WIDTH             ai                Nr. of Pixel width                        SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:HEIGHT            ai                Nr. of Pixel height                       SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:EXPOSURE          ao                Exposure                                  SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:CAMROI_X_START    ao                ROI X Start                               SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:CAMROI_X_END      ao                ROI X End                                 SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:CAMROI_Y_START    ao                ROI Y Start                               SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:CAMROI_Y_END      ao                ROI Y End                                 SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:BINX              ao                Binning X                                 SARES30-CPCW-CAMS156-SMX-OAV  office  
SARES30-CAMS156-SMX-OAV:BINY              ao                Binning Y                                 SARES30-CPCW-CAMS156-SMX-OAV  office  

waveform:
	Native DBF type: DBF_SHORT
	Number of elements: 5000

SARES30-CAMS156-SMX-OAV:WIDTH 2448 
SARES30-CAMS156-SMX-OAV:HEIGHT 2048 

caqtdm camsf
caqtdm -macro 'NAME=SARES30-CAMS156-SMX-OAV,CAMNAME=SARES30-CAMS156-SMX-OAV' /sf/controls/config/qt/Camera/CameraMiniView_RF.ui
caqtdm -macro 'NAME=SARES30-CAMS156-SMX-OAV,CAMNAME=SARES30-CAMS156-SMX-OAV' /sf/controls/config/qt/Camera/CameraExpert_RF.ui
caqtdm -macro'P=SAR-EXPMX' ESB_MX_exp.ui




03 last file: /sf/controls/config/qt/Camera/CameraMiniView_RF.ui, macro: NAME=SARES30-CAMS156-SMX-OAV,CAMNAME=SARES30-CAMS156-SMX-OAV


07-07-2022 12:14:03 last file: /sf/controls/config/qt/Camera/CameraMiniView_RF.ui, macro: NAME=SARES30-CAMS156-SMX-OAV,CAMNAME=SARES30-CAMS156-SMX-OAV
mkdir EpicsSim
cd EpicsSim
makeBaseApp.pl -t ioc SwissMxSim
makeBaseApp.pl -a UB20-x86_64 -i -t ioc -p SwissMxSim SwissMxSim

cd ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/EpicsSim/iocBoot/iocSwissMxSim
./st.cmd

EPICS_CA_ADDR_LIST=localhost
ipython3
import epics
p = epics.PV('SwissMxSim:PICTURE', auto_monitor=False)
print(p.info)
import numpy as np
a=np.arange(10000,dtype=np.uint16) 
p.put(a)
print(p.get())
https://pyepics.github.io/pyepics/arrays.html




caput SAR-EXPMX:MOT_FX.RBV -2.700
caput SAR-EXPMX:MOT_FY.RBV -7.450
caput SAR-EXPMX:MOT_CZ.RBV 1.509
 #ZAC: orig. code

 git dt 98297263 swissmx.py
 git dt 7445a5aa CustomROI.py app_config.py app_utils.py epics_widgets/MotorTweak.py epics_widgets/SmaractMotorTweak.py


zamofing_t@ganymede:~$ PPMAC=SAR-CPPM-EXPMX1
zamofing_t@ganymede:~$ gpasciiCommander --host $PPMAC -i


> &1p
X10194.8 Y-88923

-8892.32 10193.94 1000.950000000004

> #1..8->
&1#1->y
#2->x
&1#5->0.08084227555726195x+0.0370261645412808399y+157.349115566995778


plane=0.0808X+0.037Y+0.15

0.0808*10193.94-8892.32+  0.037* + 1000.950000000004

plane=0.0808*-8.8923 +0.037Y+0.15


> cpx X10194 Y-8892

> &1p
X10193.88 Y-8892

> #1,2,5p
-8892.02 10193.9 -996.5999999999985


-> z has wrong sign !

----------------
avoid constand RBV event:
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



-faster autofocus:
   - move at constant speed and acquire as fast as possible instead stop and go motion

- find fiducials:
   - fix openCV version problems

- configuration: use the current config as default values

- automation: towards automatic alignement

    if idx==0:
      #go=UsrGO.Fiducial(bm_pos+bm_sz/2-(20, 20), (40, 40),(fx,fy,bz))
      l=.120
      go=UsrGO.Fiducial((fx-l/2,fy-l/2), (l, l),bz)
      go.sigRegionChangeFinished.connect(self.cb_fiducial_update_z)
    grp=self._goTracked
    grp.addItem(go)
    mft._tree.setData(grp.childItems())


  ="geometry/find_fiducial"
  GEO_FND_FID,GEO_AUTOFOC="geometry/autofocus"