doc/developer_manual.rst

changeset 74
62d7957b3aa8
parent 73
2645ef311424
equal deleted inserted replaced
73:2645ef311424 74:62d7957b3aa8
27 datablock = cnx.send_command('DDBN') 27 datablock = cnx.send_command('DDBN')
28 28
29 if cnx.check_srq(): 29 if cnx.check_srq():
30 print "A Service Request has been sent" 30 print "A Service Request has been sent"
31 31
32 Hight level 32 But that's basically it. You can send commands to devices, wait for an
33 =========== 33 answer, check SRQ line.
34
35 High level
36 ==========
37
38 The high level API is organized around a GPIB controller class
39 (``pygpibtoolkit.gpibcontroller.GPIBController``) which is responsible
40 for managing every connection stuff. It will run a thread responsible
41 for communication processes, will regularly check SRQ line (and
42 respond accordingly, with ability to register callbacks), etc.
43
44 It will also provide a ``send_command`` method, but this latter will
45 have a much higher means: the operation can be done synchronously or
46 asynchronously (with a callback to call upon completion), etc.
47
48 It will also hold device managers for found devices on the GPIB bus.
49
50 Each device manager is a class responsible for communication
51 specifically with a specified device. It will provide (if the device
52 manager has been written) simple ways to send GPIB commands of the
53 device; every GPIB command will be presented as a method of the
54 manager.
55
56 Talking with a device can then be as simple as::
57
58 from pygpibtoolkit.gpibcontroller import GPIBController
59 c = GPIBController()
60 devices = c.detect_devices()
61 # devices is a dict which keys are the GPIB addresses
62 # and values, the managers for each device
63 hp3562 = devices[3]
64
65 # ok, let's tell the HP3562 to put channel 1 in AC couplig mode,
66 hp3562.C1AC("AC")
67 # and put it in linear measure mode
68 hp3562.LNRS() #EMEAS("LINEAR RES")
69 # and Freq response mode
70 hp3562.FRQR()
71 # set span freq and center freq
72 hp3562.FRS("10khz")
73 hp3562.CF("7212hz")
74 # then get the resulting trace data block
75 trace = hp3562.DDBN()
76 # which we can easily display
77 header, data = hp3562.decode_trace(trace)
78 import pylab
79 pylab.plot(data)
80 pylab.show()
81
82 # ok, let's stop gracefully our cession
83 c.stop()
84
34 85
35 86
36 87
37

mercurial