From c309c3fd002a7f8b3b0e7d97a7f1f342a72f61f7 Mon Sep 17 00:00:00 2001
From: Jessica McChesney <jmcchesn@anl.gov>
Date: Fri, 19 Aug 2022 10:32:38 -0500
Subject: [PATCH] debug

---
 build/lib/iexcode/instruments/logfile.py    |  8 +++---
 build/lib/iexcode/instruments/scanRecord.py | 24 +++++++++++-------
 iexcode/instruments/logfile.py              |  8 +++---
 iexcode/instruments/scanRecord.py           | 28 +++++++++++++--------
 4 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/build/lib/iexcode/instruments/logfile.py b/build/lib/iexcode/instruments/logfile.py
index cde224d..dc7d7b5 100644
--- a/build/lib/iexcode/instruments/logfile.py
+++ b/build/lib/iexcode/instruments/logfile.py
@@ -18,9 +18,11 @@ def log_update():
     """
     updates the log file with the last scan info
     """
- 
-    entry_list,pv_list, format_list = BL.log_entries()
-    logfile_update(BL.endstation_name,BL.ioc,entry_list,pv_list,format_list)
+    try:
+        entry_list,pv_list, format_list = BL.log_entries()
+        logfile_update(BL.endstation_name,BL.ioc,entry_list,pv_list,format_list)
+    except:
+        print('No logfile written')
 
 
 ##############################################################################################################
diff --git a/build/lib/iexcode/instruments/scanRecord.py b/build/lib/iexcode/instruments/scanRecord.py
index 5fd1840..f1c12a4 100644
--- a/build/lib/iexcode/instruments/scanRecord.py
+++ b/build/lib/iexcode/instruments/scanRecord.py
@@ -413,7 +413,8 @@ class ScanRecord:
         caput(scan_pv+".R"+str(posNum)+"PV",rbv_pv)
         caput(scan_pv+".P"+str(posNum)+"SP",start*1.0)
         caput(scan_pv+".P"+str(posNum)+"EP",stop*1.0)
-        if kwargs['positioner_num'] == 1:
+        
+        if posNum == 1:
             if 'num_points' in kwargs:
                 if kwargs['num_points'] :
                     caput(scan_pv+".NPTS",steps_points)
@@ -681,8 +682,8 @@ class ScanRecord:
                 print('Scan'+str(i)+': '+drive+'= '+str(start)+' / '+str(stop)+' / '+str(step))
         
         if self.check(scan_dim):
-            filename = self.prefix(self.ioc)
-            fileNum  = self.fileNum(self.ioc)
+            filename = self.prefix()
+            fileNum  = self.fileNum()
             print(filename+str(fileNum)+" started at ", dateandtime())
             scan_pv = self.ioc+"scan"+str(scan_dim)
             caput(scan_pv+".EXSC",1,wait=True,timeout=900000)  #pushes scan button
@@ -703,21 +704,24 @@ class ScanRecord:
 
         **kwargs:
             execute = True/False (default=True)
+            see scanRecord.fillin for more options
 
         Previously: Scan_Empty_Go
         """
         kwargs.setdefault('execute',True)
         kwargs.setdefault('num_points',True)
-        self.fillin("","",0,npts,1,**kwargs)   
-        sleep(.1)
+        self.fillin("","",0,npts-1,npts,**kwargs)   
+        time.sleep(.1)
 
         if kwargs['execute']:
             self.go(**kwargs)
  
-    def time_scan(self,duration_min,step_sec,**kwargs):
+    def time_scan(self,duration_min,step_min=1,**kwargs):
         """
         starts a scan with the readback as time in seconds
-
+        duration: total time for the scan in minutes
+        step_min: steps per minute (sets the detector setting time for this)
+        
         **kwargs
             execute True/False (default = True)
 
