This commit is contained in:
2018-11-21 08:08:23 +01:00
parent 882ac3a66e
commit 554fd8e1ca
11 changed files with 90 additions and 1325 deletions

View File

@@ -1137,9 +1137,36 @@ source /opt/gfa/python
source activate /sf/bernina/config/swissmx/conda/envs/b440_clone
zamofing_t@ganymede:~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python$
cp -rL ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py ~/Documents/prj/SwissFEL/PBTools/pbtools/ /sf/bernina/config/swissmx/zamofing_t/
scp -r ganymede:~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py ganymede:~/Documents/prj/SwissFEL/PBTools/pbtools/ /sf/bernina/config/swissmx/zamofing_t/
cp -arL ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py \
~/Documents/prj/SwissFEL/PBTools/pbtools/
/sf/bernina/config/swissmx/zamofing_t/
cp -arL ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/PBMotionAnalyzer/*.py \
/sf/bernina/config/swissmx/zamofing_t/PBMotionAnalyzer/
>alternatives but not recommanded
#scp -r ganymede:~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py ganymede:~/Documents/prj/SwissFEL/PBTools/pbtools/ /sf/bernina/config/swissmx/zamofing_t/
#rsync -abuv --exclude 'records/' ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/*.py ~/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/PBMotionAnalyzer/ ~/Documents/prj/SwissFEL/PBTools/pbtools/ /sf/bernina/config/swissmx/zamofing_t/
```
Sync Start
----------
```
caput SAR-CVME-TIFALL5-EVG0:SoftEvt-EvtCode-SP 254
```
TODO
----
```
adapt speed
- change pvt value (simple but fix)
make longer acquisition time by enhancing the gather server
```

View File

@@ -80,11 +80,11 @@ open subprog SP_LockBrk
}
//send 1"done\n"
Motor[1].IdCmd=0;Motor[1].InPosBand=10
Motor[2].IdCmd=0;Motor[2].InPosBand=10
Motor[3].IdCmd=0;Motor[3].InPosBand=10
Motor[4].IdCmd=0;Motor[4].InPosBand=10
Motor[5].IdCmd=0;Motor[5].InPosBand=10
Motor[1].IdCmd=0;Motor[1].InPosBand=50
Motor[2].IdCmd=0;Motor[2].InPosBand=50
Motor[3].IdCmd=0;Motor[3].InPosBand=50
Motor[4].IdCmd=0;Motor[4].InPosBand=50
Motor[5].IdCmd=0;Motor[5].InPosBand=50
PowerBrick[0].GpioData[0].16.5=$0
close

View File

@@ -103,15 +103,9 @@ close
while({flag0}){{}}
//send 1"sync1 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L0
//L1=Sys.PhaseCount
while(1)
{{
if({flag1})
{{
//PowerBrick[0].GpioData[0].16.8=255
//send 1"sync2 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L1
break
}}
}}
while({flag1}){{}}
//PowerBrick[0].GpioData[0].16.8=255
//send 1"sync2 %d:%d\\n",Sys.PhaseCount,Sys.PhaseCount-L1
'''.format(plcId=plcId, crdId=crdId, flag0=flag0, flag1=flag1)
self.sync_prg = prg
self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, plcId=plcId, crdId=crdId)

View File

@@ -8,7 +8,7 @@
'''
implements an image view to show a colored image of a hdf5 dataset.
'''
from __future__ import print_function
if __name__ == '__main__':
#Used to guarantee to use at least Wx2.8
import wxversion
@@ -45,15 +45,17 @@ class MPLCanvasErr(FigureCanvas):
self.fig=fig
self.ax=ax
def InitChild(self,meta,err):
def InitChild(self,meta,err,trig):
fig=self.fig
ax=self.ax
errx,erry,err=err
hl = []
hl += ax.plot(trig, 'k-',label='trigger')
hl += ax.plot(errx, 'b-',label='x-error')
hl += ax.plot(erry, 'g-',label='y-error')
hl += ax.plot(err, 'r-',label='error')
ax.xaxis.set_label_text('datapoint (timebase: %g ms per data point)'%meta['timebase'])
ax.yaxis.set_label_text('pos-error um')
legend = ax.legend(loc='upper right', shadow=True)
@@ -89,12 +91,12 @@ class MPLCanvasErr(FigureCanvas):
def OnBtnPress(self, event):
"""on button press we will see if the mouse is over us and store some data"""
print dir(event.guiEvent)
print(dir(event.guiEvent))
return
def OnBtnRelease(self, event):
"""on release we reset the press data"""
print dir(event.guiEvent)
print(dir(event.guiEvent))
#self.OnMouse(event)
return
@@ -129,15 +131,15 @@ class MAErrorFrame(wx.Frame):
toolbar=ut.AddToolbar(canvas,sizer)
meta = doc.fh['meta'].item()
rec = doc.fh['rec']
try:
err=doc.err
except AttributeError:
rec=doc.fh['rec']
errx = (rec[:, 1] - rec[:, 3])
erry = (rec[:, 0] - rec[:, 2])
errxy = np.sqrt(errx ** 2 + erry ** 2)
doc.err = err = (errx, erry, errxy)
canvas.InitChild(meta,err)
canvas.InitChild(meta,err,rec[:,4])
self.Centre()

View File

@@ -8,7 +8,7 @@
'''
implements an image view to show a colored image of a hdf5 dataset.
'''
from __future__ import print_function
if __name__ == '__main__':
#Used to guarantee to use at least Wx2.8
import wxversion
@@ -100,12 +100,12 @@ class MPLCanvasVelo(FigureCanvas):
def OnBtnPress(self, event):
"""on button press we will see if the mouse is over us and store some data"""
print dir(event.guiEvent)
print(dir(event.guiEvent))
return
def OnBtnRelease(self, event):
"""on release we reset the press data"""
print dir(event.guiEvent)
print(dir(event.guiEvent))
#self.OnMouse(event)
return

View File

@@ -8,7 +8,7 @@
'''
implements an image view to show a colored image of a hdf5 dataset.
'''
from __future__ import print_function
if __name__ == '__main__':
#Used to guarantee to use at least Wx2.8
import wxversion
@@ -149,7 +149,7 @@ class MPLCanvasImg(FigureCanvas):
def OnBtnPress(self, event):
"""on button press we will see if the mouse is over us and store some data"""
print dir(event.guiEvent)
print(dir(event.guiEvent))
return
if event.inaxes == self.colBar.ax:
#if event.guiEvent.LeftDClick()==True:
@@ -209,7 +209,7 @@ class MPLCanvasImg(FigureCanvas):
return
for k in dir(event):
if k[0]!='_':
print k,getattr(event,k)
print(k,getattr(event,k))
class MAxyPlotFrame(wx.Frame):
def __del__(self):

View File

@@ -5,7 +5,7 @@
# | |
# | Author Thierry Zamofing (thierry.zamofing@psi.ch) |
# *-----------------------------------------------------------------------*
from __future__ import print_function
import os,sys
import wx
import wx.py
@@ -68,7 +68,7 @@ class AboutFrame(wx.Frame):
st0=wx.StaticText(panel,-1,s,(30,10))
bmp = wx.StaticBitmap(panel,-1,wx.Bitmap(os.path.join(imgDir,'PBMA.png'), wx.BITMAP_TYPE_ANY ), (30,st0.Position[1]+st0.Size[1]+10))
for k,v in os.environ.iteritems():
print k,'=',v
print(k,'=',v)
class MAMainFrame(wx.Frame):
@@ -88,7 +88,10 @@ class MAMainFrame(wx.Frame):
lenRec=fh['rec'].shape[0]
lenPts=fh['pts'].shape[0]
self.wxTimeCtrl.slider.SetRange(0,lenRec-1)
self.wxTimeCtrl.slider.SetPageSize(lenRec/lenPts)
ts=fh['meta'].item()['timebase']
page=int((lenRec-1000/ts)/(lenPts+2))
self.wxTimeCtrl.slider.SetPageSize(page)
self.xPosCtrl.slider.SetRange(0,lenPts-1)
@@ -105,7 +108,7 @@ class MAMainFrame(wx.Frame):
pass
def __init__(self, parent, title,doc):
wx.Frame.__init__(self, parent, title=title, size=wx.Size(650, 350))
wx.Frame.__init__(self, parent, title=title, size=wx.Size(650, 200),style = wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)
self.doc=doc;doc.view.append(self)
imgDir=ut.Path.GetImage()
icon = wx.Icon(os.path.join(imgDir,'PBMA.ico'), wx.BITMAP_TYPE_ICO)
@@ -261,7 +264,7 @@ rec
@staticmethod
def OnSetTime(usrData, value, msg):
'called when the time slider has been changed'
print 'OnSetTime', usrData, value, msg
print('OnSetTime', usrData, value, msg)
view=usrData.slider.Parent
doc=view.doc
doc.Update(view,0,value)
@@ -287,7 +290,7 @@ rec
@staticmethod
def OnSetPosition(usrData, value, msg):
'called when the time slider has been changed'
print 'OnSetPosition', usrData, value, msg
print('OnSetPosition', usrData, value, msg)
view = usrData.slider.Parent
doc = view.doc
doc.Update(view, 1, value)

View File

@@ -1,3 +1,4 @@
from __future__ import print_function
if __name__ == '__main__':
#Used to guarantee to use at least Wx2.8
import wxversion
@@ -29,7 +30,7 @@ class StopWatch():
@classmethod
def Log(cls,str=None,restart=True):
ts=time.time()
print '%.6f'%(ts-cls.ts),str
print('%.6f'%(ts-cls.ts),str)
if restart:
cls.ts=ts

File diff suppressed because it is too large Load Diff

View File

@@ -224,6 +224,7 @@ class ShapePath(MotionBase):
except KeyError:
print('missing pt2pt_time, use default=100ms')
pt2pt_time=100.
self.meta['pt2pt_time']=pt2pt_time
try:
cnt=kwargs['cnt'] #move path multiple times
except KeyError:
@@ -523,6 +524,13 @@ if __name__=='__main__':
# '%(levelname)-8s %(message)s'),
# datefmt='%m-%d %H:%M',
# )
def trigger(wait=.5):
import CaChannel
time.sleep(wait)
pvTrigger = CaChannel.CaChannel('SAR-CVME-TIFALL5-EVG0:SoftEvt-EvtCode-SP.VAL')
pvTrigger.searchw()
pvTrigger.putw(254)
def run_test(args):
#args.host=None
@@ -532,6 +540,19 @@ if __name__=='__main__':
comm = PPComm(host=args.host)
gather = Gather(comm)
sp = ShapePath(comm, gather, args.verbose)
# Gather.MaxLines=116508
# ts=0.2ms
# max_num_points=(MaxLines*ts-1000ms)/(+acq_per*pt2pt_time*ts)
# pt2pt_time acq_per maxpts
# 40ms 1 555
# 40ms 2 1135
# 40ms 3 1715
# 40ms 4 2295
# 10ms 1 2220
# 10ms 2 4540
# 10ms 3 6860
# 10ms 4 9180
#sp.gen_swissmx_points(width=1000,ofs=(-500,0))
#sp.gen_swissfel_points(width=1000,ofs=(-500,0))
#fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/PBMotionAnalyzer/records/mode1'
@@ -563,15 +584,17 @@ if __name__=='__main__':
#sp.gen_grid_points(w=100,h=100,pitch=50,rnd=.2)
#setup_gather(self, acq_per=1)
#setup_gather(self, acq_per=1) #Gather.MaxLines=116508 580pts
sp.setup_gather(acq_per=2)
#setup_sync(self, crdId=1, prgId=2, plcId=2, mode=0, **kwargs):
sp.setup_sync() #no sync at all
#sp.setup_sync() #no sync at all
#sp.setup_sync(mode=1) #sync with timing system (PLC)
#sp.setup_sync(mode=2) #sync with timing system (PROG)
sp.setup_sync(mode=2) #sync with timing system (PROG)
#sp.gen_grid_points(w=2,h=2,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1)
sp.gen_swissmx_points(width=1000,ofs=(-500,0));sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40,acq_per=1)
#sp.gen_swissmx_points(width=1000,ofs=(-500,0));sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40,acq_per=1)
sp.gen_grid_points(w=30,h=30,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40)
#sp.gen_grid_points(w=200,h=200,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40)
#sp.gen_grid_points(w=2,h=20,pitch=50,rnd=0);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1)
#sp.gen_rand_points(n=500, scale=1000);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1)
@@ -586,6 +609,7 @@ if __name__=='__main__':
#>>>run gather and plot trajectory<<<
sp.run()
trigger(0.5)
sp.gather_upload(fnRec=fn+'.npz')
sp.plot_gather()