Files

9.7 KiB

Work log

xx.10.24: testing shapepath.py in different modes (tunneling)

zamofing_t@ganymede:~$
>>> kill previous tunnels 127.0.0.1:100??
ps -f `lsof -i -n | grep '127.0.0.1:100.. (LISTEN)' | awk '{print $2}'`
kill `lsof -i -n | grep '127.0.0.1:100.. (LISTEN)' | awk '{print $2}'`
#lsof -i -n | grep '127.0.0.1:100.. (LISTEN)' | tee /tmp/0.log | awk '{print $2}' | tee /tmp/1.log && grep -n '' /tmp/*.log

>>> open cameras in chrome
ssh -L 10010:cristallina-cam-top:80 saresc-vcons-01 'uname -a'
google-chrome --app-url 127.0.0.1:10010
google-chrome --app-url http://cristallina-cam-north.psi.ch/camera/index.html#/video


>>> prepare debug environment
cmdt.py -p EXPMX -tpb   # select SAR-CPPM-EXPMX1

>>> prepare shapepath and ssh tunneling
cd ~/Documents/prj/SwissFEL/apps/PBSwissMX/python/
subl shapepath.py
./shapepath.py -h

PPMAC=SAR-CPPM-EXPMX1
ssh -L 10001:localhost:22 root@$PPMAC 'uname -a'
ssh -L 10002:localhost:2332 root@$PPMAC 'uname -a'

gather_server triggerSync are copied with sftp. This does not work with tunneling:
gather_server: ~/Documents/prj/SwissFEL/PBTools/build/lib/pbtools/misc/pp_comm.py:889
triggerSync:   ~/Documents/prj/SwissFEL/apps/PBSwissMX/python/MXMotion.py:122

rsync -vai ~/Documents/prj/SwissFEL/PBTools/pbtools/gather/gather_server root@$PPMAC:/tmp/
rsync -vai ~/Documents/prj/SwissFEL/apps/PBSwissMX/src/triggerSync/triggerSync root@$PPMAC:/tmp/

gather_server needs to be started explicitly in tunneling:
ssh root@$PPMAC
LD_LIBRARY_PATH=/opt/ppmac/libppmac/ /tmp/gather_server

triggerSync is started if required at each acquisition and exits when done.

mode:
0  unused
1  pvt motion
2  unused
3  pvt motion using inverse fft velocity
4  pvt motion short code using grid parameters
5  pvt motion short code using grid parameters. Instead of continous motion it moves and waits as give in the parameter time

sync:
 0 real start and frame trigger with sync
 1 direct start
 2 simulated start and frame trigger no sync
 3 simulated start and frame trigger with sync
 4 simulated start real frame trigger no sync
 5 simulated start real frame trigger with sync


# set start EVT to value 0 (=Force Hi)
caput SAR-EXPMX-EVR0:FrontUnivOut4-Src-Scale-SP 9
./shapepath.py --host=localhost:10001:10002 -v 0x59 -m4 -s0 # works
# set start EVT to value 1 (=Force Lo)
caput SAR-EXPMX-EVR0:FrontUnivOut4-Src-Scale-SP 8
# reset EVT default value (Pulser 0)
caput SAR-EXPMX-EVR0:FrontUnivOut4-Src-Pulse-SP 0
./shapepath.py --host=localhost:10001:10002 -v 0x59 -m4 -s1  # works
./shapepath.py --host=localhost:10001:10002 -v 0x59 -m4 -s2  # works
./shapepath.py --host=localhost:10001:10002 -v 0x59 -m4 -s3  # works
./shapepath.py --host=localhost:10001:10002 -v 0x59 -m4 -s4  # works
./shapepath.py --host=localhost:10001:10002 -v 0x59 -m4 -s5  # works

Debugging were the coordinate program counter is:
&1 list pc,10

xx.10.24: mermaid tricks and links

pip install pymermaider --user
pymermaider ~/Documents/prj/SwissFEL/apps/PBSwissMX/python -o /tmp
subl /tmp/python.md

12.2.25: debugging motion code

