From e63c8146622bf882b03ea34e211ca76bbf4532a7 Mon Sep 17 00:00:00 2001 From: Thierry Zamofing Date: Thu, 23 May 2024 16:33:43 +0200 Subject: [PATCH] SFELPHOTON-1128: debug stup-and-go motion --- app_config.py | 6 +++--- psi_device.py | 8 ++++++++ swissmx.py | 31 ++++++++++++++++--------------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/app_config.py b/app_config.py index 81da6aa..4b9b22f 100644 --- a/app_config.py +++ b/app_config.py @@ -122,7 +122,7 @@ class AppCfg(QSettings): if AppCfg.DT_HOST not in keys: dflt.append((AppCfg.DT_HOST, 'SAR-CPPM-EXPMX1')) if AppCfg.DT_MISC not in keys: - dflt.append((AppCfg.DT_MISC,{'show_plots':True, 'vel_scl':1.0, 'pt2pt_time':10.0, 'time_ofs':0.03, 'time_cor':0.0005, 'sync_mode':1, 'sync_flag':3, 'verbose':0xff})) + dflt.append((AppCfg.DT_MISC,{'show_plots':True, 'vel_scl':1.0, 'fel_per':10.0, 'time_ofs':0.03, 'time_cor':0.0005, 'sync_mode':1, 'sync_flag':3, 'verbose':0xff})) if AppCfg.DAQ_DET not in keys: dflt.append((AppCfg.DAQ_DET, { "name" : "JF17T16V01", @@ -308,7 +308,7 @@ bit 1=2 : simulated frame trigger 1 : simulated start and real frame trigger 2 : real start and simulated frame trigger 3 : simulated start and frame trigger - pt2pt_time : time point to point (needed sor sync code) + fel_per : FEL-period: time FEL-pulse to FEL-pulse in ms (needed for sync code) ''' tip_verbose='''\ @@ -406,7 +406,7 @@ verbose bits: {'name':AppCfg.DT_MISC, 'title':'miscellaneous', 'type':'group', 'children':[ {'name':'show_plots', 'value':dt_misc['show_plots'], 'type':'bool', 'title':'show plots after collection'}, {'name':'vel_scl', 'value':dt_misc['vel_scl'], 'type':'float', 'limits':(0, 1), 'step':0.1, 'title':'velocity_scale', 'tip':"scale between smooth(1.0) and stop and go(0.0)"}, - {'name':'pt2pt_time', 'value':dt_misc['pt2pt_time'], 'type':'float', 'step':0.1,'tip':"time in ms from point to point"}, + {'name':'fel_per', 'value':dt_misc['fel_per'], 'type':'float', 'step':0.1,'tip':"FEL-period: time FEL-pulse to FEL-pulse in ms"}, {'name':'time_ofs', 'value':dt_misc['time_ofs'], 'type':'float', 'step':0.001,'decimals':4,'tip':"time offset for triggerSync (once)"}, {'name':'time_cor', 'value':dt_misc['time_cor'], 'type':'float', 'step':0.0001,'decimals':5,'tip':"time correction for triggerSync (each frame)"}, {'name':'sync_mode', 'value':dt_misc['sync_mode'], 'type':'int', 'tip':tip_sync_mode}, diff --git a/psi_device.py b/psi_device.py index 8ef405f..2ed7492 100644 --- a/psi_device.py +++ b/psi_device.py @@ -80,6 +80,7 @@ class Deltatau: app=QApplication.instance() cfg=app._cfg host=cfg.value(AppCfg.DT_HOST) + # sim=False;host='localhost:10001:10002' # this only moves motors during acquisition if sim: self._comm=comm=None self._gather=gather=None @@ -119,6 +120,7 @@ class Jungfrau: def config(self,**kwargs): if getattr(self,'_sim',False): _log.info(f'simulated') + return app=QApplication.instance() #temproary fix, couldnt access these in function, maybe the bt above needs to be self.detectors ... etc cfg=app._cfg det = cfg.value(AppCfg.DAQ_DET) @@ -193,6 +195,9 @@ class Jungfrau: rate_multiplicator=1, append_user_tag_to_data_dir=True) def acquire(self, n_pulses, wait=False): + if getattr(self,'_sim',False): + _log.info(f'simulated') + return try: daq=self._daq except AttributeError: @@ -218,6 +223,9 @@ class Jungfrau: cfg.setValue(AppCfg.DAQ_RUN,run) def gather_upload(self): + if getattr(self,'_sim',False): + _log.info(f'simulated') + return try: daq=self._daq except AttributeError: diff --git a/swissmx.py b/swissmx.py index a55dcba..c76d535 100755 --- a/swissmx.py +++ b/swissmx.py @@ -11,14 +11,15 @@ SwissMx experiment application. bitmask for simulation: - 0x01: backlight - 0x02: illumination - 0x04: zoom - 0x08: camera - 0x10: Deltatau motors and motion code - 0x20: SmarAct motors - 0x40: shutter - 0x80: Jungfrau + 0x001: backlight + 0x002: illumination + 0x004: zoom + 0x008: camera + 0x010: EPICS motors Deltatau + 0x020: EPICS motors SmarAct + 0x040: shutter + 0x080: Jungfrau + 0x100: Deltatau motion code """ import logging @@ -2313,7 +2314,7 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) try: dt=app._deltatau except AttributeError: - app._deltatau=dt=psi_device.Deltatau(app._args.sim&0x10!=0) + app._deltatau=dt=psi_device.Deltatau(app._args.sim&0x100!=0) try: jf=app._jungfrau except AttributeError: @@ -2322,7 +2323,7 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) sp=dt._shapepath sp.verbose=dt_misc['verbose'] - sp.meta['pt2pt_time']=dt_misc['pt2pt_time'] + sp.meta['fel_per']=dt_misc['fel_per'] sp.meta['sync_mode']=dt_misc['sync_mode'] sp.meta['sync_flag']=dt_misc['sync_flag'] @@ -2340,9 +2341,7 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) #dlg.setAutoClose(True) #dlg.show() dlg.setLabelText("Setup Gather/Sync");dlg+=5 - num_pts=kwargs['num_pts'] code_gen=kwargs.get('code_gen',0) - sp.setup_gather(num_pts) sp.setup_sync(verbose=sp.verbose&0x40, timeOfs=dt_misc['time_ofs'], timeCor=dt_misc['time_cor']) dlg.setLabelText("Download motion program");dlg+=5 if code_gen==0: @@ -2353,6 +2352,7 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) sp.setup_motion(fnPrg=fn+'.prg', mode=4, scale=1., dwell=10, grid=kwargs['grid'], trf=kwargs['trf']) elif code_gen==3: sp.setup_motion(fnPrg=fn+'.prg', mode=5, dwell=10, tmove=kwargs['tmove'] ,twait=kwargs['twait'], grid=kwargs['grid'],trf=kwargs['trf']) + sp.setup_gather() try: p=geo._fitPlane # TODO: Cleanup @@ -2419,13 +2419,14 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) sp.wait_armed() # wait until motors are at first position shutter.open() time.sleep(1.1) + num_pts=kwargs['num_pts'] jf.acquire(num_pts) sp.trigger(1.0) # send a start trigger (if needed) after given time _log.info('start trigger sent') if dt._comm is None: dlg.setLabelText("run motion/acquisition (simulated)") dlg.setMaximum(num_pts) - for p in range(0,num_pts,int(num_pts/100)): + for p in range(0,num_pts,1+int(num_pts/100)): #_log.info(f'progress {p}/{num_pts}') dlg.setValue(p) time.sleep(.1) @@ -2434,14 +2435,14 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch) dlg.setMaximum(num_pts) while True: p=int(sp.progress()) - #_log.info(f'progress {p}/{num_pts}') + _log.info(f'progress {p}/{num_pts}') if p<0: break elif dlg.wasCanceled(): dt._comm.gpascii.send_block('&1a;Gather.Enable=0') break #_log.info(f'progress {p}/{sp.points.shape[0]}') - dlg.setValue(p) + dlg.setValue(max(p,num_pts)) time.sleep(1.) #wait 1 sec instead of .1...hopefully less segmentation faults if not dlg.wasCanceled(): jf.gather_upload()