wip
This commit is contained in:
16
Readme.md
16
Readme.md
@@ -1092,8 +1092,20 @@ cpx ;linear abs; X0 Z0 Y575 B0
|
|||||||
cpx ;linear abs; X0 Z0 Y575 B100000
|
cpx ;linear abs; X0 Z0 Y575 B100000
|
||||||
```
|
```
|
||||||
|
|
||||||
Matlab models 3.10.2018
|
Software esbMX deploy
|
||||||
-----------------------
|
---------------------
|
||||||
```
|
```
|
||||||
|
zamofing_t@ganymede:~$ ll /sf/bernina/config/swissmx/zamofing_t/
|
||||||
|
/sf/bernina/config/swissmx/
|
||||||
|
ssh sf-cons-01
|
||||||
|
ssh saresb-cons-01
|
||||||
|
source /opt/gfa/python
|
||||||
|
source activate /sf/bernina/config/swissmx/conda/envs/b440_clone
|
||||||
|
zamofing_t@ganymede:~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python$
|
||||||
|
cp *.py /sf/bernina/config/swissmx/zamofing_t
|
||||||
|
cp ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py ~/Documents/prj/SwissFEL/PBTools/ /sf/bernina/config/swissmx/zamofing_t
|
||||||
|
|
||||||
|
cp -rL ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py ~/Documents/prj/SwissFEL/PBTools/pbtools/ /sf/bernina/config/swissmx/zamofing_t/
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ import matplotlib.pyplot as plt
|
|||||||
import subprocess as sprc
|
import subprocess as sprc
|
||||||
|
|
||||||
sys.path.insert(0,os.path.expanduser('~/Documents/prj/SwissFEL/PBTools/'))
|
sys.path.insert(0,os.path.expanduser('~/Documents/prj/SwissFEL/PBTools/'))
|
||||||
|
#sys.path.insert(0,'/sf/bernina/config/swissmx/zamofing_t')
|
||||||
|
#sys.path.insert(0,'/sf/bernina/config/swissmx/zamofing_t/pbtools/misc/')
|
||||||
from pbtools.misc.pp_comm import PPComm
|
from pbtools.misc.pp_comm import PPComm
|
||||||
from pbtools.misc.gather import Gather
|
from pbtools.misc.gather import Gather
|
||||||
from MXMotion import MotionBase
|
from MXMotion import MotionBase
|
||||||
@@ -66,23 +68,8 @@ class ShapePath(MotionBase):
|
|||||||
def __init__(self,comm, gather, verbose):
|
def __init__(self,comm, gather, verbose):
|
||||||
MotionBase.__init__(self,comm, gather, verbose)
|
MotionBase.__init__(self,comm, gather, verbose)
|
||||||
|
|
||||||
def run_test(self,cfg,dryrun=False):
|
|
||||||
print('cfg='+str(cfg))
|
|
||||||
try:
|
|
||||||
self.points=np.array(cfg['points'])
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
sequencer= cfg['sequencer']
|
|
||||||
except KeyError:
|
|
||||||
print('no command sequence to execute')
|
|
||||||
else:
|
|
||||||
for cmd in sequencer:
|
|
||||||
print('>'*5+' '+cmd+' '+'<'*5)
|
|
||||||
if not dryrun:
|
|
||||||
eval('self.' + cmd)
|
|
||||||
|
|
||||||
def gen_swissfel_points(self,scale=10):
|
def gen_swissfel_points(self,scale=10):
|
||||||
|
'generathe a path that writes swissfel'
|
||||||
#string from inkscape path of the drawing
|
#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="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()
|
d=d.split()
|
||||||
@@ -102,12 +89,14 @@ class ShapePath(MotionBase):
|
|||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
def gen_rand_points(self,n=107,scale=1000):
|
def gen_rand_points(self,n=107,scale=1000):
|
||||||
|
'generate random distributed points'
|
||||||
np.random.seed(0)
|
np.random.seed(0)
|
||||||
#data=np.random.randint(0,1000,(30,2))
|
#data=np.random.randint(0,1000,(30,2))
|
||||||
pts=np.random.rand(n,2)*scale
|
pts=np.random.rand(n,2)*scale
|
||||||
self.points=pts
|
self.points=pts
|
||||||
|
|
||||||
def gen_grid_points(self,w=10,h=10,pitch=100,rnd=.2):
|
def gen_grid_points(self,w=10,h=10,pitch=100,rnd=.2):
|
||||||
|
'generates points in a grid with a given pitch and a bit randomness'
|
||||||
np.random.seed(0)
|
np.random.seed(0)
|
||||||
xx,yy=np.meshgrid(range(w), range(h))
|
xx,yy=np.meshgrid(range(w), range(h))
|
||||||
pts=np.array([xx.reshape(-1),yy.reshape(-1)],dtype=np.float).transpose()*pitch
|
pts=np.array([xx.reshape(-1),yy.reshape(-1)],dtype=np.float).transpose()*pitch
|
||||||
@@ -117,6 +106,10 @@ class ShapePath(MotionBase):
|
|||||||
self.points=pts
|
self.points=pts
|
||||||
|
|
||||||
def opt_pts(self,fn):
|
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)
|
fh=np.load(fn)
|
||||||
#res=rot.ActPos,x.ActPos,y.ActPos,rot.DesPos,x.DesPos,y.DesPos
|
#res=rot.ActPos,x.ActPos,y.ActPos,rot.DesPos,x.DesPos,y.DesPos
|
||||||
#idx 0 1 2 3 4 5
|
#idx 0 1 2 3 4 5
|
||||||
@@ -136,7 +129,68 @@ class ShapePath(MotionBase):
|
|||||||
self.ptsCorr=ptsCorr
|
self.ptsCorr=ptsCorr
|
||||||
print(ptsCorr)
|
print(ptsCorr)
|
||||||
|
|
||||||
def move_trajectory(self,prgId=2,fnPrg=None,mode=0,**kwargs):
|
def setup_gather(self,acq_per=1):
|
||||||
|
'''
|
||||||
|
setup the channels to gather
|
||||||
|
kwargs:
|
||||||
|
acq_per : acquire period: acquire data all acq_per servo loops (default=1)
|
||||||
|
'''
|
||||||
|
comm=self.comm
|
||||||
|
gt=self.gather
|
||||||
|
gt.set_phasemode(False)
|
||||||
|
gt.set_address("Motor[3].ActPos","Motor[2].ActPos","Motor[1].ActPos","Motor[3].DesPos","Motor[2].DesPos","Motor[1].DesPos")
|
||||||
|
gt.set_property(MaxSamples=1000000, Period=acq_per)
|
||||||
|
ServoPeriod= .2 #0.2ms #Sys.ServoPeriod is dependent of !common() macro
|
||||||
|
#ServoPeriod=comm.gpascii.servo_period
|
||||||
|
self.meta = {'timebase': ServoPeriod*acq_per}
|
||||||
|
|
||||||
|
def setup_sync(self,crdId=1,prgId=2,plcId=2,mode=0,**kwargs):
|
||||||
|
'''setup the timing synchronization for the motion program
|
||||||
|
mode=0 : no sync at all
|
||||||
|
mode=1 : first sync test
|
||||||
|
this function generates the code blocks:
|
||||||
|
self.sync_wait and self.sync_run
|
||||||
|
sync_wait can be put in the program to force a timing sync
|
||||||
|
sync_run are the commands to run the whole program
|
||||||
|
'''
|
||||||
|
gpascii=self.comm.gpascii
|
||||||
|
if mode==0:
|
||||||
|
try:
|
||||||
|
del self.sync_wait
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, crdId=crdId)
|
||||||
|
|
||||||
|
elif mode==1:
|
||||||
|
# changes the Timebase of coord system
|
||||||
|
# modifies the timebase to start/stop a running program
|
||||||
|
# this can also be used to adjust the execution speed
|
||||||
|
# the plc for now
|
||||||
|
# - waits untis <flag> is false
|
||||||
|
# - waits raising edge of <flag> and the sets DesTimeBase=ServoPeriod
|
||||||
|
|
||||||
|
#flag ='PowerBrick[0].GpioData[0].0.1==1'
|
||||||
|
flag ='Gate3[1].Chan[0].UserFlag==1'
|
||||||
|
prg='''close all buffers
|
||||||
|
open plc {plcId}
|
||||||
|
Coord[{crdId}].DesTimeBase=0 // freezes timebase at boot
|
||||||
|
while(flag){{}}
|
||||||
|
while(1)
|
||||||
|
{{
|
||||||
|
if({flag})
|
||||||
|
{{
|
||||||
|
PowerBrick[0].GpioData[0].16.8=255
|
||||||
|
Coord[{crdId}].DesTimeBase=Sys.ServoPeriod
|
||||||
|
break
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
close
|
||||||
|
'''.format(plcId=plcId,crdId=crdId,flag=flag)
|
||||||
|
gpascii.send_block(prg)
|
||||||
|
self.sync_wait='Coord[{crdId}].DesTimeBase=0;enable plc {plcId}'.format(plcId=plcId,crdId=crdId)
|
||||||
|
self.sync_run='Coord[{crdId}].DesTimeBase=0;&{crdId}b{prgId}r'''.format(prgId=prgId, plcId=plcId, crdId=crdId)
|
||||||
|
|
||||||
|
def setup_motion(self,prgId=2,fnPrg=None,mode=0,**kwargs):
|
||||||
'''
|
'''
|
||||||
1. generates program <prgId> and saves to fnPrg
|
1. 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>
|
||||||
@@ -145,24 +199,9 @@ class ShapePath(MotionBase):
|
|||||||
acq_per : acquire period: acquire data all acq_per servo loops (default=1)
|
acq_per : acquire period: acquire data all acq_per servo loops (default=1)
|
||||||
pt2pt_time : time to move from one point to the next point
|
pt2pt_time : time to move from one point to the next point
|
||||||
'''
|
'''
|
||||||
prg=[]
|
prg=['close all buffers','open prog %d'%(prgId)]
|
||||||
acq_per=kwargs.get('acq_per',1)
|
comm=self.comm
|
||||||
gather={"MaxSamples":1000000, "Period":acq_per}
|
gpascii=comm.gpascii
|
||||||
#Sys.ServoPeriod is dependent of !common() macro
|
|
||||||
ServoPeriod= .2 #0.2ms
|
|
||||||
#ServoPeriod = .05
|
|
||||||
self.meta = {'timebase': ServoPeriod*gather['Period']}
|
|
||||||
#channels=["Motor[1].ActPos","Motor[2].ActPos","Motor[3].ActPos"]
|
|
||||||
channels=["Motor[3].ActPos","Motor[2].ActPos","Motor[1].ActPos","Motor[3].DesPos","Motor[2].DesPos","Motor[1].DesPos"]
|
|
||||||
prg.append('Gather.Enable=0')
|
|
||||||
prg.append('Gather.Items=%d'%len(channels))
|
|
||||||
for k,v in gather.iteritems():
|
|
||||||
prg.append('Gather.%s=%d'%(k,v))
|
|
||||||
for i,c in enumerate(channels):
|
|
||||||
prg.append('Gather.Addr[%d]=%s.a'%(i,c))
|
|
||||||
|
|
||||||
|
|
||||||
prg.append('open prog %d'%(prgId))
|
|
||||||
# this uses Coord[1].Tm and limits with MaxSpeed
|
# this uses Coord[1].Tm and limits with MaxSpeed
|
||||||
if mode==-1: #### jog a 10mm square
|
if mode==-1: #### jog a 10mm square
|
||||||
pos=self.points
|
pos=self.points
|
||||||
@@ -200,7 +239,6 @@ class ShapePath(MotionBase):
|
|||||||
cnt=kwargs['cnt'] #move path multiple times
|
cnt=kwargs['cnt'] #move path multiple times
|
||||||
except KeyError:
|
except KeyError:
|
||||||
cnt=1
|
cnt=1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pt=self.ptsCorr
|
pt=self.ptsCorr
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@@ -221,6 +259,12 @@ class ShapePath(MotionBase):
|
|||||||
prg.append(' linear abs')
|
prg.append(' linear abs')
|
||||||
prg.append('X%g Y%g' % tuple(pv[0, (0,1)]))
|
prg.append('X%g Y%g' % tuple(pv[0, (0,1)]))
|
||||||
prg.append('dwell 10')
|
prg.append('dwell 10')
|
||||||
|
try:
|
||||||
|
prg.append(self.sync_wait)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
print('no sync code available')
|
||||||
prg.append('Gather.Enable=2')
|
prg.append('Gather.Enable=2')
|
||||||
if cnt>1:
|
if cnt>1:
|
||||||
prg.append('P100=%d'%cnt)
|
prg.append('P100=%d'%cnt)
|
||||||
@@ -264,7 +308,7 @@ class ShapePath(MotionBase):
|
|||||||
prg.append('Gather.Enable=0')
|
prg.append('Gather.Enable=0')
|
||||||
|
|
||||||
prg.append('close')
|
prg.append('close')
|
||||||
prg.append('&1\nb%dr\n'%prgId)
|
#prg.append('&1\nb%dr\n'%prgId)
|
||||||
if self.verbose & 4:
|
if self.verbose & 4:
|
||||||
for ln in prg:
|
for ln in prg:
|
||||||
print(ln)
|
print(ln)
|
||||||
@@ -273,24 +317,41 @@ class ShapePath(MotionBase):
|
|||||||
fh=open(fnPrg,'w')
|
fh=open(fnPrg,'w')
|
||||||
fh.write('\n'.join(prg))
|
fh.write('\n'.join(prg))
|
||||||
fh.close()
|
fh.close()
|
||||||
if self.host is not None:
|
gpascii.send_block(prg)
|
||||||
cmd ='gpasciiCommander --host '+self.host+' '+ fnPrg
|
|
||||||
print(cmd)
|
#if self.host is not None:
|
||||||
p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
# cmd ='gpasciiCommander --host '+self.host+' '+ fnPrg
|
||||||
#res=p.stdout.readlines(); print res
|
# print(cmd)
|
||||||
retval = p.wait()
|
# p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
||||||
|
# #res=p.stdout.readlines(); print res
|
||||||
|
# retval = p.wait()
|
||||||
self.prg=prg
|
self.prg=prg
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
'runs the code sync_run which has been generated with setup_sync()'
|
||||||
|
comm = self.comm
|
||||||
|
gpascii = comm.gpascii
|
||||||
|
try:
|
||||||
|
cmd=self.sync_run
|
||||||
|
except AttributeError:
|
||||||
|
raise 'Need to call setup sync before'
|
||||||
|
gpascii.send_block(cmd)
|
||||||
|
|
||||||
def gather_upload(self,fnRec=None):
|
def gather_upload(self,fnRec=None):
|
||||||
#gather -u /var/ftp/gather/out.txt
|
#gather -u /var/ftp/gather/out.txt
|
||||||
cmd ='PBGatherPlot -m24 -v7 --host '+self.host
|
#cmd ='PBGatherPlot -m24 -v7 --host '+self.host
|
||||||
print(cmd)
|
#print(cmd)
|
||||||
p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
#p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
||||||
retval = p.wait()
|
#retval = p.wait()
|
||||||
fnLoc='/tmp/gather.txt'
|
#fnLoc='/tmp/gather.txt'
|
||||||
self.rec =rec = np.genfromtxt(fnLoc, delimiter=' ')
|
#self.rec =rec = np.genfromtxt(fnLoc, delimiter=' ')
|
||||||
|
gt=self.gather
|
||||||
|
gt.wait_stopped(verbose=True)
|
||||||
|
self.rec=rec=gt.upload()
|
||||||
|
|
||||||
pts=self.points
|
pts=self.points
|
||||||
|
|
||||||
|
|
||||||
#rec=Motor[1].ActPos,Motor[2].ActPos,Motor[3].ActPos,Motor[1].DesPos,Motor[2].DesPos,Motor[3].DesPos
|
#rec=Motor[1].ActPos,Motor[2].ActPos,Motor[3].ActPos,Motor[1].DesPos,Motor[2].DesPos,Motor[3].DesPos
|
||||||
#res=rot.ActPos,x.ActPos,y.ActPos,rot.DesPos,x.DesPos,y.DesPos
|
#res=rot.ActPos,x.ActPos,y.ActPos,rot.DesPos,x.DesPos,y.DesPos
|
||||||
#idx 0 1 2 3 4 5
|
#idx 0 1 2 3 4 5
|
||||||
@@ -408,13 +469,43 @@ if __name__=='__main__':
|
|||||||
sp.host=args.host #temporary
|
sp.host=args.host #temporary
|
||||||
|
|
||||||
fn='/tmp/shapepath'
|
fn='/tmp/shapepath'
|
||||||
|
xy=False
|
||||||
# fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/'+time.strftime('%y-%m-%d-%H_%M_%S')
|
# fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/'+time.strftime('%y-%m-%d-%H_%M_%S')
|
||||||
sort_points='sort_points(xy='+str(args.xy)+')'
|
|
||||||
gt_upld='gather_upload(fnRec="'+fn+'.npz")'
|
#>>>point source and sorting<<<
|
||||||
move_trj='move_trajectory(fnPrg="'+fn+'.prg"'
|
#sp.points = np.array([[100,523],[635,632],[756,213]])
|
||||||
|
#sp.points = np.array([[0, 0],[100, 0],[200, 0],[300, 0],[400, 0],[400, 100],[300, 100],[200, 100],[100, 100],[0, 100],[10, 200],[100, 200],[200, 200],[300, 200],[400, 200],[410, 300],[300, 300],[200, 300],[100, 300],[0, 300],[0, 400],[100, 400],[200, 400],[300, 400],[400, 400]])
|
||||||
|
#sp.gen_rand_points(n=107, scale=1000);sp.sort_points(xy=args.xy)
|
||||||
|
#sp.gen_grid_points(w=100,h=100,pitch=10,rnd=.2)
|
||||||
|
#sp.gen_swissfel_points(scale=300)
|
||||||
|
#sp.gen_grid_points(w=10,h=10,pitch=50,rnd=.2)
|
||||||
|
#sp.gen_grid_points(w=100,h=100,pitch=50,rnd=.2)
|
||||||
|
|
||||||
|
|
||||||
|
#setup_gather(self, acq_per=1)
|
||||||
|
sp.setup_gather()
|
||||||
|
#setup_sync(self, crdId=1, prgId=2, plcId=2, mode=0, **kwargs):
|
||||||
|
sp.setup_sync() #no sync at all
|
||||||
|
#sp.setup_sync(mode=1) #sync with timing system
|
||||||
|
|
||||||
|
sp.gen_grid_points(w=20,h=20,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1)
|
||||||
|
|
||||||
|
|
||||||
|
#>>>setup gather and sync<<<
|
||||||
|
#sp.setup_gather()
|
||||||
|
#sp.setup_sync()
|
||||||
|
|
||||||
|
#>>>setup motion program<<<
|
||||||
|
#sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1)
|
||||||
|
|
||||||
|
#>>>run gather and plot trajectory<<<
|
||||||
|
sp.run()
|
||||||
|
sp.gather_upload(fnRec=fn+'.npz')
|
||||||
|
sp.plot_gather()
|
||||||
|
|
||||||
|
|
||||||
# cfg={"points": [[100,523],[635,632],[756,213]],"sequencer":[sort_points,move_trj+')']}
|
# cfg={"points": [[100,523],[635,632],[756,213]],"sequencer":[sort_points,move_trj+')']}
|
||||||
cfg={"sequencer":['gen_rand_points(n=107, scale=1000)',sort_points,move_trj+')']}
|
#cfg={"sequencer":['gen_rand_points(n=107, scale=1000)',sort_points,move_trj+')']}
|
||||||
# cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=.2)',sort_points,move_trj+')']}
|
# cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=.2)',sort_points,move_trj+')']}
|
||||||
# cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=0.2)',sort_points,move_trj+')']}
|
# cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=0.2)',sort_points,move_trj+')']}
|
||||||
# cfg = {"sequencer": ['gen_rand_points(n=107, scale=1000)', sort_points]}
|
# cfg = {"sequencer": ['gen_rand_points(n=107, scale=1000)', sort_points]}
|
||||||
@@ -435,20 +526,18 @@ if __name__=='__main__':
|
|||||||
# ]}
|
# ]}
|
||||||
|
|
||||||
# 900npoints is a too big code block... and creates unfixable buffe locks
|
# 900npoints is a too big code block... and creates unfixable buffe locks
|
||||||
cfg={"sequencer": ['gen_rand_points(n=5000, scale=100)', sort_points,
|
#cfg={"sequencer": ['gen_rand_points(n=5000, scale=100)', sort_points,
|
||||||
move_trj+',mode=1,pt2pt_time=4,acq_per=10)',
|
# move_trj+',mode=1,pt2pt_time=4,acq_per=10)',
|
||||||
]}
|
# ]}
|
||||||
# cfg = {"sequencer": ['gen_swissfel_points(scale=300)',move_trj+',mode=1,pt2pt_time=100,acq_per=10)',]}
|
# cfg = {"sequencer": ['gen_swissfel_points(scale=300)',move_trj+',mode=1,pt2pt_time=100,acq_per=10)',]}
|
||||||
# cfg = {"sequencer": ['opt_pts("'+fn+'.npz")','move_trajectory(file="'+fn+'_corr.prg",mode=1,pt2pt_time=10,cnt=1)', ("'+fn+'_corr.npz")']}
|
# cfg = {"sequencer": ['opt_pts("'+fn+'.npz")','move_trajectory(file="'+fn+'_corr.prg",mode=1,pt2pt_time=10,cnt=1)', ("'+fn+'_corr.npz")']}
|
||||||
# cfg = {"sequencer": ['opt_pts("'+fn+'.npz")',move_trj+',mode=1,pt2pt_time=10,cnt=1)']}
|
# cfg = {"sequencer": ['opt_pts("'+fn+'.npz")',move_trj+',mode=1,pt2pt_time=10,cnt=1)']}
|
||||||
|
|
||||||
# cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.4)', sort_points,move_trj+',mode=1,pt2pt_time=10,cnt=1)']}
|
# cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.4)', sort_points,move_trj+',mode=1,pt2pt_time=10,cnt=1)']}
|
||||||
|
|
||||||
cfg['sequencer'].append(gt_upld)
|
#cfg['sequencer'].append(gt_upld)
|
||||||
cfg['sequencer'].append('plot_gather()')
|
#cfg['sequencer'].append('plot_gather()')
|
||||||
sp.run_test(cfg,args.dryrun)
|
|
||||||
#self.cfg=dotdict(cfg)
|
|
||||||
#self.args=args
|
|
||||||
|
|
||||||
|
|
||||||
from optparse import OptionParser, IndentedHelpFormatter
|
from optparse import OptionParser, IndentedHelpFormatter
|
||||||
@@ -478,8 +567,6 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
|
|||||||
parser=OptionParser(epilog=epilog, formatter=fmt)
|
parser=OptionParser(epilog=epilog, formatter=fmt)
|
||||||
|
|
||||||
parser.add_option('-v', '--verbose', type="int", dest='verbose', help='verbosity bits (see below)', default=0)
|
parser.add_option('-v', '--verbose', type="int", dest='verbose', help='verbosity bits (see below)', default=0)
|
||||||
parser.add_option('-n', '--dryrun', action='store_true', help='dryrun to stdout')
|
|
||||||
parser.add_option('--xy', action='store_true', help='sort x,y instead y,x',default=False)
|
|
||||||
parser.add_option('--host', help='hostname', default='SAR-CPPM-EXPMX1')
|
parser.add_option('--host', help='hostname', default='SAR-CPPM-EXPMX1')
|
||||||
#parser.add_option('--host', help='hostname')
|
#parser.add_option('--host', help='hostname')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user