&1b2r
go to <&>coordsystem <1> <b>eginning of program <2> and <r>un

s step one line
q quit program
a abort motion program
bpset set breakpoints

list  plc2,10,3
   list 3 lines strating from line 10 

list  pc
   show program counter
   &1b2r

open prog 3
  linearabs
  X2Y1
  dwell10
  X0Y3
  dwell10
  X3Y3
  dwell10
  X3Y0
  dwell10
  X0Y0
close

&1b3

cpx linearabs X1Y1

//return coordinate transcormation of all axes (in coordinate system 1)
&1 #1..8->

&1p  // returns coordinate positions in 'wells' (in coordinate system 1)
X1.000208333333334 Y1.000104166666666

#1..2p

//show were the program is:
list pc
list pc, // with line numbers

Coord[1].ProgRunning
Coord[1].ProgActive
Coord[1].ProgProceeding
Coord[1].Program.Lsize
Coord[1].Program.Number
Coord[1].Program.Size
Coord[1].Program.Store   

08.05.2026: SFELPHOTON-1957: stop-go-and-return motion

4  continuous         : pvt motion using grid parameters (short code)
5  stop-and-go        : pvt motion using grid parameters: Instead of continous motion it moves and waits as give in the parameter time
6  hit-and-return     : pvt motion using grid parameters: continous motion on 2n ells to pump then same 2n wells to probe, then go 2 rows down
7  stop-go-and-return : pvt motion using grid parameters: continous motion on 2n ells to pump then same 2n wells to probe, then go 2 rows down

./shapepath.py -v0x04 -m4  ; mv /tmp/shapepath.prg /tmp/shapepath40.prg
./shapepath.py -v0x04 -m5  ; mv /tmp/shapepath.prg /tmp/shapepath50.prg
./shapepath.py -v0x04 -m60 ; mv /tmp/shapepath.prg /tmp/shapepath60.prg
./shapepath.py -v0x04 -m70 ; mv /tmp/shapepath.prg /tmp/shapepath70.prg
bcompare /tmp/shapepath60.prg /tmp/shapepath70.prg


------- mode 5 -------
  L1=0 //slow loop x
  L0=0 //fast loop y
  while(L1<20)
  {
    //send 1"A:move X%g:%g Y%g:%g",-1000+L1*120,0,-1200+L0*120,0
    X(-1000+L1*120):0 Y(-1200+L0*120):0
    while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
    L0+=1
    while(L0<25-1)
    {
      X(-1000+L1*120):0 Y(-1200+L0*120):0
      while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
      L0+=1
    }
    if(L1>=20-1)
    {
      break
    }
    X(-1000+L1*120):0 Y(-1200+L0*120):0
    while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
    L1+=1
    X(-1000+L1*120):0 Y(-1200+L0*120):0
    while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
    L0-=1
    while(L0>=1)
    {
      X(-1000+L1*120):0 Y(-1200+L0*120):0
      while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
      L0-=1
    }
    if(L1>=20-1)
    {
      break
    }
    X(-1000+L1*120):0 Y(-1200+L0*120):0
    while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
    L1+=1
    X(-1000+L1*120):0 Y(-1200+L0*120):0
    while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
    L0+=1
  }
  X(-1000+L1*120):0 Y(-1200+L0*120):0
  while(Sys.Udata[2]==Sys.Udata[1]){};Sys.Udata[2]=Sys.Udata[1] // wait motion trigger
  dwell 100

