using old communication that worked

This commit is contained in:
2018-10-12 17:04:56 +02:00
parent baef7cdb9e
commit 6f17d94008

View File

@@ -54,6 +54,7 @@ import os, sys, time
import numpy as np import numpy as np
import matplotlib as mpl import matplotlib as mpl
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
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/'))
from pbtools.misc.pp_comm import PPComm from pbtools.misc.pp_comm import PPComm
@@ -144,18 +145,23 @@ 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
''' '''
gt=self.gather host='SAR-CPPM-EXPMX1'
comm=self.comm
acq_per=kwargs.get('acq_per', 1)
ServoPeriod= .2 #0.2ms
if gt:
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)
#gt.set_property(Period=acq_per)
prg=[] prg=[]
self.meta = {'timebase': ServoPeriod*acq_per} acq_per=kwargs.get('acq_per',1)
gather={"MaxSamples":1000000, "Period":acq_per}
#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)) prg.append('open prog %d'%(prgId))
# this uses Coord[1].Tm and limits with MaxSpeed # this uses Coord[1].Tm and limits with MaxSpeed
@@ -268,29 +274,23 @@ 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 comm is not None: if host is not None:
gpascii=comm.gpascii cmd ='gpasciiCommander --host '+host+' '+ fnPrg
for ln in prg: print(cmd)
gpascii.send_line(ln.strip()) p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
gpascii.sync() #res=p.stdout.readlines(); print res
retval = p.wait()
#gather -u /var/ftp/gather/out.txt
cmd ='PBGatherPlot -m24 -v7 --host '+host
print(cmd)
p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
retval = p.wait()
self.prg=prg
def gather_upload(self,fnRec=None): def gather_upload(self,fnRec=None):
gt=self.gather pts=self.points # X,Y array
comm=self.comm fnLoc='/tmp/gather.txt'
if comm is None: self.rec =rec = np.genfromtxt(fnLoc, delimiter=' ')
return
gpascii=comm.gpascii
#while True: #wait unti acquisition started
# samples=gpascii.get_variable('Gather.Samples', type_=int)
# enable=gpascii.get_variable('Gather.Enable', type_=int)
# if enable>0 and samples>0:
# break;
# time.sleep(.1)
# sys.stdout.flush()
gt.wait_stopped(verbose=True)
self.rec =rec = self.gather.upload()
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
@@ -434,8 +434,8 @@ 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=100, scale=1000)', sort_points, cfg={"sequencer": ['gen_rand_points(n=5000, scale=100)', sort_points,
move_trj+',mode=1,pt2pt_time=40,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")']}