@@ -728,10 +732,12 @@ class ScanRecord:
         """
         kwargs.setdefault('execute',True)
 
-        stop=duration_min*60.0/step_sec
+        kwargs.update({'detector_settling_time':60.0/step_min})
+
+        stop=duration_min*60.0*step_min
         self.fillin("","time",1,stop,1,**kwargs)
 
-        print("Time scan - Settling time : "+str(step_sec))
+        print("Time scan - Settling time : "+str(step_min))
         if kwargs['execute']:
             self.go(**kwargs)
 
diff --git a/iexcode/instruments/logfile.py b/iexcode/instruments/logfile.py
index cde224d..dc7d7b5 100644
--- a/iexcode/instruments/logfile.py
+++ b/iexcode/instruments/logfile.py
@@ -18,9 +18,11 @@ def log_update():
     """
     updates the log file with the last scan info
     """
- 
-    entry_list,pv_list, format_list = BL.log_entries()
-    logfile_update(BL.endstation_name,BL.ioc,entry_list,pv_list,format_list)
+    try:
+        entry_list,pv_list, format_list = BL.log_entries()
+        logfile_update(BL.endstation_name,BL.ioc,entry_list,pv_list,format_list)
+    except:
+        print('No logfile written')
 
 
 ##############################################################################################################
diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py
index 5fd1840..2fd9113 100644
--- a/iexcode/instruments/scanRecord.py
+++ b/iexcode/instruments/scanRecord.py
@@ -413,7 +413,8 @@ class ScanRecord:
         caput(scan_pv+".R"+str(posNum)+"PV",rbv_pv)
         caput(scan_pv+".P"+str(posNum)+"SP",start*1.0)
         caput(scan_pv+".P"+str(posNum)+"EP",stop*1.0)
-        if kwargs['positioner_num'] == 1:
+        
+        if posNum == 1:
             if 'num_points' in kwargs:
                 if kwargs['num_points'] :
                     caput(scan_pv+".NPTS",steps_points)
@@ -681,8 +682,8 @@ class ScanRecord:
                 print('Scan'+str(i)+': '+drive+'= '+str(start)+' / '+str(stop)+' / '+str(step))
         
         if self.check(scan_dim):
-            filename = self.prefix(self.ioc)
-            fileNum  = self.fileNum(self.ioc)
+            filename = self.prefix()
+            fileNum  = self.fileNum()
             print(filename+str(fileNum)+" started at ", dateandtime())
             scan_pv = self.ioc+"scan"+str(scan_dim)
             caput(scan_pv+".EXSC",1,wait=True,timeout=900000)  #pushes scan button
@@ -703,21 +704,24 @@ class ScanRecord:
 
         **kwargs:
             execute = True/False (default=True)
+            see scanRecord.fillin for more options
 
         Previously: Scan_Empty_Go
         """
         kwargs.setdefault('execute',True)
         kwargs.setdefault('num_points',True)
-        self.fillin("","",0,npts,1,**kwargs)   
-        sleep(.1)
+        self.fillin("","",0,npts-1,npts,**kwargs)   
+        time.sleep(.1)
 
         if kwargs['execute']:
             self.go(**kwargs)
  
-    def time_scan(self,duration_min,step_sec,**kwargs):
+    def time_scan(self,duration_min,step_min=1,**kwargs):
         """
         starts a scan with the readback as time in seconds
-
+        duration: total time for the scan in minutes
+        step_min: steps per minute (sets the detector setting time for this)
+        
         **kwargs
             execute True/False (default = True)
 
@@ -728,10 +732,14 @@ class ScanRecord:
         """
         kwargs.setdefault('execute',True)
 
-        stop=duration_min*60.0/step_sec
-        self.fillin("","time",1,stop,1,**kwargs)
+        kwargs.update({'detector_settling_time':60.0/step_min})
+
+        stop = duration_min 
+        #num_pnts = duration_min * step_min
+        dwell = 60/step_min
+        self.fillin("","time",dwell/60,stop,dwell/60,**kwargs)
 
-        print("Time scan - Settling time : "+str(step_sec))
+        print("Time scan - Settling time : "+str(step_min))
         if kwargs['execute']:
             self.go(**kwargs)
 
-- 
GitLab