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
|
||||
Reference in New Issue
Block a user