------- mode 6 -------
  L6=1               // motion pvt tome scaling
  L5=-1              // key position
  L0=0;L1=0       // section counter
  L10=0;L12=0;L4=0 // counter well in region
  L2=0;L3=1       // motion pitch
  L7=0;L8=12000.0   // scaled velocity
  pvt10 abs
  while(1){
    if (L1%2==0){ // even rows
      L9=6*L0+L10;L11=10*L1+L12
    }else{       // odd rows
      L9=(2-L0)*6-L10-1;L11=10*L1+L12
      L7=-L7
    }
    L10+=L2;L12+=L3
    //send 1"A:move(%d) X%g:%g Y%g:%g",L5,-1000+L9*120,L7,-1200+L11*120,L8
    X(-1000+L9*120):(L7) Y(-1200+L11*120):(L8)
    if (L6!=1){
      pvt10 abs;L6=1
    }
    if (L5>=0){ //if keypoint not directly followed by an other keypoint, define future velocity
      if (L5==0 || L5==4){
        L7=0;L8=12000.0
      }else if (L5==2){
        L7=0;L8=-12000.0
      }else if (L5==5){
        L7=-12000.0;L8=0
      }else if (L5==6){
        L4+=1
        if (6!=1) {
          pvt60 abs;L6=6
        }
      }else if (L5==7){
        //send 1"next h section"
        L0+=1
        L10=0;L12=0;L4=0;L2=0;L3=0
        if (9!=1) {
          pvt90 abs;L6=9
        }
      }else if (L5==8){
        //send 1"next v section"
        L0=0;L1+=1
        L10=0;L12=0;L4=0;L2=0;L3=0
        if (L1>=2){
          //send 1"finished whole grid"
          break
        }
        if (19!=1) {
          pvt190 abs;L6=19
        }
      }
      //send 1"after keypoint %d: %g|%g",L5,L7,L8
      L5=-1
    }
    if (L12==10-1){
      if (L3==1){   //(1)
        L2=1;L3=0
        L7=12000.0/2;L8=12000.0/2
      }else{
        L5=2;L2=0;L3=-1 //(2)
        L7=12000.0/2;L8=-12000.0/2
      }
    }else if (L12==1 && L10>0 && L10<6-1){
      if (L3==-1){  //(3)
        L2=1;L3=0
        L7=12000.0/2;L8=-12000.0/2
      }else{
        L5=4;L2=0;L3=1 //(4)
        L7=12000.0/2;L8=12000.0/2
      }
    }else if (L12==0){
      if (L4==1 && L10==1){ //(7 or 8)
        if (L0<2-1){
          L5=7;L2=-1;L3=0
          L7=0;L8=0
        }else{ //(8)
          L5=8;L2=6-1;L3=10
          L7=0;L8=0
        }
      }else if (L10==1){ //(6)
        L5=6;L2=-1;L3=0
        L7=-12000.0;L8=0
      }else if (L10==0){ //(0)
        L5=0;L2=0;L3=1
        L7=0;L8=12000.0
      }else if (L10==6-1){ //(5)
        L5=5;L2=-1;L3=0
        L7=-12000.0/2;L8=-12000.0/2
      }
    }
  }
  dwell 100

------- mode 7 -------


zamofing_t@ganymede:~/Documents/prj/SwissFEL/apps/SwissMX$
  ./swissmx.py --sim 0xfff
    Fix Target -> Grid() 'mode:6,ssz:(6,5)' add obj
    collect

testing mode 7:
zamofing_t@ganymede:~/Documents/prj/SwissFEL/apps/SwissMX$
  ./swissmx.py --sim 0xfff
    Fix Target -> Grid() 'mode:7,ssz:(6,5)' add obj
    collect
    -> this works in simulation and

cmdt.py -tpbg -p SAR-EXPMX
  -> SAR-CPPM-EXPMX1 -> gathering will also install and run the gather server that is required later

./shapepath.py -v0x7d -m60
  -> show motion works.

./shapepath.py -v0x7d -m70
  -> show motion works.

tunneling:
PPMAC=SAR-CPPM-EXPMX1
ssh -L 10001:localhost:22 root@$PPMAC 'uname -a'
ssh -L 10002:localhost:2332 root@$PPMAC 'uname -a'

./shapepath.py --host=localhost:10001:10002 -v0x5d -m5
  -> execute stop-and-go works !!!

./shapepath.py --host=localhost:10001:10002 -v0x5d -m60
  -> execute hit-and-return motion works !!!


./shapepath.py --host=localhost:10001:10002 -v0x5d -m70
  -> execute stop-go-and-return preliminary motion works... but not tested...