using old communication that worked
This commit is contained in:
@@ -54,6 +54,7 @@ import os, sys, time
|
||||
import numpy as np
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
import subprocess as sprc
|
||||
|
||||
sys.path.insert(0,os.path.expanduser('~/Documents/prj/SwissFEL/PBTools/'))
|
||||
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)
|
||||
pt2pt_time : time to move from one point to the next point
|
||||
'''
|
||||
gt=self.gather
|
||||
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)
|
||||
|
||||
host='SAR-CPPM-EXPMX1'
|
||||
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))
|
||||
# this uses Coord[1].Tm and limits with MaxSpeed
|
||||
@@ -268,29 +274,23 @@ class ShapePath(MotionBase):
|
||||
fh=open(fnPrg,'w')
|
||||
fh.write('\n'.join(prg))
|
||||
fh.close()
|
||||
if comm is not None:
|
||||
gpascii=comm.gpascii
|
||||
for ln in prg:
|
||||
gpascii.send_line(ln.strip())
|
||||
gpascii.sync()
|
||||
if host is not None:
|
||||
cmd ='gpasciiCommander --host '+host+' '+ fnPrg
|
||||
print(cmd)
|
||||
p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
||||
#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):
|
||||
gt=self.gather
|
||||
comm=self.comm
|
||||
if comm is None:
|
||||
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
|
||||
|
||||
pts=self.points # X,Y array
|
||||
fnLoc='/tmp/gather.txt'
|
||||
self.rec =rec = np.genfromtxt(fnLoc, delimiter=' ')
|
||||
#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
|
||||
#idx 0 1 2 3 4 5
|
||||
@@ -404,7 +404,7 @@ if __name__=='__main__':
|
||||
else:
|
||||
comm = PPComm(host=args.host)
|
||||
gather = Gather(comm)
|
||||
sp=ShapePath(comm, gather, args.verbose)
|
||||
sp = ShapePath(comm, gather, args.verbose)
|
||||
|
||||
fn='/tmp/shapepath'
|
||||
# fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/'+time.strftime('%y-%m-%d-%H_%M_%S')
|
||||
@@ -434,8 +434,8 @@ if __name__=='__main__':
|
||||
# ]}
|
||||
|
||||
# 900npoints is a too big code block... and creates unfixable buffe locks
|
||||
cfg={"sequencer": ['gen_rand_points(n=100, scale=1000)', sort_points,
|
||||
move_trj+',mode=1,pt2pt_time=40,acq_per=10)',
|
||||
cfg={"sequencer": ['gen_rand_points(n=5000, scale=100)', sort_points,
|
||||
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": ['opt_pts("'+fn+'.npz")','move_trajectory(file="'+fn+'_corr.prg",mode=1,pt2pt_time=10,cnt=1)', ("'+fn+'_corr.npz")']}
|
||||
|
||||
Reference in New Issue
Block a user