This commit is contained in:
2024-11-25 14:04:26 +01:00
parent bea723d7f8
commit f545812bc1
2 changed files with 99 additions and 64 deletions

View File

@@ -60,13 +60,6 @@ class HitReturnEval:
#vgrid: grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0} #vgrid: grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0}
#vp0: x/y koordinates of well to start (default 0,0) #vp0: x/y koordinates of well to start (default 0,0)
#vsz: size of wells to cycle (must be 2n x m) #vsz: size of wells to cycle (must be 2n x m)
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
#smv=kwargs['smv'] #time(in num of shots) to move to next section (horiz/vert) #smv=kwargs['smv'] #time(in num of shots) to move to next section (horiz/vert)
#swait=kwargs['smv'] #wait after <swait> section for motion trigger. swait=0:never wait #swait=kwargs['smv'] #wait after <swait> section for motion trigger. swait=0:never wait
@@ -81,11 +74,30 @@ class HitReturnEval:
# | | | | | | | | | | | | # | | | | | | | | | | | |
# 1-2 1-2 1-2 1-2 1-2 1-2 # 1-2 1-2 1-2 1-2 1-2 1-2
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)
try:
tsx, tsy=kwargs['smv'] # time(in num of shots) to move to next section (horiz/vert)
except KeyError as e:
tsx=sx-1
tsy=sy
try:
tsd=kwargs['sdelay']
except KeyError as e:
tsd=sx*sy
tsd+=1-sx*sy # sdl are shots to wait at position #(6)
tx,ty=nx//sx,ny//sy #total sections
vsx=vsy=1 # scaled velocity
t=1 #motion pvt tome scaling
k=-1 # key position k=-1 # key position
cx,cy=0,0 # section counter cx,cy=0,0 # section counter
x0,y0,n=0,0,0 # counter well in region x0,y0,n=0,0,0 # counter well in region
dx,dy=0,1 # motion pitch dx,dy=0,1 # motion pitch
vsx=vsy=1 # scaled velocity
vx,vy=0,vsy # scaled velocity vx,vy=0,vsy # scaled velocity
mv=list() mv=list()
while(True): while(True):
@@ -98,6 +110,8 @@ class HitReturnEval:
print(f'X{x}:{vx} Y{y}:{vy} ({k}|{dx}|{dy}|{n})') print(f'X{x}:{vx} Y{y}:{vy} ({k}|{dx}|{dy}|{n})')
mv.append((x+.1*n,y+.1*n,n)) mv.append((x+.1*n,y+.1*n,n))
self.updatePlt(mv,vx,vy) self.updatePlt(mv,vx,vy)
if t !=1:
print('pvt 10')
if k>=0: #if keypoint not directly followed by an other keypoint, define future velocity if k>=0: #if keypoint not directly followed by an other keypoint, define future velocity
if k in (0,4): if k in (0,4):
vx,vy=0,vsy vx,vy=0,vsy
@@ -107,10 +121,14 @@ class HitReturnEval:
vx,vy=-vsx,0 vx,vy=-vsx,0
elif k==6: elif k==6:
n+=1 n+=1
if tsd!=1:
print(f'pvt {10*tsd}');t=tsd;time.sleep(.1*tsd)
elif k==7: elif k==7:
print('next h section') print('next h section')
cx+=1 cx+=1
x0,y0,n,dx,dy=0,0,0,0,0 x0,y0,n,dx,dy=0,0,0,0,0
if tsx!=1:
print(f'pvt {10*tsx}');t=tsx;time.sleep(.1*tsx)
elif k==8: elif k==8:
print('next v section') print('next v section')
cx=0;cy+=1 cx=0;cy+=1
@@ -118,6 +136,8 @@ class HitReturnEval:
if cy>=ty: if cy>=ty:
print('finished whole grid') print('finished whole grid')
break # break #
if tsy!=1:
print(f'pvt {10*tsy}');t=tsy;time.sleep(.1*tsy)
else: else:
raise ValueError('should never happened') raise ValueError('should never happened')
print(f'vx|vy after keypoint {k}: ({vx}|{vy})') print(f'vx|vy after keypoint {k}: ({vx}|{vy})')
@@ -220,7 +240,7 @@ if __name__=='__main__':
grid={'pos':(-1000, -1200), 'pitch':(120, 120), 'count':(20, 25)} grid={'pos':(-1000, -1200), 'pitch':(120, 120), 'count':(20, 25)}
grid={'pos':(0, 0), 'pitch':(1, 1), 'count':(16, 20)} grid={'pos':(0, 0), 'pitch':(1, 1), 'count':(16, 20)}
obj.initPlt(grid) obj.initPlt(grid)
obj.setup_motion(grid=grid,ssz=(4,5)) obj.setup_motion(grid=grid,ssz=(4,5),smv=(4-1,5+1),sdelay=4*5)
obj.initPlt(grid) obj.initPlt(grid)
obj.setup_motion(grid=grid,ssz=(6,10)) obj.setup_motion(grid=grid,ssz=(6,10))
obj.initPlt(grid) obj.initPlt(grid)

