majot rework of shapepath.py
This commit is contained in:
1 parent
ad149fb750
commit
6141dba696
2 files changed
+204
-198
No files matched your search
+199
-195
@@ -9,7 +9,7 @@
|
||||
shape an optimal path with given points
|
||||
|
||||
verbose bits:
|
||||
0x01 basic info
|
||||
0x01 basic info
|
||||
0x02 plot sorting steps
|
||||
0x04 list program
|
||||
0x08 upload progress
|
||||
@@ -56,11 +56,10 @@ sendgetsends -1
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
try: raw_input;input=raw_input
|
||||
except NameError: pass
|
||||
import logging
|
||||
_log=logging.getLogger(__name__)
|
||||
|
||||
import os, sys, time
|
||||
import os, sys, time, re
|
||||
import numpy as np
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
@@ -339,7 +338,7 @@ class DebugPlot:
|
||||
pts=self.pts # X,Y array
|
||||
rec = self.rec # yA,xA,yD,xD,trig
|
||||
except AttributeError as e:
|
||||
print('plot_gather(): '+str(e)+': no data acquired yet')
|
||||
_log.warning('plot_gather(): '+str(e)+': no data acquired yet')
|
||||
return
|
||||
|
||||
if mode&1:
|
||||
@@ -456,82 +455,55 @@ class DebugPlot:
|
||||
|
||||
def set_data(self,spObj):
|
||||
self.meta=spObj.meta
|
||||
self.pts=spObj.points
|
||||
self.pts=spObj.mot_pts
|
||||
try: self.rec=spObj.rec
|
||||
except AttributeError: pass
|
||||
try: self.pvt=spObj.pvt
|
||||
except AttributeError: pass
|
||||
|
||||
|
||||
class ShapePath(MotionBase):
|
||||
'''
|
||||
member variables:
|
||||
meta: defined in base class MotionBase
|
||||
MotionBase uses keys:
|
||||
srv_per
|
||||
pt2pt_time
|
||||
sync_flag
|
||||
sync_mode
|
||||
additional keys from function setup_gather():
|
||||
acq_per
|
||||
address
|
||||
|
||||
points: numpy array of raw points (motor values not X,Y-cooridnate values)
|
||||
|
||||
'''
|
||||
def __init__(self,comm, gather, verbose,**kwargs):
|
||||
MotionBase.__init__(self,comm, gather, verbose, **kwargs)
|
||||
|
||||
def gen_swissmx_points(self,flipx=False,flipy=False,ofs=(0,0),width=1000):
|
||||
class GenPath():
|
||||
def __init__(self, verbose=0xff):
|
||||
self.verbose=verbose
|
||||
def swissmx(self,flipx=False,flipy=False,ofs=(0,0),width=1000):
|
||||
'generathe a path that writes swissfel'
|
||||
#string from inkscape path of the drawing
|
||||
d="m 524.7061,637.31536 3.54883,0 3.54882,0 3.54883,0 0,-4.20801 0,-4.20801 0,-4.208 0,-4.20801 4.22949,0 4.22949,0 4.2295,0 4.22949,0 0,-3.55957 0,-3.55957 0,-3.55957 0,-3.55957 -4.22949,0 -4.2295,0 -4.22949,0 -4.22949,0 0,-4.22949 0,-4.2295 0,-4.22949 0,-4.22949 -3.54883,0 -3.54882,0 -3.54883,0 -3.54883,0 0,4.22949 0,4.22949 0,4.2295 0,4.22949 -4.20752,0 -4.20752,0 -4.20752,0 -4.20752,0 0,3.55957 0,3.55957 0,3.55957 0,3.55957 4.20752,0 4.20752,0 4.20752,0 4.20752,0 0,4.20801 0,4.208 0,4.20801 0,4.20801 -11.87126,0.36152 -12.12171,-0.13934 -2.52941,3.93977 -2.57238,3.94369 -2.50854,3.88614 -2.50731,3.91767 -2.49035,3.88268 -2.50987,3.91244 -2.50453,3.88732 -2.51897,3.9189 -6.39782,5.72802 -6.63782,6.70894 -3.21517,5.11464 -3.3404,5.32333 -3.08995,5.11464 -3.17343,5.15637 -16.69223,0.0698 5.55908,0 5.55909,0 5.55908,0 3.18604,-5.17432 3.18603,-5.17431 3.18604,-5.17432 3.18603,-5.17431 3.17481,5.17431 3.1748,5.17432 3.17481,5.17431 3.1748,5.17432 5.59229,0 5.59228,0 5.59229,0 5.59228,0 -2.74121,-4.15283 -2.74121,-4.15283 -2.74121,-4.15283 -2.74121,-4.15284 -2.74122,-4.15283 -2.74121,-4.15283 -2.74121,-4.15283 -2.74121,-4.15283 2.50488,-3.90015 2.50489,-3.90015 2.50488,-3.90014 2.50488,-3.90015 2.50488,-3.90015 2.50489,-3.90015 2.50488,-3.90014 2.50488,-3.90015 -5.42724,0 -5.42725,0 -5.42724,0 -5.42725,0 -2.76855,4.95508 -2.76856,4.95508 -2.76855,4.95508 -2.76856,4.95508 -2.85644,-4.95508 -2.85645,-4.95508 -2.85644,-4.95508 -2.85645,-4.95508 -5.48193,0 -5.48194,0 -5.48194,0 -5.48193,0 2.52686,3.8562 2.52685,3.8562 2.52686,3.8562 2.52686,3.85621 2.52685,3.8562 2.52686,3.8562 2.52685,3.8562 2.52686,3.8562 -2.77954,4.19678 -2.77954,4.19678 -2.77954,4.19677 -2.77955,4.19678 -2.77954,4.19678 -2.77954,4.19678 -2.77954,4.19677 -2.77954,4.19678 -4.91638,0 -4.91638,0 -4.91639,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91639,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91639,0 -4.91638,0 -4.91638,0 4.07568,0 4.07568,0 4.07569,0 4.07568,0 0,-6.14136 0,-6.14135 0,-6.14136 0,-6.14136 0,-6.14136 0,-6.14135 0,-6.14136 0,-6.14136 1.57105,6.14136 1.57104,6.14136 1.57104,6.14135 1.57105,6.14136 1.57105,6.14136 1.57104,6.14136 1.57104,6.14135 1.57105,6.14136 3.68066,0 3.68067,0 3.68067,0 3.68066,0 1.57642,-6.14136 1.57641,-6.14135 1.57642,-6.14136 1.57641,-6.14136 1.57642,-6.14136 1.57642,-6.14135 1.57641,-6.14136 1.57642,-6.14136 0,6.14136 0,6.14136 0,6.14135 0,6.14136 0,6.14136 0,6.14136 0,6.14135 0,6.14136 4.06494,0 4.06494,0 4.06494,0 4.06494,0 0,-8.05298 0,-8.05298 0,-8.05298 0,-8.05297 0,-8.05298 0,-8.05298 0,-8.05298 0,-8.05298 -6.52588,0 -6.52588,0 -6.52587,0 -6.52588,0 -1.25781,4.8999 -1.25782,4.89991 -1.25781,4.8999 -1.25781,4.8999 -1.25781,4.8999 -1.25782,4.89991 -1.25781,4.8999 -1.25781,4.8999 -1.26343,-4.8999 -1.26343,-4.8999 -1.26343,-4.89991 -1.26343,-4.8999 -1.26342,-4.8999 -1.26343,-4.8999 -1.26343,-4.89991 -1.26343,-4.8999 -6.54785,0 -6.54785,0 -6.54785,0 -6.54785,0 0,8.05298 0,8.05298 0,8.05298 0,8.05298 0,8.05297 0,8.05298 0,8.05298 -4.25755,8.13646 -8.40743,0.19687 -8.40743,0.19687 -8.40743,0.19687 -8.40743,0.19687 5.93521,0.22812 8.09742,-0.56079 6.18579,-1.6814 4.55883,-2.66919 3.13062,-3.43823 1.84571,-3.87866 0.61523,-3.98853 -0.58179,-3.83373 -1.74634,-3.50416 -2.802,-2.95581 -3.83472,-2.18676 -5.49316,-1.60401 -7.77832,-1.20849 -7.64649,-1.58204 -1.75781,-2.59179 1.36328,-2.59375 4.4375,-1.09766 5.09766,1.40625 2.19727,3.29492 4.24072,-0.41748 4.24073,-0.41748 4.24072,-0.41748 4.24072,-0.41748 -1.98804,-4.09741 -2.44946,-3.15259 -2.97778,-2.3291 -3.65894,-1.62598 -5.05371,-0.95629 -7.25098,-0.3191 -7.10766,0.41748 -5.50367,1.25244 -4.19677,2.05494 -3.18604,2.91186 -2.01099,3.65796 -0.67065,4.29517 0.61523,3.98852 1.84571,3.5271 2.78002,2.823 3.32935,1.87817 5.06421,1.42822 7.89868,1.56006 7.69141,1.84571 2.02148,2.98828 -1.53906,2.85742 -5.58008,1.53711 -5.27344,-1.36133 -3.07617,-4.52734 -4.43847,0.41748 -4.43848,0.41748 -4.43848,0.41748 -4.43847,0.41748 2.50488,5.95459 4.43848,4.4165 3.18313,1.59592 4.10031,1.14017 -3.65979,0.0939 -5.9713,6e-5 -5.97131,5e-5 -5.9713,6e-5 -5.9713,6e-5 -5.9713,5e-5 -5.97131,6e-5 -5.9713,5e-5 -5.9713,6e-5 5.34491,0.81842 8.09742,-0.56079 6.18579,-1.6814 4.55883,-2.66919 3.13062,-3.43823 1.84571,-3.87866 0.61523,-3.98853 -0.58179,-3.83373 -1.74634,-3.50416 -2.802,-2.95581 -3.83472,-2.18676 -5.49316,-1.60401 -7.77832,-1.20849 -7.64649,-1.58204 -1.75781,-2.59179 1.36328,-2.59375 4.4375,-1.09766 5.09766,1.40625 2.19727,3.29492 4.24072,-0.41748 4.24073,-0.41748 4.24072,-0.41748 4.24072,-0.41748 -1.98804,-4.09741 -2.44946,-3.15259 -2.97778,-2.3291 -3.65894,-1.62598 -5.05371,-0.95629 -7.25098,-0.3191 -7.10766,0.41748 -5.50367,1.25244 -4.19677,2.05494 -3.18604,2.91186 -2.01099,3.65796 -0.67065,4.29517 0.61523,3.98852 1.84571,3.5271 2.78002,2.823 3.32935,1.87817 5.06421,1.42822 7.89868,1.56006 7.69141,1.84571 2.02148,2.98828 -1.53906,2.85742 -5.58008,1.53711 -5.27344,-1.36133 -3.07617,-4.52734 -4.43847,0.41748 -4.43848,0.41748 -4.43848,0.41748 -4.43847,Line truncated
|
||||
d=d.split()
|
||||
pts=np.ndarray((len(d)-1,2),dtype=np.float)
|
||||
for i in xrange(pts.shape[0]):
|
||||
pts[i,:]=map(float,d[i+1].split(','))
|
||||
for i in range(pts.shape[0]):
|
||||
pts[i,:]=tuple(map(float,d[i+1].split(',')))
|
||||
|
||||
pts[0,:]=(0,0)
|
||||
pts=pts.cumsum(0)
|
||||
pts=pts[::-1,:]
|
||||
pts=pts-pts[0]
|
||||
pts*=width/pts[:,0].max()
|
||||
if flipx: pts[:,0]=-pts[:,0]
|
||||
if not flipy: pts[:,1]=-pts[:,1]
|
||||
pts=pts-pts.min(0)
|
||||
pts*=width/pts[:,0].max()
|
||||
pts+=ofs
|
||||
self.points=pts
|
||||
|
||||
verb=self.verbose
|
||||
if verb&0x02:
|
||||
self.plot_points(pts)
|
||||
plt.show(block=False)
|
||||
|
||||
|
||||
def gen_swissfel_points(self,flipx=False,flipy=False,ofs=(0,0),width=1000):
|
||||
def swissfel(self,flipx=False,flipy=False,ofs=(0,0),width=1000):
|
||||
'generathe a path that writes swissfel'
|
||||
#string from inkscape path of the drawing
|
||||
d="m 15.801613,951.54022 -1.655274,-0.17578 -1.809082,-0.52002 0,-1.52344 1.765137,0.76172 1.699219,0.25635 1.955566,-0.49805 0.688477,-1.4209 -0.498047,-1.25976 -1.618652,-0.68115 -0.900879,-0.17578 -1.426392,-0.42298 -0.968628,-0.60974 -0.739746,-1.95557 0.254516,-1.29638 0.76355,-0.98877 1.217652,-0.62622 1.602173,-0.20874 1.567383,0.13916 1.6333,0.41748 0,1.44287 -1.589355,-0.60059 -1.442871,-0.19775 -1.071167,0.11719 -0.796509,0.35156 -0.651856,1.33301 0.432129,1.09863 1.655274,0.59326 0.893555,0.18311 1.437377,0.43579 1.001587,0.67749 0.593262,0.92651 0.197754,1.19751 -0.267334,1.3971 -0.802002,1.01257 -1.311035,0.61523 2.995605,-0.004 2.995606,-0.004 -0.536499,-2.05078 -0.536499,-2.05078 -0.536499,-2.05079 -0.536499,-2.05078 1.347656,0 0.421142,1.60034 0.421143,1.60034 0.421143,1.60035 0.421142,1.60034 0.419312,-1.60034 0.419311,-1.60035 0.419312,-1.60034 0.419311,-1.60034 1.589356,0 0.421142,1.60034 0.421143,1.60034 0.421143,1.60035 0.421142,1.60034 0.419312,-1.60034 0.419311,-1.60035 0.419312,-1.60034 0.419311,-1.60034 1.347657,0 -0.536499,2.05078 -0.5365,2.05079 -0.536499,2.05078 -0.536499,2.05078 -1.589355,0 -0.441284,-1.68091 -0.441285,-1.68091 -0.441284,-1.6809 -0.441284,-1.68091 -0.443115,1.68091 -0.443116,1.6809 -0.443115,1.68091 -0.443115,1.68091 2.330933,-8e-5 2.330933,-8e-5 2.330932,-8e-5 2.330933,-8e-5 0,-2.05078 0,-2.05078 0,-2.05079 0,-2.05078 0.673828,-1.48681 0.673828,0 0,-0.85327 0,-0.85327 -0.673828,0 -0.673828,0 0,0.85327 0,0.85327 0.673828,1.48681 0.673828,0 0,2.05078 0,2.05079 0,2.05078 0,2.05078 2.545166,0.1062 2.545166,0.1062 -1.376953,-0.13183 -1.501465,-0.38086 0,-1.3916 1.472168,0.58593 1.435547,0.19043 1.464844,-0.32226 0.512695,-0.92285 -0.373535,-0.84229 -1.038789,-0.41935 -1.048614,-0.25448 -1.078491,-0.33325 -0.730591,-0.47241 -0.55664,-1.50147 0.205078,-1.02539 0.615234,-0.76172 0.99243,-0.47241 1.336672,-0.15747 1.40625,0.10986 1.21582,0.32959 0,1.27442 -1.186523,-0.43946 -1.274414,-0.14648 -1.508789,0.30762 -0.498047,0.92285 0.358886,0.73975 0.763094,0.30189 0.76857,0.22893 0.785513,0.20842 0.813927,0.24037 0.809326,0.49988 0.455932,0.66833 0.151978,0.89173 -0.227051,1.02355 -0.681152,0.78553 -1.071167,0.49988 3.205262,0.0833 3.205261,0.0833 -1.376953,-0.13183 -1.501465,-0.38086 0,-1.3916 1.472168,0.58593 1.435547,0.19043 1.464843,-0.32226 0.512696,-0.92285 -0.373536,-0.84229 -1.038789,-0.41935 -1.048613,-0.25448 -1.078491,-0.33325 -0.730591,-0.47241 -0.556641,-1.50147 0.205078,-1.02539 0.615235,-0.76172 0.99243,-0.47241 1.336672,-0.15747 1.40625,0.10986 1.21582,0.32959 0,1.27442 -1.186524,-0.43946 -1.274414,-0.14648 -1.508789,0.30762 -0.498047,0.92285 0.358887,0.73975 0.805073,0.3095 0.76935,0.22988 0.764915,0.20509 0.791765,0.23514 0.809327,0.49988 0.455932,0.66833 0.151978,0.89173 -0.227051,1.02355 -0.681152,0.78553 -1.071167,0.49988 2.095642,-0.0229 2.095642,-0.0229 0,-1.36688 0,-1.36688 0,-1.36689 0,-1.36688 0,-1.36688 0,-1.36688 0,-1.36689 0,-1.36688 1.571045,0 1.571045,0 1.571045,0 1.571045,0 0,1.24512 -1.201172,0 -1.201172,0 -1.201172,0 -1.201172,0 0,0.80566 0,0.80567 0,0.80566 0,0.80566 1.083984,0 1.083985,0 1.083984,0 1.083985,0 0,1.24512 -1.083985,0 -1.083984,0 -1.083985,0 -1.083984,0 0,1.30554 0,1.30555 0,1.30554 0,1.30554 3.581543,0 3.581543,0 0,-1.36688 0,-1.36688 0,-1.36689 0,-1.36688 0,-1.36688 0,-1.36688 0,-1.36689 0,-1.36688 1.728516,0 1.728516,0 1.728515,0 1.728516,0 0,1.24512 -1.358643,0 -1.358642,0 -1.358643,0 -1.358643,0 0,0.80932 0,0.80933 0,0.80933 0,0.80932 1.30188,0 1.30188,0 1.30188,0 1.30188,0 0,1.24512 -1.30188,0 -1.30188,0 -1.30188,0 -1.30188,0 0,0.9906 0,0.9906 0,0.9906 0,0.9906 1.391602,0 1.391601,0 1.391602,0 1.391602,0 0,1.24512 -3.587581,3.8e-4 -1.964972,0 3.702844,0 4.295998,0 0,-1.36733 0,-1.36688 0,-1.36689 0,-1.36688 0,-1.36688 0,-1.36689 0,-1.36688 0,-1.36688 1.479492,0 0,1.21124 0,1.21124 0,1.21125 0,1.21124 0,1.21124 0,1.21124 0,1.21125 0,1.21124 1.331177,0 1.331177,0 1.331176,0 1.331177,0 0,1.24512 -1.70105,0 -1.701049,0 -1.70105,0"
|
||||
d=d.split()
|
||||
pts=np.ndarray((len(d)-1,2),dtype=np.float)
|
||||
for i in xrange(pts.shape[0]):
|
||||
pts[i,:]=map(float,d[i+1].split(','))
|
||||
for i in range(pts.shape[0]):
|
||||
pts[i,:]=tuple(map(float,d[i+1].split(',')))
|
||||
|
||||
pts[0,:]=(0,0)
|
||||
pts=pts.cumsum(0)
|
||||
pts=pts[::-1,:]
|
||||
pts=pts-pts[0]
|
||||
pts*=width/pts[:,0].max()
|
||||
if flipx: pts[:,0]=-pts[:,0]
|
||||
if not flipy: pts[:,1]=-pts[:,1]
|
||||
pts=pts-pts.min(0)
|
||||
pts*=width/pts[:,0].max()
|
||||
pts+=ofs
|
||||
self.points=pts
|
||||
|
||||
verb=self.verbose
|
||||
if verb&0x02:
|
||||
self.plot_points(pts)
|
||||
plt.show(block=False)
|
||||
|
||||
def gen_rand_points(self,n=107,scale=1000,ofs=(0,0)):
|
||||
def rand(self,n=107,scale=1000,ofs=(0,0)):
|
||||
'generate random distributed points'
|
||||
np.random.seed(0)
|
||||
#data=np.random.randint(0,1000,(30,2))
|
||||
@@ -539,7 +511,7 @@ class ShapePath(MotionBase):
|
||||
pts+=ofs
|
||||
self.points=pts
|
||||
|
||||
def gen_grid_points(self,w=10,h=10,pitch=100,rnd=.2,ofs=(0,0)):
|
||||
def grid(self,w=10,h=10,pitch=100,rnd=.2,ofs=(0,0)):
|
||||
'generates points in a grid with a given pitch and a bit randomness'
|
||||
np.random.seed(0)
|
||||
xx,yy=np.meshgrid(range(w), range(h))
|
||||
@@ -549,7 +521,7 @@ class ShapePath(MotionBase):
|
||||
pts+=ofs
|
||||
self.points=pts
|
||||
|
||||
def gen_spiral_points(self,rStart=1.,rInc=.2,numSeg=4,numCir=6, phase=0, ofs=(0, 0)):
|
||||
def spiral(self,rStart=1.,rInc=.2,numSeg=4,numCir=6, phase=0, ofs=(0, 0)):
|
||||
#rInc radius increment per circle
|
||||
r=rStart+np.arange(numSeg*numCir)*(float(rInc)/numSeg)
|
||||
ang=2.*np.pi/numSeg*np.arange(numSeg*numCir)+phase*np.pi/180
|
||||
@@ -558,7 +530,7 @@ class ShapePath(MotionBase):
|
||||
pts+=ofs
|
||||
self.points=pts
|
||||
|
||||
def gen_closed_shifted(self,pitch=100,shift=5,mult=3):
|
||||
def closed_shifted(self,pitch=100,shift=5,mult=3):
|
||||
'from the given points, close the path, and runs 9 times with small pitch'
|
||||
|
||||
pts=self.points
|
||||
@@ -570,7 +542,7 @@ class ShapePath(MotionBase):
|
||||
bk=[]
|
||||
if abs(d[1])>pitch: #make a vertical back move
|
||||
s=np.sign(d[1])
|
||||
n=np.ceil(np.abs(d[1])/pitch)
|
||||
n=int(np.ceil(np.abs(d[1])/pitch))
|
||||
p=np.ndarray((n,2))
|
||||
p[:,0]=pts[-1, 0]
|
||||
p[:,1]=pts[-1, 1]+np.arange(1,n+1)*s*pitch
|
||||
@@ -578,7 +550,7 @@ class ShapePath(MotionBase):
|
||||
|
||||
if abs(d[0])>pitch: #make a horizonlat back move
|
||||
s=np.sign(d[0])
|
||||
n=np.ceil(np.abs(d[0])/pitch)
|
||||
n=int(np.ceil(np.abs(d[0])/pitch))
|
||||
p=np.ndarray((n,2))
|
||||
p[:,0]=pts[-1, 0]+np.arange(1,n+1)*s*pitch
|
||||
p[:,1]=pts[-1, 1]
|
||||
@@ -590,12 +562,19 @@ class ShapePath(MotionBase):
|
||||
for x in np.arange(mult)*shift:
|
||||
stack.append(pts+(x,y))
|
||||
pts=np.vstack(stack)
|
||||
if self.verbose&0x02:
|
||||
DebugPlot.plot_points(pts)
|
||||
plt.show(block=False)
|
||||
self.points=pts
|
||||
|
||||
|
||||
def sort_points(self,xy=False,grp_sz=None):
|
||||
def sort(self,mode=1,grp_sz=None):
|
||||
'''
|
||||
sorts self.points in forward backward scanning groups
|
||||
:param mode: 0:X fast Y slow 1:Y fast X slow
|
||||
:param grp_sz: size of group to scan in one direction
|
||||
'''
|
||||
pts=self.points
|
||||
verb=self.verbose
|
||||
|
||||
cnt=pts.shape[0]
|
||||
idx=np.ndarray(cnt,dtype=np.int32)
|
||||
@@ -606,7 +585,7 @@ class ShapePath(MotionBase):
|
||||
grp_sz=int(grp_sz)
|
||||
grp_cnt=int(np.ceil(float(cnt)/grp_sz))
|
||||
|
||||
if xy==True:
|
||||
if mode==0:
|
||||
idxA=1;idxB=0
|
||||
else:
|
||||
idxA=0;idxB=1
|
||||
@@ -624,37 +603,29 @@ class ShapePath(MotionBase):
|
||||
#print(idx)
|
||||
pts=pts[idx]
|
||||
|
||||
if verb&0x02:
|
||||
DebugPlot.plot_points(pts)
|
||||
plt.show(block=False)
|
||||
self.points=pts
|
||||
|
||||
class ShapePath(MotionBase):
|
||||
'''
|
||||
member variables:
|
||||
meta: defined in base class MotionBase
|
||||
MotionBase uses keys:
|
||||
srv_per
|
||||
pt2pt_time
|
||||
sync_flag
|
||||
sync_mode
|
||||
additional keys from function setup_gather():
|
||||
acq_per
|
||||
address
|
||||
|
||||
def opt_pts(self,fn):
|
||||
'''
|
||||
trial to optimize path by mofing trajectory, uload real path and move the points
|
||||
to finally go trough the desired points
|
||||
'''
|
||||
fh=np.load(fn)
|
||||
#res=rot.ActPos,x.ActPos,y.ActPos,rot.DesPos,x.DesPos,y.DesPos
|
||||
#idx 0 1 2 3 4 5
|
||||
rec=fh['rec']
|
||||
pts=fh['pts']
|
||||
desPos=rec[:,(3,2)]
|
||||
mot_pts: numpy array of raw motor points (motor values not X,Y-cooridnate values)
|
||||
|
||||
idx=np.ndarray(shape=len(pts),dtype=np.int32)
|
||||
for i in range(len(pts)):
|
||||
l=desPos-pts[i,:]
|
||||
l2=l[:,0]**2+l[:,1]**2
|
||||
idx[i]=np.argmin(l2)
|
||||
'''
|
||||
def __init__(self,comm, gather, verbose,**kwargs):
|
||||
MotionBase.__init__(self,comm, gather, verbose, **kwargs)
|
||||
|
||||
recPts=rec[idx,:]
|
||||
ptsCorr=(pts-recPts[:,(1,0)]+recPts[:,(3,2)])
|
||||
self.points=pts
|
||||
self.ptsCorr=ptsCorr
|
||||
print(ptsCorr)
|
||||
|
||||
def setup_gather(self,acq_per=None):
|
||||
def setup_gather(self,acq_per=None,numPts=None):
|
||||
'''
|
||||
setup the channels to gather
|
||||
kwargs:
|
||||
@@ -673,14 +644,22 @@ class ShapePath(MotionBase):
|
||||
#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)
|
||||
if acq_per is None:
|
||||
if numPts is None:
|
||||
numPts=self.mot_pts.shape[0]
|
||||
ovhdTime=100
|
||||
acq_per=int(np.ceil((meta['pt2pt_time']*self.points.shape[0]+ovhdTime)/(gtMaxLn*meta['srv_per'])))
|
||||
acq_per=int(np.ceil((meta['pt2pt_time']*numPts+ovhdTime)/(gtMaxLn*meta['srv_per'])))
|
||||
gt.set_property(MaxSamples=1000000, Period=acq_per)
|
||||
#gt.set_property(Period=acq_per)
|
||||
meta.update({'acq_per':acq_per,'address':address})
|
||||
|
||||
def setup_coord_trf(self,fx='X',fy='Y',cz='0'):
|
||||
# FY:1, FX:2, ROT_Y:3, CX:4, CZ:5,
|
||||
#0X 0Y 0Z are not allowed in the coordinates !!!
|
||||
ptrn='[+-][0]*[XYZ]'
|
||||
fx=re.sub(ptrn,'',fx)
|
||||
fy=re.sub(ptrn,'',fy)
|
||||
cz=re.sub(ptrn,'',cz)
|
||||
_log.info(f'\n fx->{fx}\n fy->{fy}\n cz->{cz}')
|
||||
if self.comm is None: return
|
||||
comm = self.comm
|
||||
gpascii = comm.gpascii
|
||||
@@ -704,23 +683,31 @@ class ShapePath(MotionBase):
|
||||
def setup_motion(self,prgId=2,fnPrg=None,mode=0,**kwargs):
|
||||
'''
|
||||
generates program <prgId> and saves to fnPrg
|
||||
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'
|
||||
|
||||
common kwargs:
|
||||
scale : scaling velocity (default=1. value=0 would stop at each point
|
||||
cnt : move path multiple times (default=1)
|
||||
dwell : dwell time at end (default=100ms)
|
||||
|
||||
mode:0 unused
|
||||
mode:1 pvt motion
|
||||
kwargs:
|
||||
scale : scaling velocity (default=1. value=0 would stop at the point
|
||||
cnt : move path multiple times (default=1)
|
||||
dwell : dwell time at end (default=100ms)
|
||||
common kwargs plus:
|
||||
points : point list
|
||||
trf : optional transformation that will be done on 'points', mot_pts=trf*points
|
||||
mode:2 unused
|
||||
mode:3 pvt motion using inverse fft velocity
|
||||
kwargs : same as pvt motion plus:
|
||||
common kwargs plus:
|
||||
points : point list
|
||||
trf : optional transformation that will be done on 'points', mot_pts=trf*points
|
||||
numPad : number of padding points to reduce aliasing (default=16)
|
||||
mode:4 pvt motion short code using grid parameters
|
||||
kwargs : same as pvt motion plus:
|
||||
common kwargs plus:
|
||||
trf : transformation that will be done on 'grid points'
|
||||
grid: grid parameters: {orig:(0,0),pitch(10,10),cnt:(10,10),mode:0}
|
||||
mode=0 ->X,Y 'snake' scan
|
||||
mode=0 ->Y,X 'snake' scan
|
||||
scan=0 ->X,Y 'snake' scan
|
||||
scan=1 ->Y,X 'snake' scan
|
||||
|
||||
'''
|
||||
prg=f'close all buffers\nopen prog {prgId}\n'
|
||||
@@ -729,6 +716,10 @@ class ShapePath(MotionBase):
|
||||
comm=self.comm
|
||||
if comm is not None:
|
||||
gpascii=comm.gpascii
|
||||
try:
|
||||
self.sync_prg
|
||||
except AttributeError:
|
||||
_log.warning('missing motion sync code!')
|
||||
# this uses Coord[1].Tm and limits with MaxSpeed
|
||||
if mode in (1,3,4): #### pvt motion
|
||||
pt2pt_time=self.meta['pt2pt_time']
|
||||
@@ -738,10 +729,13 @@ class ShapePath(MotionBase):
|
||||
dwell=kwargs.get('dwell', 100) # wait time at end of motion
|
||||
CoordFeedTime=1000. #Defaut deltatau value
|
||||
if mode in (1, 3): #### pvt motion, using points
|
||||
pt=kwargs['points']
|
||||
try:
|
||||
pt=self.ptsCorr
|
||||
except AttributeError:
|
||||
pt=self.points
|
||||
trf=kwargs['trf']
|
||||
except KeyError as e:
|
||||
self.mot_pts=pt
|
||||
else:
|
||||
self.mot_pts=(np.hstack((pt, np.ones((pt.shape[0], 1))))*np.asmatrix(trf)).A # pt*trf
|
||||
#pv is an array of posx posy velx vely
|
||||
pv=np.ndarray(shape=(pt.shape[0]+2,4),dtype=pt.dtype)
|
||||
pv[:]=np.NaN
|
||||
@@ -771,17 +765,16 @@ class ShapePath(MotionBase):
|
||||
n=-numPad
|
||||
pv[ 1:-1,(2,3)] = v[:n]*scale
|
||||
if verb&0x20:
|
||||
dp=DebugPlot(self);self.pvt=dp.plot_gen_pvt(pv)
|
||||
plt.show(block=False)
|
||||
|
||||
if 'trf' in kwargs:
|
||||
_log.warning('correct ploting of pvt only works without transformation !')
|
||||
else:
|
||||
dp=DebugPlot(self);self.pvt=dp.plot_gen_pvt(pv)
|
||||
plt.show(block=False)
|
||||
pv[1:-1, (2, 3)]*=CoordFeedTime #scaling for Deltatau
|
||||
prg+=' linear abs\n X%g Y%g\n' % tuple(pv[0, (0,1)])
|
||||
else: # mode==4: #### pvt motion, short code using grid parameters
|
||||
g=kwargs['grid']
|
||||
ox,oy=g['pos']
|
||||
px,py=g['pitch']
|
||||
nx,ny=g['count']
|
||||
|
||||
nx, ny=g['count']
|
||||
scan=0x2
|
||||
xx, yy=np.meshgrid(range(nx), range(ny))
|
||||
if scan&0x01: #modify x scaning forward backward each line
|
||||
@@ -792,9 +785,17 @@ class ShapePath(MotionBase):
|
||||
yy=yy.T
|
||||
for i in range(1, nx, 2):
|
||||
yy[i]=yy[i][::-1]
|
||||
pts=np.array([xx.reshape(-1), yy.reshape(-1)], dtype=np.float).transpose() #*pitch
|
||||
self.points=pts*g['pitch']+g['pos']
|
||||
|
||||
pt=np.array([xx.reshape(-1), yy.reshape(-1)], dtype=np.float).transpose() #*pitch
|
||||
try:
|
||||
trf=kwargs['trf']
|
||||
except KeyError as e:
|
||||
ox, oy=g['pos']
|
||||
px, py=g['pitch']
|
||||
self.mot_pts=pt
|
||||
else:
|
||||
ox, oy=(0,0)
|
||||
px, py=(1,1)
|
||||
self.mot_pts=(np.hstack((pt, np.ones((pt.shape[0], 1))))*np.asmatrix(trf)).A # pt*trf
|
||||
prg+=f' linear abs\n X{ox:g} Y{oy:g}\n'
|
||||
prg+=' dwell 10\n'
|
||||
try: prg+=self.sync_prg
|
||||
@@ -807,14 +808,16 @@ class ShapePath(MotionBase):
|
||||
prg+=' pvt%g abs\n'%pt2pt_time #100ms to next position
|
||||
if mode in (1,3):
|
||||
for idx in range(1,pv.shape[0]):
|
||||
prg+=f'N{idx} ' + 'X%g:%g Y%g:%g\n'%tuple(pv[idx,(0,2,1,3)])
|
||||
prg+=f'X{pv[-1, 0]} Y{pv[-1, 1]}\n'
|
||||
#prg+=f'N{idx} ' + 'X%g:%g Y%g:%g\n'%tuple(pv[idx,(0,2,1,3)])
|
||||
prg+=f' X%g:%g Y%g:%g\n'%tuple(pv[idx, (0, 2, 1, 3)])
|
||||
prg+=f' X{pv[-1, 0]:g} Y{pv[-1, 1]:g}\n'
|
||||
else: # mode=4
|
||||
#mode=0 # X fast Y slow
|
||||
mode=1 # X fast Y slow
|
||||
if mode==0:
|
||||
#scan=0 # X fast Y slow
|
||||
scan=1 # X fast Y slow
|
||||
if scan==0:
|
||||
raise Exception('scan=0 not supported')
|
||||
pass
|
||||
else: # mode=1
|
||||
else: # scan=1
|
||||
vx=px/(pt2pt_time)*scale*CoordFeedTime #scaling for Deltatau
|
||||
vy=py/(pt2pt_time)*scale*CoordFeedTime #scaling for Deltatau
|
||||
|
||||
@@ -824,12 +827,12 @@ L1=0 //slow loop x
|
||||
L0=0 //fast loop y
|
||||
while(L1<{nx})
|
||||
{{
|
||||
//send 1"A:move X%f:%f Y%f:%f",{ox}+L1*{px},0,{oy}+L0*{py},{vy/2:g}
|
||||
//send 1"A:move X%g:%g Y%g:%g",{ox}+L1*{px},0,{oy}+L0*{py},{vy/2:g}
|
||||
X({ox}+L1*{px}):0 Y({oy}+L0*{py}):{vy/2:g}
|
||||
L0+=1
|
||||
while(L0<{ny}-1)
|
||||
{{
|
||||
//send 1"B:move X%f:%f Y%f:%f",{ox}+L1*{px},0,{oy}+L0*{py},{vy:g}
|
||||
//send 1"B:move X%g:%g Y%g:%g",{ox}+L1*{px},0,{oy}+L0*{py},{vy:g}
|
||||
X({ox}+L1*{px}):0 Y({oy}+L0*{py}):{vy:g}
|
||||
L0+=1
|
||||
}}
|
||||
@@ -837,15 +840,15 @@ while(L1<{nx})
|
||||
{{
|
||||
break
|
||||
}}
|
||||
//send 1"C:move X%f:%f Y%f:%f",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{vy/2:g}
|
||||
//send 1"C:move X%g:%g Y%g:%g",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{vy/2:g}
|
||||
X({ox}+L1*{px}):{vx/2:g} Y({oy}+L0*{py}):{vy/2:g}
|
||||
L1+=1
|
||||
//send 1"D:move X%f:%f Y%f:%f",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{-vy/2:g}
|
||||
//send 1"D:move X%g:%g Y%g:%g",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{-vy/2:g}
|
||||
X({ox}+L1*{px}):{vx/2:g} Y({oy}+L0*{py}):{-vy/2:g}
|
||||
L0-=1
|
||||
while(L0>=1)
|
||||
{{
|
||||
//send 1"E:move X%f:%f Y%f:%f",{ox}+L1*{px},0,{oy}+L0*{py},{-vy:g}
|
||||
//send 1"E:move X%g:%g Y%g:%g",{ox}+L1*{px},0,{oy}+L0*{py},{-vy:g}
|
||||
X({ox}+L1*{px}):0 Y({oy}+L0*{py}):{-vy:g}
|
||||
L0-=1
|
||||
}}
|
||||
@@ -853,14 +856,14 @@ while(L1<{nx})
|
||||
{{
|
||||
break
|
||||
}}
|
||||
//send 1"F:move X%f:%f Y%f:%f",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{-vy/2:g}
|
||||
//send 1"F:move X%g:%g Y%g:%g",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{-vy/2:g}
|
||||
X({ox}+L1*{px}):{vx/2:g} Y({oy}+L0*{py}):{-vy/2:g}
|
||||
L1+=1
|
||||
//send 1"G:move X%f:%f Y%f:%f",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{vy/2:g}
|
||||
//send 1"G:move X%g:%g Y%g:%g",{ox}+L1*{px},{vx/2:g},{oy}+L0*{py},{vy/2:g}
|
||||
X({ox}+L1*{px}):{vx/2:g} Y({oy}+L0*{py}):{vy/2:g}
|
||||
L0+=1
|
||||
}}
|
||||
//send 1"H:move X%f:%f Y%f:%f",{ox}+L1*{px},{0:g},{oy}+L0*{py},{0:g}
|
||||
//send 1"H:move X%g:%g Y%g:%g",{ox}+L1*{px},{0:g},{oy}+L0*{py},{0:g}
|
||||
X({ox}+L1*{px}):{0:g} Y({oy}+L0*{py}):{0:g}
|
||||
|
||||
'''
|
||||
@@ -879,6 +882,9 @@ f(P100>0)
|
||||
else:
|
||||
prg+=f' dwell {dwell}\n Gather.Enable=0\nclose\n'
|
||||
#prg+='&1\nb%dr\n'%prgId)
|
||||
if verb&0x02:
|
||||
DebugPlot.plot_points(self.mot_pts)
|
||||
plt.show(block=False)
|
||||
if verb&0x04:
|
||||
print(prg)
|
||||
|
||||
@@ -904,7 +910,7 @@ f(P100>0)
|
||||
print(syncShell.sync())
|
||||
del self.syncShell
|
||||
|
||||
pts=self.points
|
||||
pts=self.mot_pts
|
||||
|
||||
ofsy=comm.gpascii.get_variable("Motor[1].HomePos", type_=float)
|
||||
ofsx=comm.gpascii.get_variable("Motor[2].HomePos", type_=float)
|
||||
@@ -915,8 +921,6 @@ f(P100>0)
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
import logging
|
||||
_log=logging.getLogger(__name__)
|
||||
logging.getLogger('pbtools.misc.pp_comm').setLevel(logging.INFO)
|
||||
logging.getLogger('paramiko').setLevel(logging.WARNING)
|
||||
logging.getLogger('matplotlib').setLevel(logging.INFO)
|
||||
@@ -936,16 +940,20 @@ if __name__=='__main__':
|
||||
|
||||
|
||||
def run_test(args):
|
||||
hpp=args.host.split(':')
|
||||
param={'host':hpp[0]}
|
||||
if len(hpp)>1:
|
||||
param['port']=int(hpp[1])
|
||||
if len(hpp)>2:
|
||||
param['fast_gather_port']=int(hpp[2])
|
||||
print(' -> ssh-tunneling PPComm({host}:{port} {host}:{fast_gather_port})'.format(**param))
|
||||
comm=PPComm(**param)
|
||||
gather=Gather(comm)
|
||||
if args.host:
|
||||
hpp=args.host.split(':')
|
||||
param={'host':hpp[0]}
|
||||
if len(hpp)>1:
|
||||
param['port']=int(hpp[1])
|
||||
if len(hpp)>2:
|
||||
param['fast_gather_port']=int(hpp[2])
|
||||
_log.info(' -> ssh-tunneling PPComm({host}:{port} {host}:{fast_gather_port})'.format(**param))
|
||||
comm=PPComm(**param)
|
||||
gather=Gather(comm)
|
||||
else:
|
||||
comm=gather=None
|
||||
|
||||
gp=GenPath()
|
||||
#real start and frame trigger with sync
|
||||
#sp = ShapePath(comm, gather, args.verbose)
|
||||
|
||||
@@ -980,84 +988,81 @@ if __name__=='__main__':
|
||||
# 10ms 3 6860
|
||||
# 10ms 4 9180
|
||||
|
||||
#sp.gen_grid_points(w=6,h=6,pitch=100,rnd=0,ofs=(0,0));sp.sort_points(False);
|
||||
#sp.gen_grid_points(w=100,h=100,pitch=10,rnd=.2)
|
||||
#sp.gen_swissfel_points(width=1000,ofs=(-500,0));sp.sort_points(xy=xy)
|
||||
#sp.gen_grid_points(w=10,h=10,pitch=50,rnd=.2)
|
||||
#sp.gen_grid_points(w=100,h=100,pitch=50,rnd=.2)
|
||||
#sp.gen_closed_shifted()
|
||||
#sp.gen_swissmx_points(width=1000,ofs=(-500,0))
|
||||
#sp.gen_swissfel_points(width=1000,ofs=(-500,0))
|
||||
#sp.gen_rand_points(n=20, scale=100,ofs=(-950,+2780));sp.sort_points(xy=False)
|
||||
#sp.gen_rand_points(n=200, scale=100,ofs=(0,+2000));sp.sort_points(xy=False)
|
||||
#sp.gen_swissmx_points(width=1000, ofs=(-500, 0));
|
||||
#sp.gen_spiral_points(rStart=100,rInc=10,numSeg=4,numCir=60, ofs=(0, 0))
|
||||
#sp.gen_spiral_points(rStart=100,rInc=130,numSeg=4,numCir=2, ofs=(0, 0))
|
||||
#sp.gen_grid_points(w=20,h=20,pitch=100,rnd=0,ofs=(0,+2000));sp.sort_points(False);
|
||||
#sp.gen_grid_points(w=5,h=10,pitch=100,rnd=0,ofs=(0,+2000));sp.sort_points(False,10);
|
||||
#gp.grid(w=6,h=6,pitch=100,rnd=0,ofs=(0,0));gp.sort()
|
||||
#gp.grid(w=100,h=100,pitch=10,rnd=.2)
|
||||
#gp.swissfel(width=1000,ofs=(-500,0));gp.sort()
|
||||
#gp.grid(w=10,h=10,pitch=50,rnd=.2)
|
||||
#gp.closed_shifted()
|
||||
#gp.grid(w=100,h=100,pitch=50,rnd=.2)
|
||||
#gp.swissmx(width=1000,ofs=(-500,0))
|
||||
#gp.swissfel(width=1000,ofs=(-500,0))
|
||||
#gp.rand(n=20, scale=100,ofs=(-950,+2780));gp.sort()
|
||||
#gp.rand(n=200, scale=100,ofs=(0,+2000));gp.sort()
|
||||
#gp.swissmx(width=1000, ofs=(-500, 0))
|
||||
#gp.spiral(rStart=100,rInc=10,numSeg=4,numCir=60, ofs=(0, 0))
|
||||
#gp.spiral(rStart=100,rInc=130,numSeg=4,numCir=2, ofs=(0, 0))
|
||||
#gp.grid(w=20,h=20,pitch=100,rnd=0,ofs=(0,+2000));gp.sort()
|
||||
#gp.grid(w=5,h=10,pitch=100,rnd=0,ofs=(0,+2000));gp.sort(grp_sz=10)
|
||||
|
||||
#sp.gen_grid_points(w=50,h=50,pitch=120,rnd=0,ofs=(0,+2000));sp.sort_points(False,50); sp.meta['pt2pt_time']=10
|
||||
#sp.gen_grid_points(w=16,h=16,pitch=120,rnd=0,ofs=(0,+2000));sp.sort_points(False,16); sp.meta['pt2pt_time']=10
|
||||
#gp.grid(w=50,h=50,pitch=120,rnd=0,ofs=(0,+2000));gp.sort(grp_sz=50); sp.meta['pt2pt_time']=10
|
||||
#gp.grid(w=16,h=16,pitch=120,rnd=0,ofs=(0,+2000));gp.sort(grp_sz=16); sp.meta['pt2pt_time']=10
|
||||
#12.5x12.5
|
||||
sp.gen_grid_points(w=78,h=78,pitch=120,rnd=0,ofs=(-10000,-12000));sp.sort_points(False,78); sp.meta['pt2pt_time']=10
|
||||
#gp.grid(w=78,h=78,pitch=120,rnd=0,ofs=(-10000,-12000));gp.sort(grp_sz=78); sp.meta['pt2pt_time']=10
|
||||
#23.0x23.0 -> only 3 data points from shot to shot: 6,9,12,14,17,20...
|
||||
#sp.gen_grid_points(w=162,h=162,pitch=120,rnd=0,ofs=(-10000,-12000));sp.sort_points(False,162); sp.meta['pt2pt_time']=10
|
||||
#gp.grid(w=162,h=162,pitch=120,rnd=0,ofs=(-10000,-12000));gp.sort(grp_sz=162); sp.meta['pt2pt_time']=10
|
||||
|
||||
#sp.gen_grid_points(w=1,h=10,pitch=100,rnd=0,ofs=(0,0))
|
||||
#sp.gen_spiral_points(rStart=100,rInc=20,numSeg=8,numCir=32, ofs=(0, 0))
|
||||
#sp.gen_spiral_points(rStart=100,rInc=10,numSeg=2,numCir=32, phase=45, ofs=(0, 0))
|
||||
#sp.gen_spiral_points(rStart=100,rInc=10,numSeg=4,numCir=32, ofs=(0, 0))
|
||||
#sp.gen_closed_shifted()
|
||||
#sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1.,dwell=10)
|
||||
sp.gen_grid_points(w=10,h=11,pitch=120,rnd=0,ofs=(-1000,-1200));sp.sort_points(False,11); sp.meta['pt2pt_time']=10
|
||||
#sp.setup_motion(fnPrg=fn+'.prg', mode=1, scale=1.,dwell=10)
|
||||
#grid={'pos':(-1000, -1200),'pitch':(120,120),'count':(10,11)}
|
||||
#gp.grid(w=1,h=10,pitch=100,rnd=0,ofs=(0,0))
|
||||
#gp.spiral(rStart=100,rInc=20,numSeg=8,numCir=32, ofs=(0, 0))
|
||||
#gp.spiral(rStart=100,rInc=10,numSeg=2,numCir=32, phase=45, ofs=(0, 0))
|
||||
#gp.spiral(rStart=100,rInc=10,numSeg=4,numCir=32, ofs=(0, 0))
|
||||
#gp.closed_shifted()
|
||||
gp.grid(w=10,h=15,pitch=120,rnd=0,ofs=(-1000,-1200));gp.sort(grp_sz=15); sp.meta['pt2pt_time']=10
|
||||
#gp.grid(w=10,h=15,pitch=120,rnd=0,ofs=(-1000,-1200));gp.sort(mode=0,grp_sz=10); sp.meta['pt2pt_time']=10
|
||||
|
||||
grid={'pos':(-1000, -1200),'pitch':(120,120),'count':(10,11)}
|
||||
#grid={'pos':(-500, -600),'pitch':(120,120),'count':(40,45)}
|
||||
#grid={'pos':(-500, -600),'pitch':(12,12),'count':(400,450)}
|
||||
|
||||
if sp.comm:
|
||||
gtMaxLn=int(sp.comm.gpascii.get_variable('Gather.MaxLines')) # 116508
|
||||
if gtMaxLn==0:
|
||||
sp.setup_gather(acq_per=1)
|
||||
gtMaxLn=int(sp.comm.gpascii.get_variable('Gather.MaxLines')) # 116508
|
||||
|
||||
ovhdTime=100
|
||||
acq_per=int(np.ceil((sp.meta['pt2pt_time']*sp.mot_pts.shape[0]+ovhdTime)/(gtMaxLn*sp.meta['srv_per'])))
|
||||
if args.verbose&0x01:
|
||||
_log.info(f'''\
|
||||
Gather.MaxLines:{gtMaxLn}
|
||||
Gather.Period: {acq_per}
|
||||
meta: {sp.meta}
|
||||
Filename: {fn}.[prg|npz]
|
||||
''')
|
||||
sp.setup_gather(acq_per=acq_per)
|
||||
sp.setup_sync(verbose=args.verbose&0x40,timeOfs=0.03,timeCor=0.0005)
|
||||
sp.setup_coord_trf() # reset to shape path system
|
||||
sp.meta['pt2pt_time']=10 #put between setup_sync and setup_motion to have more motion points than FEL syncs
|
||||
|
||||
|
||||
sp.setup_motion(fnPrg=fn+'.prg', mode=1, scale=1.,dwell=10,points=gp.points)
|
||||
#sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1.,dwell=10,points=gp.points)
|
||||
#sp.setup_motion(fnPrg=fn+'.prg', mode=4, scale=1.,dwell=10,grid=grid)
|
||||
|
||||
sp.gen_grid_points(w= 40,h=45,pitch=120,rnd=0,ofs=(-1000,-1200));sp.sort_points(False,45); sp.meta['pt2pt_time']=10
|
||||
sp.setup_motion(fnPrg=fn+'.prg', mode=1, scale=1.,dwell=10)
|
||||
grid={'pos':(-500, -600),'pitch':(120,120),'count':(40,45)}
|
||||
sp.setup_motion(fnPrg=fn+'.prg', mode=4, scale=1.,dwell=10,grid=grid)
|
||||
|
||||
|
||||
gtMaxLn=int(sp.comm.gpascii.get_variable('Gather.MaxLines')) # 116508
|
||||
if gtMaxLn==0:
|
||||
sp.setup_gather(acq_per=1)
|
||||
gtMaxLn=int(sp.comm.gpascii.get_variable('Gather.MaxLines')) # 116508
|
||||
|
||||
ovhdTime=100
|
||||
acq_per=int(np.ceil((sp.meta['pt2pt_time']*sp.points.shape[0]+ovhdTime)/(gtMaxLn*sp.meta['srv_per'])))
|
||||
if args.verbose&0x01:
|
||||
print(f'''\
|
||||
Gather.MaxLines:{gtMaxLn}
|
||||
Gather.Period: {acq_per}
|
||||
meta: {sp.meta}
|
||||
Filename: {fn}.[prg|npz]
|
||||
''')
|
||||
sp.setup_gather(acq_per=acq_per)
|
||||
sp.setup_sync(verbose=args.verbose&0x40,timeOfs=0.03,timeCor=0.0005)
|
||||
sp.setup_coord_trf() # reset to shape path system
|
||||
#sp.meta['pt2pt_time']=10 #put between setup_sync and setup_motion to have more motion points than FEL syncs
|
||||
#sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1.,dwell=10)
|
||||
|
||||
#NEW sp.setup_motion(fnPrg=fn+'.prg', mode=2, scale=1.,dwell=10)
|
||||
#sp.setup_motion(fnPrg=fn + '.prg', mode=1, scale=1,dwell=10)
|
||||
#sp.setup_motion(fnPrg=fn + '.prg', mode=1, scale=0,dwell=10)
|
||||
sp.homing() #homing if needed
|
||||
sp.run() #start motion program
|
||||
print('wait_armed')
|
||||
_log.info('wait_armed')
|
||||
sp.wait_armed() # wait until motors are at first position
|
||||
print('trigger')
|
||||
_log.info('trigger')
|
||||
sp.trigger(0.5) #send a start trigger (if needed) ater given time
|
||||
print('progress..')
|
||||
_log.info('progress..')
|
||||
if not comm is None:
|
||||
while True:
|
||||
p=sp.progress()
|
||||
if p<0: break
|
||||
print('progress %d/%d'%(p,sp.points.shape[0]));time.sleep(.1)
|
||||
_log.info('progress %d/%d'%(p,sp.points.shape[0]));time.sleep(.1)
|
||||
sp.gather_upload(fnRec=fn+'.npz')
|
||||
dp=DebugPlot(sp);dp.plot_gather(mode=11)
|
||||
print('done')
|
||||
_log.info('done')
|
||||
plt.show(block=False)
|
||||
input('press return')
|
||||
|
||||
@@ -1065,15 +1070,14 @@ Filename: {fn}.[prg|npz]
|
||||
'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=localhost:10001:10002 -v 0x5d',
|
||||
'--host=SAR-CPPM-EXPMX1 -v 0x5d',
|
||||
'--host=localhost:10001:10002 -v 0x59'
|
||||
)
|
||||
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('-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='SAR-CPPM-EXPMX1')
|
||||
#parser.add_option('--host', help='hostname', default='localhost:10001:10002')
|
||||
parser.add_argument('--host', help='hostname', default=None)
|
||||
|
||||
args=parser.parse_args()
|
||||
_log.info('Arguments:{}'.format(args.__dict__))
|
||||
|
||||
Reference in new issue
Block a user