HP3562A/__init__.py

changeset 13
78e3e839658b
child 14
07e2cbf140df
equal deleted inserted replaced
12:a04bea92c509 13:78e3e839658b
1 """
2 HP3562A
3 =======
4
5 Module for communicating with the HP 3562A Digital Signal Analyzer.
6
7 Subpackages
8 -----------
9
10
11 Constants
12 ---------
13
14 """
15
16 from gpib import gpib
17
18 #####################
19 # HP3562A constants
20
21 # GPIB buffer size is 3x80 characters lines
22 class STATUS_BYTE(gpib.Constants):
23 # HP3562A Status Byte, as returned by a serial poll
24 _constants = [(0x40, "RQS", "Request Service"), # when sent in response to a serial poll
25 (0x20, "ERR", "GPIB error"),
26 (0x10, "RDY", "ready to accept GPIB commands"),
27 ]
28
29 conditions = [(0, "NSR", "No service requested"),
30 (1, "USRQ1", "User SRQ #1"),
31 (2, "USRQ1", "User SRQ #2"),
32 (3, "USRQ1", "User SRQ #3"),
33 (4, "USRQ1", "User SRQ #4"),
34 (5, "USRQ1", "User SRQ #5"),
35 (6, "USRQ1", "User SRQ #6"),
36 (7, "USRQ1", "User SRQ #7"),
37 (8, "USRQ1", "User SRQ #8"),
38 (9, "EOD", "End of disk action"),
39 (10, "EOP", "End of plot action"),
40 (11, "STCH", "Instrument status changed"), # any change in
41 # the status register sets this condition
42 (12, "PWR", "Power on"),
43 (13, "KEY", "Key pressed"),
44 (14, "DCP", "Device clear plotter (listen)"),
45 # ...
46 ]
47 def __init__(self):
48 super(STATUS_BYTE, self).__init__()
49 self._conditions = dict([(x[0], x[1]) for x in self.conditions])
50 self._rev_conditions = dict([(x[1], x[0]) for x in self.conditions])
51 self._long_conditions = dict([(x[0], x[2]) for x in self.conditions])
52
53 def byte_condition(self, byte):
54 byte = byte & 0x8F
55 return self._conditions.get(byte, "N/A")
56
57 class IS_REGISTER(gpib.Constants):
58 _constants = [(0x01, "MEASP", "measeurement pause"),
59 (0x02, "ASQP", "Auto sequence pause"),
60 (0X04, "EOM", "End of measurement, capture or throughput"),
61 (0x08, "EOAS", "End of auto sequence"),
62 (0x10, "SWPR", "Sweep point ready"),
63 (0x20, "CH1OV", "Channel 1 overrange"),
64 (0x40, "CH2OV", "Channel 2 overrange"),
65 (0X80, "CH1HR", "Channel 1 half range"),
66 (0x100, "CH2HR", "Channel 2 half range"),
67 (0x200, "SFALT", "Source falt"),
68 (0x400, "RUNL", "Reference unlock"),
69 (0x800, "RMKT", "Remote marker knob turn"),
70 (0x1000, "REKT", "Remote entry knob turn"),
71 (0x2000, "ASRC", "Asctive Status Register changed"),
72 (0x4000, "PWRF", "Power-on test failed"),
73 ]
74
75 class StatusQuery(gpib.Constants):
76 _command = "STA?"
77 _constants = [(0x01, "N/A", "Not used"),
78 (0x02, "N/A", "Not used"),
79 (0x04, "KEY", "Key pressed"),
80 (0x08, "N/A", "Not used"),
81 (0x10, "RDY", "Ready"),
82 (0x20, "ERR", "Error"),
83 (0x40, "RQS", "Request"),
84 (0x80, "MOS", "Message on screen"),
85 (0x100, "MEASP", "measeurement pause"),
86 (0x200, "ASQP", "Auto sequence pause"),
87 (0X400, "EOM", "End of measurement, capture or throughput"),
88 (0x800, "EOAS", "End of auto sequence"),
89 (0x1000, "SWPR", "Sweep point ready"),
90 (0x2000, "CH1OV", "Channel 1 overrange"),
91 (0x4000, "CH2OV", "Channel 2 overrange"),
92 (0x8000, "MAOV", "Math overflow"),
93 ]
94 class ActivityStatysRegister(gpib.Constants):
95 _command = "AS?"
96 _constants = [(0x01, "CKFL", "Check fault log"),
97 (0x02, "FITR", "Filling time record"),
98 (0x04, "FLTR", "Filters settings"),
99 (0x08, "CFTP", "Curve fir in progress"),
100 (0x10, "MSSM", "Missed sample"),
101 (0x20, "TMPR", "Timed preview"),
102 (0x40, "ACDA", "Accept date"),
103 #...
104 ]

mercurial