This commit is contained in:
2024-11-25 10:20:38 +01:00
parent 527fcec7f5
commit 87d984d358

View File

@@ -1031,6 +1031,93 @@ enable plc 2
vsy=py/(pt2pt_time)*scale*CoordFeedTime # scaling for Deltatau
#variables
r,x0,y0,n,dx,dy,x1,y1,t,vx,vy=map(lambda x: f'L{x}',range(11))
# replace: [^{](x|y|x0|y0|cx|cy|x0|y0|n|dx|dy|vsx|vsy|vx|vy) -> {\1}
prg+=f'''\
g=kwargs['grid']
ox,oy=g['pos'] #origin position in um (or counts if scaled)
px,py=g['pitch'] #pitch to next position in um (or 1 if scaled)
nx,ny=g['count'] #total count of wells
sx,sy=kwargs['ssz'] #section size (in wells)
tx,ty=nx//sx,ny//sy #total sections
k=-1 # key position
cx,cy=0,0 # section counter
x0,y0,n=0,0,0 # counter well in region
dx,dy=0,1 # motion pitch
vsx=vsy=1 # scaled velocity
vx,vy=0,vsy # scaled velocity
mv=list()
while(True):
if cy%2==0: # even rows
x=sx*cx+x0;y=sy*cy+y0
else: # odd rows
x=(tx-cx)*sx-x0-1;y=sy*cy+y0
vx=-vx
x0+=dx;y0+=dy
print(f'X{x}:{vx} Y{y}:{vy} ({k}|{dx}|{dy}|{n})')
mv.append((x+.1*n,y+.1*n,n))
self.updatePlt(mv,vx,vy)
if k>=0: #if keypoint not directly followed by an other keypoint, define future velocity
if k in (0,4):
vx,vy=0,vsy
elif k==2:
vx,vy=0,-vsy
elif k==5:
vx,vy=-vsx,0
elif k==6:
n+=1
elif k==7:
print('next h section')
cx+=1
x0,y0,n,dx,dy=0,0,0,0,0
elif k==8:
print('next v section')
cx=0;cy+=1
x0,y0,n,dx,dy=0,0,0,0,0
if cy>=ty:
print('finished whole grid')
break #
else:
raise ValueError('should never happened')
print(f'vx|vy after keypoint {k}: ({vx}|{vy})')
k=-1
if y0==sy-1:
if dy==1: #(1)
dx,dy=1,0
vx,vy=vsx/2,vsy/2
else:
k,dx,dy=2,0,-1#(2)
vx,vy=vsx/2,-vsy/2
elif y0==1 and x0>0 and x0<sx-1:
if dy==-1: #(3)
dx,dy=1,0
vx,vy=vsx/2,-vsy/2
else:
k,dx,dy=4,0,1 #(4)
vx,vy=vsx/2,vsy/2
elif y0==0:
if n==1 and x0==1: #(7 or 8)
if cx<tx-1:
k,dx,dy=7,-1,0
vx,vy=0,0
else: #(8)
k,dx,dy=8,sx-1,sy
vx,vy=0,0
elif x0==1: #(6)
k,dx,dy=6,-1,0
vx,vy=-vsx,0
elif x0==0: #(0)
k,dx,dy=0,0,1
vx,vy=0,vsy
elif x0==sx-1: #(5)
k,dx,dy=5,-1,0
vx,vy=-vsx/2,-vsy/2
'''
prg+=f'''\
//mode 6: hit-and-return pvt motion
{r}=0 // row