Mercurial > ~darius > hgwebdir.cgi > pyinst
comparison specan.py @ 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 | 182c42e7bf03 |
children | 23c96322cfb6 |
comparison
equal
deleted
inserted
replaced
43:7ba7207df078 | 44:c93d6d4cb04b |
---|---|
41 def gettrace(self, timeout = 10): | 41 def gettrace(self, timeout = 10): |
42 # Trigger the sweep | 42 # Trigger the sweep |
43 self.con.write("INIT;*WAI") | 43 self.con.write("INIT;*WAI") |
44 | 44 |
45 # Wait for it to be done | 45 # Wait for it to be done |
46 if False: | 46 self.wait(timeout) |
47 | |
48 # Grab trace data | |
49 self.con.write(self.tracequery) | |
50 dat = self.con.read(10) | |
51 | |
52 # Parse into array | |
53 ary = scpi.bindecode(dat, dtype = self.tracedtype) | |
54 return ary | |
55 | |
56 def wait(self, timeout): | |
57 if self.hasopc: | |
47 self.con.write("*OPC?") | 58 self.con.write("*OPC?") |
48 opc = scpi.getdata(self.con.read(timeout), int) | 59 opc = scpi.getdata(self.con.read(timeout), int) |
49 if opc != 1: | 60 if opc != 1: |
50 return None | 61 return None |
51 else: | 62 else: |
53 self.con.write(':STATus:OPERation?') | 64 self.con.write(':STATus:OPERation?') |
54 i = scpi.getdata(self.con.read(timeout), int) | 65 i = scpi.getdata(self.con.read(timeout), int) |
55 if i & 256: | 66 if i & 256: |
56 break | 67 break |
57 | 68 |
58 | 69 |
59 # Grab trace data | |
60 self.con.write(self.tracequery) | |
61 dat = self.con.read(10) | |
62 | |
63 # Parse into array | |
64 ary = scpi.bindecode(dat, dtype = self.tracedtype) | |
65 return ary | |
66 | |
67 def dumpconf(self): | 70 def dumpconf(self): |
68 rtn = {} | 71 rtn = {} |
69 for k in self.attrs: | 72 for k in self.attrs: |
70 self.con.write(self.attrs[k][0] + '?') | 73 self.con.write(self.attrs[k][0] + '?') |
71 res = self.con.read() | 74 res = self.con.read() |
87 'sweepcnt' : ['SENSE1:AVERAGE:COUNT', int, None], # Page 595 | 90 'sweepcnt' : ['SENSE1:AVERAGE:COUNT', int, None], # Page 595 |
88 'reflev' : ['DISPLAY:WINDOW1:TRACE1:Y:SCALE:RLEVEL', float, None], # Page 506 | 91 'reflev' : ['DISPLAY:WINDOW1:TRACE1:Y:SCALE:RLEVEL', float, None], # Page 506 |
89 'detector' : ['SENSE1:DETECTOR1:FUNCTION', str, None] , # Page 552 | 92 'detector' : ['SENSE1:DETECTOR1:FUNCTION', str, None] , # Page 552 |
90 } | 93 } |
91 | 94 |
95 hasopc = True | |
92 tracetypename = 'REAL,32' | 96 tracetypename = 'REAL,32' |
93 tracedtype = numpy.float32 | 97 tracedtype = numpy.float32 |
94 tracequery = 'TRAC1? TRACE1' | 98 tracequery = 'TRAC1? TRACE1' |
95 swptslist = [125, 251, 501, 1001, 2001, 4001, 8001] | 99 swptslist = [125, 251, 501, 1001, 2001, 4001, 8001] |
96 | 100 |
97 # def sweepptscheck(npts): | 101 # def sweepptscheck(npts): |
98 # if x not in RSSPA.swptslist: | 102 # if x not in RSSPA.swptslist: |
99 # raise exceptions.ValueError("Sweep value not supported, must be one of " + str(RSSPA.swptslist)) | 103 # raise exceptions.ValueError("Sweep value not supported, must be one of " + str(RSSPA.swptslist)) |
100 | 104 |
101 | 105 |
102 class AnSPA(Traceinst): | 106 class AnSPA(Traceinst): |
103 '''Anritsu Spectrum Analyzer''' | 107 '''Anritsu Spectrum Analyzer''' |
104 attrs = { 'fstart' : ['FREQ:START', float, None], # Page 26 | 108 attrs = { 'fstart' : ['FREQ:START', float, None], # Page 26 |
105 'fstop' : ['FREQ:STOP', float, None], # Page 26 | 109 'fstop' : ['FREQ:STOP', float, None], # Page 26 |
111 'vidbw' : ['SENSE:BANDWIDTH:VIDEO', float, None], # Page 23 | 115 'vidbw' : ['SENSE:BANDWIDTH:VIDEO', float, None], # Page 23 |
112 'reflev' : [':DISPLAY:WIND:TRACE:Y:SCALE:RLEVEL', float, None], # Page 15 | 116 'reflev' : [':DISPLAY:WIND:TRACE:Y:SCALE:RLEVEL', float, None], # Page 15 |
113 'detector' : [':SENSe:DETector:FUNCtion', str, None], # Page 24 | 117 'detector' : [':SENSe:DETector:FUNCtion', str, None], # Page 24 |
114 } | 118 } |
115 | 119 |
120 hasopc = False | |
116 tracetypename = 'REAL,32' | 121 tracetypename = 'REAL,32' |
117 tracedtype = numpy.float32 | 122 tracedtype = numpy.float32 |
118 tracequery = 'TRACE:DATA?' | 123 tracequery = 'TRACE:DATA?' |
119 | 124 |
120 def getInst(inst): | 125 def getInst(inst): |