View File

@@ -852,15 +852,15 @@ class ShapePath(MotionBase):
self.mot_pts=(np.hstack((pt, np.ones((pt.shape[0], 1))))*np.asmatrix(trf)).A # pt*trf self.mot_pts=(np.hstack((pt, np.ones((pt.shape[0], 1))))*np.asmatrix(trf)).A # pt*trf
sx,sy=kwargs['ssz'] #section size (in wells) sx,sy=kwargs['ssz'] #section size (in wells)
try: try:
tmx,tmy=kwargs['smv'] #time(in num of shots) to move to next section (horiz/vert) tsx,tsy=kwargs['smv'] #time(in num of shots) to move to next section (horiz/vert)
except KeyError as e: except KeyError as e:
tmx=sx-1 tsx=sx-1
tmy=sy+1 tsy=sy
try: try:
sdl=kwargs['sdelay'] tsd=kwargs['sdelay']
except KeyError as e: except KeyError as e:
sdl=sx*sy tsd=sx*sy
sdl+=1-sx*sy # sdl are shots to wait at position #(6) tsd+=1-sx*sy # sdl are shots to wait at position #(6)
prg+=f' linear abs\n X{ox-px:g} Y{oy-py:g}\n' # start one position out of grid prg+=f' linear abs\n X{ox-px:g} Y{oy-py:g}\n' # start one position out of grid
prg+=' dwell 10\n' prg+=' dwell 10\n'
try: prg+=self.sync_prg try: prg+=self.sync_prg
@@ -1030,17 +1030,18 @@ enable plc 2
vsx=px/(pt2pt_time)*scale*CoordFeedTime # scaling for Deltatau vsx=px/(pt2pt_time)*scale*CoordFeedTime # scaling for Deltatau
vsy=py/(pt2pt_time)*scale*CoordFeedTime # scaling for Deltatau vsy=py/(pt2pt_time)*scale*CoordFeedTime # scaling for Deltatau
g=kwargs['grid'] #g=kwargs['grid']
ox,oy=g['pos'] #origin position in um (or counts if scaled) #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) #px,py=g['pitch'] #pitch to next position in um (or 1 if scaled)
nx,ny=g['count'] #total count of wells #nx,ny=g['count'] #total count of wells
sx,sy=kwargs['ssz'] #section size (in wells) #sx,sy=kwargs['ssz'] #section size (in wells)
#tsx, tsy, tsd #time scale to pvt move to (next horiz|next vert| after position #6)
tx,ty=nx//sx,ny//sy #total sections tx,ty=nx//sx,ny//sy #total sections
#variables #variables
cx,cy,dx,dy,n,k,sx,sy,tx,ty,vsx,vsy,vx,vy,x,x0,y,y0=map(lambda x: f'L{x}',range(16)) cx,cy,dx,dy,n,k,t,vx,vy,x,x0,y,y0=map(lambda x: f'L{x}',range(13))
# replace in python code of hit_and_return.py setup_motion: # replace in python code of hit_and_return.py setup_motion:
# (cx|cy|dx|dy|n|k|sx|sy|tx|ty|vsx|vsy|vx|vy|x|x0|y|y0) -> {\1} # (cx|cy|dx|dy|n|k|sx|sy|tsd|tsx|tsy|tx|ty|vsx|vsy|vx|vy|x|x0|y|y0) -> {\1}
# if ([^:]*): -> if \(\1\){{ # if ([^:]*): -> if \(\1\){{
# else: -> }}else{{ # else: -> }}else{{
# elif ([^:]*): -> }}else if \(\1\){{ # elif ([^:]*): -> }}else if \(\1\){{
@@ -1048,80 +1049,94 @@ enable plc 2
prg+=f'''\ prg+=f'''\
//mode 6: hit-and-return pvt motion //mode 6: hit-and-return pvt motion
{k}=-1 # key position {t}=1 // motion pvt tome scaling
{cx},{cy}=0,0 # section counter {k}=-1 // key position
{x0},{y0},{n}=0,0,0 # counter well in region {cx}=0;{cy}=0 // section counter
{dx},{dy}=0,1 # motion pitch {x0}=0;{y0}=0;{n}=0 // counter well in region
{vsx}={vsy}=1 # scaled velocity {dx}=0;{dy}=1 // motion pitch
{vx},{vy}=0,{vsy} # scaled velocity {vx}=0;{vy}={vsy} // scaled velocity
pvt{pt2pt_time} abs pvt{pt2pt_time} abs
while(1){{: while(1){{
if ({cy}%2==0){{ # even rows if ({cy}%2==0){{ // even rows
{x}={sx}*{cx}+{x0};{y}={sy}*{cy}+{y0} {x}={sx}*{cx}+{x0};{y}={sy}*{cy}+{y0}
}}else{{ # odd rows }}else{{ // odd rows
{x}=({tx}-{cx})*{sx}-{x0}-1;{y}={sy}*{cy}+{y0} {x}=({tx}-{cx})*{sx}-{x0}-1;{y}={sy}*{cy}+{y0}
{vx}=-{vx} {vx}=-{vx}
}} }}
{x0}+={dx};{y0}+={dy} {x0}+={dx};{y0}+={dy}
//send 1"A:move(%d) X%g:%g Y%g:%g",{k},{x},{vx},{y},{vy} //send 1"A:move(%d) X%g:%g Y%g:%g",{k},{ox}+{x}*{px},{vx},{oy}+{y}*{py},{vy}
X({x}):({vx}) Y({y}):({vy}) X({ox}+{x}*{px}):({vx}) Y({oy}+{y}*{py}):({vy})
if ({k}>=0){{ #if keypoint not directly followed by an other keypoint, define future velocity if ({t}!=1){{
pvt{pt2pt_time} abs;{t}=1
}}
if ({k}>=0){{ //if keypoint not directly followed by an other keypoint, define future velocity
if ({k}==0 || {k}==4){{ if ({k}==0 || {k}==4){{
{vx},{vy}=0,{vsy} {vx}=0;{vy}={vsy}
}}else if ({k}==2){{ }}else if ({k}==2){{
{vx},{vy}=0,-{vsy} {vx}=0;{vy}=-{vsy}
}}else if ({k}==5){{ }}else if ({k}==5){{
{vx},{vy}=-{vsx},0 {vx}=-{vsx};{vy}=0
}}else if ({k}==6){{ }}else if ({k}==6){{
{n}+=1 {n}+=1
if ({tsd}!=1) {{
pvt{pt2pt_time*tsd} abs;{t}={tsd}
}}
}}else if ({k}==7){{ }}else if ({k}==7){{
//send 1"next h section" //send 1"next h section"
{cx}+=1 {cx}+=1
{x0},{y0},{n},{dx},{dy}=0,0,0,0,0 {x0}=0;{y0}=0;{n}=0;{dx}=0;{dy}=0
if ({tsx}!=1) {{
pvt{pt2pt_time*tsx} abs;{t}={tsx}
}}
}}else if ({k}==8){{ }}else if ({k}==8){{
//send 1"next v section" //send 1"next v section"
{cx}=0;{cy}+=1 {cx}=0;{cy}+=1
{x0},{y0},{n},{dx},{dy}=0,0,0,0,0 {x0}=0;{y0}=0;{n}=0;{dx}=0;{dy}=0
if ({cy}>={ty}){{ if ({cy}>={ty}){{
//send 1"finished whole grid" //send 1"finished whole grid"
break break
}} }}
if ({tsy}!=1) {{
pvt{pt2pt_time*tsy} abs;{t}={tsy}
}}
}} }}
//send 1"after keypoint %d: %g|%g",{k},{vx},{vy} //send 1"after keypoint %d: %g|%g",{k},{vx},{vy}
{k}=-1 {k}=-1
}}
if ({y0}=={sy}-1){{ if ({y0}=={sy}-1){{
if ({dy}==1){{ #(1) if ({dy}==1){{ //(1)
{dx},{dy}=1,0 {dx}=1;{dy}=0
{vx},{vy}={vsx}/2,{vsy}/2 {vx}={vsx}/2;{vy}={vsy}/2
}}else{{ }}else{{
{k},{dx},{dy}=2,0,-1#(2) {k}=2;{dx}=0;{dy}=-1 //(2)
{vx},{vy}={vsx}/2,-{vsy}/2 {vx}={vsx}/2;{vy}=-{vsy}/2
}} }}
}}else if ({y0}==1 && {x0}>0 && {x0}<{sx}-1){{ }}else if ({y0}==1 && {x0}>0 && {x0}<{sx}-1){{
if ({dy}==-1){{ #(3) if ({dy}==-1){{ //(3)
{dx},{dy}=1,0 {dx}=1;{dy}=0
{vx},{vy}={vsx}/2,-{vsy}/2 {vx}={vsx}/2;{vy}=-{vsy}/2
}}else{{ }}else{{
{k},{dx},{dy}=4,0,1 #(4) {k}=4;{dx}=0;{dy}=1 //(4)
{vx},{vy}={vsx}/2,{vsy}/2 {vx}={vsx}/2;{vy}={vsy}/2
}}else if ({y0}==0){{
if ({n}==1 && {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
}} }}
}}else if ({x0}==1){{ #(6) }}else if ({y0}==0){{
{k},{dx},{dy}=6,-1,0 if ({n}==1 && {x0}==1){{ //(7 or 8)
{vx},{vy}=-{vsx},0 if ({cx}<{tx}-1){{
}}else if ({x0}==0){{ #(0) {k}=7;{dx}=-1;{dy}=0
{k},{dx},{dy}=0,0,1 {vx}=0;{vy}=0
{vx},{vy}=0,{vsy} }}else{{ //(8)
}}else if ({x0}=={sx}-1){{ #(5) {k}=8;{dx}={sx}-1;{dy}={sy}
{k},{dx},{dy}=5,-1,0 {vx}=0;{vy}=0
{vx},{vy}=-{vsx}/2,-{vsy}/2 }}
}}else if ({x0}==1){{ //(6)
{k}=6;{dx}=-1;{dy}=0
{vx}=-{vsx};{vy}=0
}}else if ({x0}==0){{ //(0)
{k}=0;{dx}=0;{dy}=1
{vx}=0;{vy}={vsy}
}}else if ({x0}=={sx}-1){{ //(5)
{k}=5;{dx}=-1;{dy}=0
{vx}=-{vsx}/2;{vy}=-{vsy}/2
}} }}
}} }}
}} }}