HP3562A/__init__.py

changeset 13
78e3e839658b
child 14
07e2cbf140df
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HP3562A/__init__.py	Mon Dec 17 18:59:45 2007 +0100
@@ -0,0 +1,104 @@
+"""
+HP3562A
+=======
+
+Module for communicating with the HP 3562A Digital Signal Analyzer.
+
+Subpackages
+-----------
+
+
+Constants
+---------
+
+"""
+
+from gpib import gpib
+
+#####################
+# HP3562A constants
+
+# GPIB buffer size is 3x80 characters lines
+class STATUS_BYTE(gpib.Constants):
+    # HP3562A Status Byte, as returned by a serial poll
+    _constants = [(0x40, "RQS", "Request Service"), # when sent in response to a serial poll
+                  (0x20, "ERR", "GPIB error"),
+                  (0x10, "RDY", "ready to accept GPIB commands"),
+                  ]
+
+    conditions = [(0, "NSR", "No service requested"),
+                  (1, "USRQ1", "User SRQ #1"),
+                  (2, "USRQ1", "User SRQ #2"),
+                  (3, "USRQ1", "User SRQ #3"),
+                  (4, "USRQ1", "User SRQ #4"),
+                  (5, "USRQ1", "User SRQ #5"),
+                  (6, "USRQ1", "User SRQ #6"),
+                  (7, "USRQ1", "User SRQ #7"),
+                  (8, "USRQ1", "User SRQ #8"),
+                  (9, "EOD", "End of disk action"),
+                  (10, "EOP", "End of plot action"),
+                  (11, "STCH", "Instrument status changed"), # any change in 
+                  # the status register sets this condition
+                  (12, "PWR", "Power on"),
+                  (13, "KEY", "Key pressed"),
+                  (14, "DCP", "Device clear plotter (listen)"),
+                  # ...
+                  ]
+    def __init__(self):
+        super(STATUS_BYTE, self).__init__()
+        self._conditions = dict([(x[0], x[1]) for x in self.conditions])
+        self._rev_conditions = dict([(x[1], x[0]) for x in self.conditions])
+        self._long_conditions = dict([(x[0], x[2]) for x in self.conditions])
+               
+    def byte_condition(self, byte):
+        byte = byte & 0x8F
+        return self._conditions.get(byte, "N/A")
+
+class IS_REGISTER(gpib.Constants):
+    _constants = [(0x01, "MEASP", "measeurement pause"),
+                  (0x02, "ASQP", "Auto sequence pause"),
+                  (0X04, "EOM", "End of measurement, capture or throughput"),
+                  (0x08, "EOAS", "End of auto sequence"),
+                  (0x10, "SWPR", "Sweep point ready"),
+                  (0x20, "CH1OV", "Channel 1 overrange"),
+                  (0x40, "CH2OV", "Channel 2 overrange"),
+                  (0X80, "CH1HR", "Channel 1 half range"),
+                  (0x100, "CH2HR", "Channel 2 half range"),
+                  (0x200, "SFALT", "Source falt"),
+                  (0x400, "RUNL", "Reference unlock"),
+                  (0x800, "RMKT", "Remote marker knob turn"),
+                  (0x1000, "REKT", "Remote entry knob turn"),
+                  (0x2000, "ASRC", "Asctive Status Register changed"),
+                  (0x4000, "PWRF", "Power-on test failed"),
+                  ]
+    
+class StatusQuery(gpib.Constants):
+    _command = "STA?"
+    _constants = [(0x01, "N/A", "Not used"),
+                  (0x02, "N/A", "Not used"),
+                  (0x04, "KEY", "Key pressed"),
+                  (0x08, "N/A", "Not used"),
+                  (0x10, "RDY", "Ready"),
+                  (0x20, "ERR", "Error"),
+                  (0x40, "RQS", "Request"),
+                  (0x80, "MOS", "Message on screen"),
+                  (0x100, "MEASP", "measeurement pause"),
+                  (0x200, "ASQP", "Auto sequence pause"),
+                  (0X400, "EOM", "End of measurement, capture or throughput"),
+                  (0x800, "EOAS", "End of auto sequence"),
+                  (0x1000, "SWPR", "Sweep point ready"),
+                  (0x2000, "CH1OV", "Channel 1 overrange"),
+                  (0x4000, "CH2OV", "Channel 2 overrange"),
+                  (0x8000, "MAOV", "Math overflow"),
+                  ]
+class ActivityStatysRegister(gpib.Constants):
+    _command = "AS?"
+    _constants = [(0x01, "CKFL", "Check fault log"),
+                  (0x02, "FITR", "Filling time record"),
+                  (0x04, "FLTR", "Filters settings"),
+                  (0x08, "CFTP", "Curve fir in progress"),
+                  (0x10, "MSSM", "Missed sample"),
+                  (0x20, "TMPR", "Timed preview"),
+                  (0x40, "ACDA", "Accept date"),
+                  #...
+                  ]

mercurial