try to cleanup stuff(1)

This commit is contained in:
2024-11-27 15:23:52 +01:00
parent 9888377e13
commit 54ba58f657

View File

@@ -192,7 +192,8 @@ class DebugPlot:
def plot_points(pts): def plot_points(pts):
fig=plt.figure() fig=plt.figure()
ax = fig.add_subplot(1,1,1) ax = fig.add_subplot(1,1,1)
ax.invert_xaxis();ax.invert_yaxis() #ax.invert_xaxis()
ax.invert_yaxis()
#hl=ax[0].plot(x, y, color=col) #hl=ax[0].plot(x, y, color=col)
hl=ax.plot(pts[:,0],pts[:,1],'r.') hl=ax.plot(pts[:,0],pts[:,1],'r.')
hl=ax.plot(pts[:,0],pts[:,1],'y--') hl=ax.plot(pts[:,0],pts[:,1],'y--')
@@ -707,63 +708,73 @@ class ShapePath(MotionBase):
the type of generated program is defined by <mode>$ the type of generated program is defined by <mode>$
-> the list af all points that will be moved at, is in 'mot_pts' -> the list af all points that will be moved at, is in 'mot_pts'
(m)= mandatory
(o)= optional
common kwargs: common kwargs:
scale : scaling velocity (default=1. value=0 would stop at each point scale : (o) scaling velocity (default=1. value=0 would stop at each point
cnt : move path multiple times (default=1) cnt : (o) move path multiple times (default=1)
dwell : dwell time at end (default=100ms) dwell : (o) dwell time at end (default=100ms)
mode:0 unused mode:0 unused
mode:1 pvt motion mode:1 pvt motion point list
common kwargs plus: common kwargs plus:
points : point list points : (m) point list
trf : optional transformation that will be done on 'points', mot_pts=trf*points trf : (o) transformation that will be done on 'points', mot_pts=trf*points
mode:2 unused mode:2 unused
mode:3 pvt motion using inverse fft velocity mode:3 pvt motion point list using inverse fft velocity
common kwargs plus: common kwargs plus:
points : point list points : (m) point list
trf : optional transformation that will be done on 'points', mot_pts=trf*points trf : (o) transformation that will be done on 'points', mot_pts=trf*points
numPad : number of padding points to reduce aliasing (default=16) numPad : (o) number of padding points to reduce aliasing (default=16)
mode:4 pvt motion short code using grid parameters mode:4 pvt motion short code using grid parameters
common kwargs plus: common kwargs plus:
trf : transformation that will be done on 'grid points' trf : (o) transformation that will be done on 'grid points'
grid: grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0} grid: (m) grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0}
mode:5 pvt motion 'stop and go' short code using grid parameters. mode:5 pvt motion 'stop and go' short code using grid parameters.
Instead of continous motion it moves and waits as given in the parameters Instead of continous motion it moves and waits as given in the parameters
common kwargs plus: common kwargs plus:
trf : transformation that will be done on 'grid points' trf : (o) transformation that will be done on 'grid points'
grid: grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0} grid: (m) grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0}
tmove: time to move in ms (move start on FEL-trigger tmove: (m) time to move in ms (move start on FEL-trigger
twait: time to wait in ms twait: (m) time to wait in ms
(tmove+twait will be rounded to a multiple of fel_per) (tmove+twait will be rounded to a multiple of fel_per)
mode:6 pvt motion 'hit and return using grid parameters. continous motion on 2n ells to pump then same 2n wells to probe, then go 2 rows down mode:6 pvt motion 'hit and return using grid parameters. continous motion on 2n ells to pump then same 2n wells to probe, then go 2 rows down
common kwargs plus: common kwargs plus:
trf : transformation that will be done on 'grid points' trf : (o) transformation that will be done on 'grid points'
grid : grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0} grid : (m) grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0}
ssz : section size (in wells) ssz : (m) section size (in wells)
smv : time(in num of shots) to move to next section (horiz/vert) smv : (o) time(in num of shots) to move to next section (horiz/vert)
default is (ssz[0]-1,ssz[1]) default is (ssz[0]-1,ssz[1])
sdelay: shots count of delay. Default is ssz[0]*ssz[1] sdelay: (o) shots count of delay. Default is ssz[0]*ssz[1]
''' '''
#scan=0 # snake motion X fast, Y slow if mode not in (1,3,4,5,6): #### pvt motion
scan=1 # snake motion Y fast, X slow (default) raise ValueError(f'unsupported mode:{mode}')
prg=f'close all buffers\nopen prog {prgId}\n Coord[1].DesTimeBase=Sys.ServoPeriod\n'
verb=self.verbose
comm=self.comm
meta=self.meta
try: try:
self.sync_prg self.sync_prg
except AttributeError: except AttributeError:
_log.warning('missing motion sync code!') _log.warning('missing motion sync code!')
# this uses Coord[1].Tm and limits with MaxSpeed
if mode in (1,3,4,5,6): #### pvt motion verb=self.verbose
if mode!=5: comm=self.comm
pt2pt_time=meta['pt2pt_time']=meta['fel_per'] meta=self.meta
#scan=0 # snake motion X fast, Y slow
scan=1 # snake motion Y fast, X slow (default)
argsStr=[f'mode:{mode}']
for k,v in kwargs.items():
if type(v) in (np.ndarray,np.matrix):
argsStr.append(f'{k}:{type(v).__name__}({v.shape})')
else:
argsStr.append(f'{k}:{v}')
prg='// '+' '.join(argsStr)
prg+=f'\n\nclose all buffers\nopen prog {prgId}\n Coord[1].DesTimeBase=Sys.ServoPeriod\n'
scale=kwargs.get('scale', 1.) scale=kwargs.get('scale', 1.)
cnt=kwargs.get('cnt', 1) # move path multiple times cnt=kwargs.get('cnt', 1) # move path multiple times
dwell=kwargs.get('dwell', 100) # wait time at end of motion dwell=kwargs.get('dwell', 100) # wait time at end of motion
CoordFeedTime=1000. #Defaut deltatau value CoordFeedTime=1000. #Defaut deltatau value
if mode!=5:
pt2pt_time=meta['pt2pt_time']=meta['fel_per']
if mode in (1, 3): #### pvt motion, using points if mode in (1, 3): #### pvt motion, using points
pt=kwargs['points'] pt=kwargs['points']
try: try:
@@ -802,7 +813,7 @@ class ShapePath(MotionBase):
pv[ 1:-1,(2,3)] = v[:n]*scale pv[ 1:-1,(2,3)] = v[:n]*scale
if verb&0x20: if verb&0x20:
if 'trf' in kwargs: if 'trf' in kwargs:
_log.warning('correct ploting of pvt only works without transformation !') _log.warning('correct plotting of pvt only works without transformation !')
else: else:
dp=DebugPlot(self);self.pvt=dp.plot_gen_pvt(pv) dp=DebugPlot(self);self.pvt=dp.plot_gen_pvt(pv)
plt.show(block=False) plt.show(block=False)
@@ -967,7 +978,7 @@ open plc 2
close close
enable plc 2 enable plc 2
''' '''
comm.gpascii.send_block(syncPlc, verb&0x08) if comm: comm.gpascii.send_block(syncPlc, verb&0x08)
prg+=f'''\ prg+=f'''\
//mode 5: grid pvt motion //mode 5: grid pvt motion
pvt{tmove} abs pvt{tmove} abs
@@ -1143,8 +1154,6 @@ enable plc 2
}} }}
''' '''
else:
raise ValueError('unsupported mode')
#common code to repeat the motion multiple times #common code to repeat the motion multiple times
if cnt>1: if cnt>1:
prg+=f'''\ prg+=f'''\
@@ -1159,7 +1168,6 @@ f(P100>0)
}}\n''' }}\n'''
else: else:
prg+=f' dwell {dwell}\n Gather.Enable=0\nclose\n' prg+=f' dwell {dwell}\n Gather.Enable=0\nclose\n'
#prg+='&1\nb%dr\n'%prgId)
if verb&0x02: if verb&0x02:
DebugPlot.plot_points(self.mot_pts) DebugPlot.plot_points(self.mot_pts)