towards new communication
This commit is contained in:
@@ -1,3 +1,27 @@
|
||||
#some further usefull PMAC commands:
|
||||
# list pc , 10 //list program counter during motion exec
|
||||
# buffer //list allocated buffers
|
||||
#the rotary stuff only works from gpascii, not gpasciiCommander
|
||||
#delete rotary
|
||||
#define rotary 4096 //allocates mem
|
||||
#open rotary //same as open prog 0
|
||||
#
|
||||
# X100 Y100
|
||||
# X200 Y300
|
||||
# X600 Y500
|
||||
# adding lines alway are acknowledged with ACK,
|
||||
# if not, it means that the buffer is full
|
||||
# it will acknowlegde when there is again free space.
|
||||
# close
|
||||
# delete rotary
|
||||
|
||||
|
||||
#from other gpascii
|
||||
#list rotary
|
||||
#rotfree
|
||||
#size
|
||||
#b0s //start the rotary buffer in single step mode
|
||||
|
||||
import os, sys
|
||||
sys.path.insert(0,os.path.expanduser('~/Documents/prj/SwissFEL/PBTools/'))
|
||||
#import pbtools.misc.pp_comm as pp_comm -> pp_comm.PPComm
|
||||
@@ -11,28 +35,59 @@ class MotionBase:
|
||||
self.gather=gather
|
||||
self.verbose=verbose
|
||||
|
||||
def wait_trigger(self):
|
||||
'''
|
||||
//changes the Timebase of coord system 1
|
||||
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)
|
||||
|
||||
//modifies the timebase to start/stop a running program
|
||||
//this can also be used to adjust the execution speed
|
||||
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 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)
|
||||
|
||||
open plc 1
|
||||
Coord[1].DesTimeBase=0 // freezes timebase at boot
|
||||
while(1)
|
||||
{
|
||||
if(PowerBrick[0].GpioData[0].0.1==1)
|
||||
{
|
||||
PowerBrick[0].GpioData[0].16.8=255
|
||||
Coord[1].DesTimeBase=Sys.ServoPeriod
|
||||
}
|
||||
else
|
||||
{
|
||||
PowerBrick[0].GpioData[0].16.8=7
|
||||
Coord[1].DesTimeBase=0
|
||||
}
|
||||
}
|
||||
close
|
||||
'''
|
||||
pass
|
||||
@@ -144,51 +144,21 @@ class ShapePath(MotionBase):
|
||||
#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_coord_trf(self):
|
||||
comm = self.comm
|
||||
gpascii = comm.gpascii
|
||||
prg = '''&1a
|
||||
#1-> Y
|
||||
#2-> X
|
||||
#3-> A
|
||||
#4->0
|
||||
#5->0
|
||||
#6->0
|
||||
#7->0
|
||||
#8->0
|
||||
#1..8j/
|
||||
'''
|
||||
gpascii.send_block(prg)
|
||||
|
||||
def setup_motion(self,prgId=2,fnPrg=None,mode=0,**kwargs):
|
||||
'''
|
||||
@@ -327,31 +297,13 @@ close
|
||||
# retval = p.wait()
|
||||
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):
|
||||
#gather -u /var/ftp/gather/out.txt
|
||||
#cmd ='PBGatherPlot -m24 -v7 --host '+self.host
|
||||
#print(cmd)
|
||||
#p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
||||
#retval = p.wait()
|
||||
#fnLoc='/tmp/gather.txt'
|
||||
#self.rec =rec = np.genfromtxt(fnLoc, delimiter=' ')
|
||||
gt=self.gather
|
||||
gt.wait_stopped(verbose=True)
|
||||
self.rec=rec=gt.upload()
|
||||
|
||||
pts=self.points
|
||||
|
||||
|
||||
#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
|
||||
@@ -466,7 +418,7 @@ if __name__=='__main__':
|
||||
comm = PPComm(host=args.host)
|
||||
gather = Gather(comm)
|
||||
sp = ShapePath(comm, gather, args.verbose)
|
||||
sp.host=args.host #temporary
|
||||
sp.setup_coord_trf()
|
||||
|
||||
fn='/tmp/shapepath'
|
||||
xy=False
|
||||
|
||||
Reference in New Issue
Block a user