changeset 44:c93d6d4cb04b

Use *OPC where supported, otherwise poll.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 28 Sep 2011 17:15:23 +0930
parents 7ba7207df078
children 6bd941d96c03
files specan.py
diffstat 1 files changed, 17 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/specan.py	Wed Sep 28 17:14:30 2011 +0930
+++ b/specan.py	Wed Sep 28 17:15:23 2011 +0930
@@ -43,7 +43,18 @@
         self.con.write("INIT;*WAI")
 
         # Wait for it to be done
-        if False:
+        self.wait(timeout)
+
+        # Grab trace data
+        self.con.write(self.tracequery)
+        dat = self.con.read(10)
+
+        # Parse into array
+        ary = scpi.bindecode(dat, dtype = self.tracedtype)
+        return ary
+
+    def wait(self, timeout):
+        if self.hasopc:
             self.con.write("*OPC?")
             opc = scpi.getdata(self.con.read(timeout), int)
             if opc != 1:
@@ -55,15 +66,7 @@
                 if i & 256:
                     break
 
-           
-        # Grab trace data
-        self.con.write(self.tracequery)
-        dat = self.con.read(10)
-
-        # Parse into array
-        ary = scpi.bindecode(dat, dtype = self.tracedtype)
-        return ary
-
+        
     def dumpconf(self):
         rtn = {}
         for k in self.attrs:
@@ -89,15 +92,16 @@
               'detector' : ['SENSE1:DETECTOR1:FUNCTION', str, None] , # Page 552
               }
 
+    hasopc = True
     tracetypename = 'REAL,32'
     tracedtype = numpy.float32
     tracequery = 'TRAC1? TRACE1'
     swptslist = [125, 251, 501, 1001, 2001, 4001, 8001]
-
+    
 #    def sweepptscheck(npts):
 #        if x not in RSSPA.swptslist:
 #            raise exceptions.ValueError("Sweep value not supported, must be one of " + str(RSSPA.swptslist))
-        
+
         
 class AnSPA(Traceinst):
     '''Anritsu Spectrum Analyzer'''
@@ -113,6 +117,7 @@
              'detector' : [':SENSe:DETector:FUNCtion', str, None], # Page 24
     }
 
+    hasopc = False
     tracetypename = 'REAL,32'
     tracedtype = numpy.float32
     tracequery = 'TRACE:DATA?'