annotate example2.py @ 9:a6b746654ae2

Fix comment mangle.
author Daniel O'Connor <darius@dons.net.au>
date Sat, 16 May 2009 23:32:51 +0930
parents 85dfc0babc36
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 #!/usr/bin/env python
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 # Copyright (c) 2009
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 # Daniel O'Connor <darius@dons.net.au>. All rights reserved.
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 #
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 # Redistribution and use in source and binary forms, with or without
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7 # modification, are permitted provided that the following conditions
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8 # are met:
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 # 1. Redistributions of source code must retain the above copyright
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10 # notice, this list of conditions and the following disclaimer.
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11 # 2. Redistributions in binary form must reproduce the above copyright
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 # notice, this list of conditions and the following disclaimer in the
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13 # documentation and/or other materials provided with the distribution.
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 #
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15 # THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 # ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 # SUCH DAMAGE.
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 #
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 import rsib
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 import numpy
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 from matplotlib import pylab
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32 def test(r):
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33 r.write('*IDN?')
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 print "ID is " + r.read(5)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 r.write("*RST")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 r.write("INIT:CONT OFF")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37 r.write("SYST:DISP:UPD ON")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 r.write("FREQ:STAR 85MHz;STOP 125MHz")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 r.write("DISP:WIND:TRAC:T:RLEV -20dBm")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40 r.write("INIT;*WAI")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41 r.write("*OPC?")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42 print "OPC - " + r.read(10)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43 r.write("CALC:MARK:PEXC 6DB")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 r.write("CALC:MARK:FUNC:TOI ON")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45 r.write("CALC:MARK:FUNC:TOI:RES?")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46 print "Result " + r.read(10)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
47
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48 r.write("FORM:DATA ASC")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49 r.write("CALC:LIM5:NAME 'TEST1'")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50 r.write("CALC:LIM5:COMM 'Upper limit line'")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 r.write("CALC1:LIM5:TRAC 2")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52 r.write("TRAC1? TRACE1")
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 data = r.read(10)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 #print "Data - " + dat
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 data = map(float, data.split(','))
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
56 ary = numpy.array(data)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57 pylab.plot(ary)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
58 pylab.show()
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
59
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
60 if __name__ == '__main__':
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
61 r = rsib.RSIBDevice('localhost')
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
62 test(r)
85dfc0babc36 Add basic RSIB parser and example program.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
63