Tue, 19 Aug 2008 23:01:19 +0200
fixes to make gpib_detect works
--- a/bin/gpib_detect Tue Aug 19 22:47:16 2008 +0200 +++ b/bin/gpib_detect Tue Aug 19 23:01:19 2008 +0200 @@ -9,6 +9,7 @@ except ImportError: sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) from pygpibtoolkit.gpibcontroller import GPIBController +import pygpibtoolkit.HP3562A def main(): import optparse
--- a/pygpibtoolkit/HP3562A/HP356X.py Tue Aug 19 22:47:16 2008 +0200 +++ b/pygpibtoolkit/HP3562A/HP356X.py Tue Aug 19 23:01:19 2008 +0200 @@ -1,5 +1,6 @@ # from pygpibtoolkit.pygpib import Constants, Command +from pygpibtoolkit.pygpib import Condition from pygpibtoolkit.pygpib import BoolValue, IntValue, FloatValue from pygpibtoolkit.pygpib import PercentageValue, FrequencyValue, DurationValue from pygpibtoolkit.pygpib import VoltageValue @@ -130,7 +131,7 @@ class AverageMode(Mode): "Average mode" - _condition = LinRes | LogRes | TimeCaptur + _condition = LinRes() | LogRes() | TimeCaptur() _key = "EAVGTYP" _DATA_BLOCK = "DSBN" @@ -142,11 +143,11 @@ class TIAV(BoolValue): "TIM AV ON OFF - Time average" - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class OVLP(PercentageValue): "OVRLP% - Overlap (%)" - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class AUTO(BoolValue): "AUTO ON OFF - Auto calibration" @@ -179,27 +180,27 @@ class CF(FrequencyValue): "CENTER FREQ - Center freq." _units = "hz","khz","mhz","ord","rmp" - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class ZST(Command): "ZERO START - Zero start" - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class MAXS(FrequencyValue): "MAX SPAN - Max span" - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class TLN(DurationValue): "TIME LENGTH - Time len." - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class ESMP(BoolValue): "E SMPL ON OFF - E sample" - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class SMPF(FrequencyValue): "SAMPLE FREQ - Sample freq." - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() class SPF(FrequencyValue): "STOP FREQ - Stop freq." @@ -256,14 +257,18 @@ CPTR = ModeCommand(3, "TIME CAPTUR") # MEAS DISP +class FreqResp(Condition): + def __call__(self, device): + return device.SelectMeas == "FREQ RESP" + class MeasDisp(Mode): # TODO - FRQR = ModeCommand(0, "FREQ RESP", condition=(LinRes | LogRes) & FreqResp | SweptSine) - COHR = ModeCommand(0, "COHER", condition=(LinRes | LogRes) & FreqResp | SweptSine) - PSP1 = ModeCommand(0, "POWER SPEC1", condition=(LinRes | LogRes) & FreqResp | SweptSine) - PSP2 = ModeCommand(0, "POWER SPEC2", condition=(LinRes | LogRes) & FreqResp | SweptSine) - CSPS = ModeCommand(0, "CROSS SPEC", condition=(LinRes | LogRes) & FreqResp | SweptSine) - IRSP = ModeCommand(0, "IMPLS RESP", condition=LinRes & FreqResp) + FRQR = ModeCommand(0, "FREQ RESP", condition=(LinRes() | LogRes()) & FreqResp() | SweptSine()) + COHR = ModeCommand(0, "COHER", condition=(LinRes() | LogRes()) & FreqResp() | SweptSine()) + PSP1 = ModeCommand(0, "POWER SPEC1", condition=(LinRes() | LogRes()) & FreqResp() | SweptSine()) + PSP2 = ModeCommand(0, "POWER SPEC2", condition=(LinRes() | LogRes()) & FreqResp() | SweptSine()) + CSPS = ModeCommand(0, "CROSS SPEC", condition=(LinRes() | LogRes()) & FreqResp() | SweptSine()) + IRSP = ModeCommand(0, "IMPLS RESP", condition=LinRes() & FreqResp()) AUMT = ModeCommand(0, "AUTO MATH", ) FILT = ModeCommand(0, "FILTRD INPUT") @@ -272,9 +277,6 @@ LSP1 = ModeCommand(0, "LINEAR SPEC1", condition=TimeCaptur) LSP2 = ModeCommand(0, "LINEAR SPEC2", condition=TimeCaptur) -class FreqResp(Condition): - def __call__(self, device): - return device.SelectMeas == "FREQ RESP" class PowerSpec(Condition): def __call__(self, device): @@ -299,24 +301,24 @@ "Select measurement" _key = "EMTYP" _DATA_BLOCK = "DSBN" - _condition = LinRes | TimeCaptur | SweptSine + _condition = LinRes() | TimeCaptur() | SweptSine() - FRSP = ModeCommand(0, "FREQ RESP", condition=LinRes | LogRes | SweptSine) - PSPC = ModeCommand(2, "POWER SPEC", condition=LinRes | LogRes | TimeCaptur) - AUCR = ModeCommand(3, "AUTO CORR", condition=LinRes | TimeCaptur) - CCOR = ModeCommand(1, "CROSS CORR", condition=LinRes) - HIST = ModeCommand(4, "HIST", condition=LinRes | TimeCaptur) + FRSP = ModeCommand(0, "FREQ RESP", condition=LinRes() | LogRes() | SweptSine()) + PSPC = ModeCommand(2, "POWER SPEC", condition=LinRes() | LogRes() | TimeCaptur()) + AUCR = ModeCommand(3, "AUTO CORR", condition=LinRes() | TimeCaptur()) + CCOR = ModeCommand(1, "CROSS CORR", condition=LinRes()) + HIST = ModeCommand(4, "HIST", condition=LinRes() | TimeCaptur()) class Channel(Mode): "" _key = "ECH" _DATA_BLOCK = "DDBN" # XXX sure? CH12 = ModeCommand("Channel 1&2 active", "CH 1&2 ACTIVE", - condition=LinRes | LogRes) + condition=LinRes() | LogRes()) CH1 = ModeCommand("Channel 1 active", "CH 1 ACTIVE", - condition=LinRes | LogRes | TimeCaptur) + condition=LinRes() | LogRes() | TimeCaptur()) CH2 = ModeCommand("Channel 2 active", "CH 2 ACTIVE", - condition=LinRes | LogRes | TimeCaptur) + condition=LinRes() | LogRes() | TimeCaptur()) class REV(StringValue): _readonly = True
--- a/pygpibtoolkit/HP3562A/__init__.py Tue Aug 19 22:47:16 2008 +0200 +++ b/pygpibtoolkit/HP3562A/__init__.py Tue Aug 19 23:01:19 2008 +0200 @@ -13,7 +13,7 @@ --------- """ - +import HP356X
--- a/pygpibtoolkit/pygpib.py Tue Aug 19 22:47:16 2008 +0200 +++ b/pygpibtoolkit/pygpib.py Tue Aug 19 23:01:19 2008 +0200 @@ -6,6 +6,7 @@ from serial.serialutil import SerialException import time from pygpibtoolkit.tools import AbstractRegister +import operator class ConnectionError(Exception): pass @@ -22,7 +23,7 @@ class _ComposedCondition(Condition): def __init__(self, op, *args): - self._conditions = args[:] + self._conditions = list(args[:]) self._reduc_op = op for cond in args: assert isinstance(cond, Condition)