# HG changeset patch # User Daniel O'Connor # Date 1317195923 -34200 # Node ID c93d6d4cb04beca00fc146982c3f6b26824d7496 # Parent 7ba7207df0783b1c8e287c8f48fed20e8c086d5c Use *OPC where supported, otherwise poll. diff -r 7ba7207df078 -r c93d6d4cb04b specan.py --- 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?'