From 0e03bff911dd7879b1a163aaa3bf82180862f943 Mon Sep 17 00:00:00 2001 From: philippe piot <ppiot@anl.gov> Date: Wed, 3 Jul 2024 15:05:36 -0500 Subject: [PATCH] some debugging --- AWAControl/utils.py | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/AWAControl/utils.py b/AWAControl/utils.py index 03a11f4..431f205 100644 --- a/AWAControl/utils.py +++ b/AWAControl/utils.py @@ -1,5 +1,6 @@ import time from epics import caput, caget, pv +import numpy as np # Trigger Sync @@ -9,16 +10,17 @@ class TriggerSynchronisation: triggerCheckPV = None # PV used to check if the trigger works as expected # the ICT current is a good default check since it updates with every bunchtrain - def setup(checkPVName = "AWAVXI11ICT:Ch1"): - triggerCheckPV = pv.PV(checkPVName) - triggerPV.put(1) + def setup(self, checkPVName = "AWAVXI11ICT:Ch1"): + self.triggerPV = pv.PV("AWATrigCtrl:SetCh8") + self.triggerCheckPV = pv.PV(checkPVName) + self.triggerPV.put(1) - def check_trigger_sync(): - temp = triggerCheckPV.get() # do not think this is strictly necessary - ts_ict_ts_b =triggerCheckPV.timestamp + def check_trigger_sync(self): + temp = self.triggerCheckPV.get() # do not think this is strictly necessary + ts_ict_ts_b = self.triggerCheckPV.timestamp time.sleep(1.1) # need to be larger than pulse - ts_ict_ts_a = triggerCheckPV.timestamp + ts_ict_ts_a = self.triggerCheckPV.timestamp # if the time difference is large enough and PV timestamp did not change # we can assume that the triggerControl is setup correctlys @@ -27,17 +29,17 @@ class TriggerSynchronisation: if ((ts_ict_ts_a - ts_ict_ts_b) > 0.000001): print("Please, Make sure the osciloscopes and the Images are frozen after each trigger.") input("Press Enter to continue...") - check_trigger() + self.check_trigger_sync() pass - def trigger(): - temp = triggerCheckPV.get() - ts_ict_ts_b =triggerCheckPV.timestamp # before trigger + def trigger(self): + temp = self.triggerCheckPV.get() + ts_ict_ts_b =self.triggerCheckPV.timestamp # before trigger # trigger scopes and camera update - triggerPV.put(1) + self.triggerPV.put(1) - ts_ict_ts_a = triggerCheckPV.timestamp #after trigger + ts_ict_ts_a = self.triggerCheckPV.timestamp #after trigger n_waits = 0 @@ -48,10 +50,12 @@ class TriggerSynchronisation: while ((ts_ict_ts_a - ts_ict_ts_b) < 0.000001 ): # retrigger if time sptampe differnce was to small by chance if (n_waits > 60): # this number depends on pulsefrequency - triggerPV.put(1) + print("Re-Triggering...") + self.triggerPV.put(1) + n_waits = 0 time.sleep(0.02) - n_waits++ - ts_ict_ts_a = pv_ICT.timestamp + n_waits+=1 + ts_ict_ts_a = self.triggerCheckPV.timestamp ##### @@ -114,6 +118,4 @@ def get_waveforms(fct12ghz=False): return results - - - \ No newline at end of file + -- GitLab