matlab rename, adapt for new software

This commit is contained in:
2019-02-19 16:34:49 +01:00
parent 4c676269fc
commit 46aab5ae36
10 changed files with 52 additions and 20 deletions

View File

@@ -70,25 +70,27 @@ class MotionBase:
if sync_mode!=0:
print({0: 'real start trigger', 1: 'simulated start trigger'}[sync_flag&1])
print({0: 'real frame trigger', 2: 'simulated frame trigger'}[sync_flag&2])
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, crdId=crdId)
if sync_mode==0:
try:
del self.sync_prg
except AttributeError:
pass
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, crdId=crdId)
elif sync_mode in(1,2):
#frequence jitter 50Hz Swissgrid:
#https://www.swissgrid.ch/de/home/operation/grid-data/current-data.html#
flag0='Coord[1].Q[10]' if sync_flag&1 else 'Gate3[1].Chan[0].UserFlag'
flag1='Coord[1].Q[11]' if sync_flag&2 else 'Gate3[1].Chan[1].UserFlag'
flag0='Coord[{crdId}].Q[10]'.format(crdId=crdId) if sync_flag&1 else 'Gate3[1].Chan[0].UserFlag'
flag1='Coord[{crdId}].Q[11]'.format(crdId=crdId) if sync_flag&2 else 'Gate3[1].Chan[1].UserFlag'
if sync_mode==1:
prg = '''
Coord[1].Q[1]=-2
Coord[1].TimeBaseSlew=1 //1E-4 is default
Coord[1].DesTimeBase=0
Coord[{crdId}].Q[0]=-2
Coord[{crdId}].TimeBaseSlew=1 //1E-4 is default
Coord[{crdId}].DesTimeBase=0
while({flag0}==0){{}}
Coord[1].Q[1]=-1
Coord[{crdId}].Q[0]=-1
Gather.Enable=2
while({flag1}==0){{}}
Coord[1].DesTimeBase=Sys.ServoPeriod
@@ -98,11 +100,10 @@ class MotionBase:
//Gather.Enable=2 is done in the sync program
Coord[1].TimeBaseSlew=1 //1E-4 is default
Coord[1].DesTimeBase=0
Coord[1].Q[1]=-1
//Coord[1].Q[0]=-1 is done in the sync program
'''.format(crdId=crdId, flag0=flag0, flag1=flag1)
self.sync_prg = prg
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, crdId=crdId)
#download and start triggerSync code
comm=self.comm
@@ -113,7 +114,7 @@ class MotionBase:
if sync_mode==2 or arg&4:
sftp = comm.sftp
dst = '/tmp/triggerSync'
src = os.path.abspath(os.path.join(os.path.dirname(__file__), '../src/triggerSync/triggerSync'))
src = os.path.abspath(os.path.join(os.path.dirname(__file__), 'triggerSync'))
sftp.put(src, dst)
sftp.chmod(dst, 0o755)
cmd = 'LD_LIBRARY_PATH=/opt/ppmac/libppmac/ ' + dst
@@ -140,7 +141,7 @@ class MotionBase:
def run(self):
def run(self, crdId=1):
'runs the code sync_run which has been generated with setup_sync()'
comm = self.comm
gpascii = comm.gpascii
@@ -150,6 +151,32 @@ class MotionBase:
raise 'Need to call setup sync before'
gpascii.send_block(cmd)
def wait_armed(self,crdId=1): #wait until motors are at first position
sm=self.meta['sync_mode']
if sm==0:
return
else:
comm = self.comm
gpascii = comm.gpascii
while (True):
val = gpascii.get_variable('Coord[{crdId}].Q[0]'.format(crdId=crdId), type_=int)
if val==-2:
break
time.sleep(.1)
def progress(self): #returns the progress of the motion
sm=self.meta['sync_mode']
comm = self.comm
gpascii = comm.gpascii
ge = gpascii.get_variable('Gather.Enable', type_=int)
if ge == 0: return -1
cnt = gpascii.get_variable('Gather.Samples', type_=int)
try:
cnt*=self.meta['srv_per']/(self.meta['acq_per']*self.meta['pt2pt_time'])
except KeyError:
pass
return cnt
def trigger(self,wait=.5):
if self.meta['sync_mode']==0:
return # no trigger at all