SFELPHOTON-1335:rework triggerSync

This commit is contained in:
2024-10-24 12:10:00 +02:00
parent 786d9c0037
commit cf4a9362f2
7 changed files with 418 additions and 149 deletions

View File

@@ -17,19 +17,26 @@ verbose bits:
0x20 plot pvt trajectory (before motion)
0x40 print sync details
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
if mode&1:
self.plot_trajectory()
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
if mode&2:
self.plot_pos_error()
if mode&4:
self.plot_bode(xy=(3,1),mode=31,db=True) # FX
self.plot_bode(xy=(2,0),mode=31,db=True) # FY
if mode&8:
self.plot_trigger_jitter()
if motion not possible check the DesTimeBase:
Coord[1].DesTimeBase
> Coord[1].DesTimeBase=0 // this is blocked
Coord[1].DesTimeBase=Sys.ServoPeriod // to unblock
Gather motor order
@@ -71,7 +78,7 @@ if __name__=="__main__":
sys.path.insert(0, os.path.abspath(os.path.join(base,'../../../PBTools')))
else:
base=os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(base,'PBTools'))
sys.path.insert(0, os.path.abspath(os.path.join(base,'../../PBTools')))
sys.path.insert(0, os.path.join(base,'PBSwissMX/python'))
#_log.info(sys.path)
@@ -652,7 +659,7 @@ class ShapePath(MotionBase):
address=("Motor[1].ActPos","Motor[2].ActPos","Motor[1].DesPos","Motor[2].DesPos","Gate3[1].Chan[1].UserFlag")
#address=("Motor[1].ActPos","Motor[2].ActPos","Motor[1].DesPos","Motor[2].DesPos","Gate3[1].Chan[1].UserFlag","EncTable[20].PrevEnc")
#address=("Motor[1].ActPos", "Motor[2].ActPos", "Motor[1].DesPos", "Motor[2].DesPos", "Gate3[1].Chan[1].UserFlag","Coord[1].TimeBase","EncTable[20].DeltaPos")
gtMaxLn=gt.set_address(*address)
gtMaxLn=gt.set_address(*address) # sets also Gather.Enable=1
if acq_per is None:
if numPts is None:
numPts=self.mot_pts.shape[0]
@@ -1016,11 +1023,11 @@ f(P100>0)
self.rec=rec=gt.upload()
try:
syncShell=self.syncShell
sync_shell=self.sync_shell
except AttributeError: pass
else:
print(syncShell.sync())
del self.syncShell
print(sync_shell.sync())
del self.sync_shell
pts=self.mot_pts
@@ -1066,23 +1073,30 @@ if __name__=='__main__':
comm=gather=None
gp=GenPath()
#real start and frame trigger with sync
#sp = ShapePath(comm, gather, args.verbose)
# direct start
#sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=0)
sync=args.sync
mode=args.mode
#simulated start and frame trigger no sync
#sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=1,sync_flag=3)
#simulated start and frame trigger with sync
#sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=2,sync_flag=3)
#simulated start real frame trigger no sync
sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=1,sync_flag=1)
#simulated start real frame trigger with sync
#sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=2,sync_flag=1)
if sync==0:
#real start and frame trigger with sync
sp = ShapePath(comm, gather, args.verbose)
elif sync==1:
# direct start
sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=0)
elif sync==2:
#simulated start and frame trigger no sync
sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=1,sync_flag=3)
elif sync==3:
#simulated start and frame trigger with sync
sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=2,sync_flag=3)
elif sync==4:
#simulated start real frame trigger no sync
sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=1,sync_flag=1)
elif sync==5:
#simulated start real frame trigger with sync
sp = ShapePath(comm, gather, args.verbose,fel_per=10,sync_mode=2,sync_flag=1)
else:
raise(ValueError(f'unsupported sync:{sync}'))
fn='/tmp/shapepath'
#fn =unique_filename('ShapePathAnalyser/records/19_01_24/spiral')
@@ -1130,7 +1144,8 @@ if __name__=='__main__':
gp.grid(w=10,h=15,pitch=120,rnd=0,ofs=(-1000,-1200));gp.sort(grp_sz=15)
# for motion mode 4,5
grid={'pos':(-1000, -1200), 'pitch':(120, 120), 'count':(10, 15)}
#grid={'pos':(-1000, -1200), 'pitch':(120, 120), 'count':(10, 15)}
grid={'pos':(-1000, -1200), 'pitch':(120, 120), 'count':(20, 25)}
# mode:0 unused
# mode:1 pvt motion
@@ -1139,7 +1154,6 @@ if __name__=='__main__':
# mode:4 pvt motion short code using grid parameters
# mode:5 pvt motion short code using grid parameters. Instead of continous motion it moves and waits as give in the parameter time
#mode=3;scale=0
mode=5
if mode==5:
tmove=20 # time to move in ms
twait=130# time to move in ms
@@ -1160,6 +1174,8 @@ if __name__=='__main__':
sp.setup_motion(fnPrg=fn+'.prg',scale=1.,cnt=1,dwell=100,mode=4,grid=grid)
elif mode==5:
sp.setup_motion(fnPrg=fn+'.prg',scale=1.,cnt=1,dwell=100,mode=5,tmove=tmove, twait=twait, grid=grid)
else:
raise(ValueError(f'unsupported mode:{mode}'))
if sp.comm:
sp.setup_gather()
@@ -1169,7 +1185,7 @@ if __name__=='__main__':
_log.info('wait_armed')
sp.wait_armed() # wait until motors are at first position
_log.info('trigger')
sp.trigger(0.5) #send a start trigger (if needed) ater given time
sp.trigger(0.5) #send a start trigger (if needed) after given time
_log.info('progress..')
if not comm is None:
while True:
@@ -1185,13 +1201,15 @@ if __name__=='__main__':
def parse_args():
'main command line interpreter function'
(h, t)=os.path.split(sys.argv[0]);cmd='\n '+(t if len(h)>3 else sys.argv[0])+' '
exampleCmd=('-v15',
'--host=SAR-CPPM-EXPMX1 -v 0x5d',
'--host=localhost:10001:10002 -v 0x59'
exampleCmd=('-v0xff',
'--host=SAR-CPPM-EXPMX1 -v0x5d',
'--host=localhost:10001:10002 -v0x59',
'--host=SAR-CPPM-EXPMX1 -v0x5d -m5',
)
epilog=__doc__+'\nExamples:'+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
parser=argparse.ArgumentParser(epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("-m", "--mode", type=lambda x:int(x, 0), help="mode (see bitmasks) default=0x%(default)x", default=0xff)
parser.add_argument("-m", "--mode", type=lambda x:int(x, 0), help="mode default=0x%(default)x", default=4)
parser.add_argument("-s", "--sync", type=lambda x:int(x, 0), help="sync default=0x%(default)x", default=2)
parser.add_argument('-v', '--verbose', type=lambda x:int(x, 0), dest='verbose', help='verbosity bits (see below) default=0x%(default)x', default=0x00)
parser.add_argument('--host', help='hostname', default=None)