Synchronizing Acquisitions 42
Keysight InfiniiVision 4000 X-Series Oscilloscopes Programmer's Guide 1603
# can reflect states for other oscilloscope properties, for
# example, if the oscilloscope is armed, thus it can produce
# values other than 0 (stopped) or 8 (running).
#
# To handle that, the result of :OPERation:Condition? is bitwise
# ANDed (& in Python) with an 8. This is called "unmasking".
#
# Here, the "unmasking" is done in the script. On the other
# hand, it is possible to "mask" which bits get passed to the
# summary bit to the next register below on the instrument
# itself. However, this method it typically only used when
# working with the Status Byte, and not used here.
#
# - Why 8 = running = not done?
#
# The Run bit is the 4th bit of the Operation Status Condition
# (and Event) Registers.
#
# The registers are binary and start counting at zero, thus the
# 4th bit is bit number 3, and 2^3 = 8, and thus it returns an
# 8 for high and a 0 for low.
#
# - Why the CONDITION and NOT the EVENT register?
#
# The Condition register reflects the CURRENT state, while the
# EVENT register reflects the first event that occurred since it
# was cleared or read (as in: has it EVER happened?), thus the
# CONDITION register is used.
#
# Note that with this method using :SINGle, for InfiniiVision
# X-Series oscilloscopes only, :SINGle itself forces the trigger
# sweep mode into NORMal. This does not happen with the blocking
# method, using :DIGitize, or on the InfiniiVision notXs.
# ====================================================================
def polling_method():
MAX_TIME_TO_WAIT = SCOPE_ACQUISITION_TIME_OUT/float(1000)
# Time in seconds to wait for the oscilloscope to arm, trigger,
# and finish acquisition.
#
# Note that this is NOT a property of the device interface,
# KsInfiniiVisionX, but rather some constant in the script to be
# used later with the Python module "time", and will be used with
# time.clock().
# Define "mask" bits.
#
# Mask condition for Run state in the Operation Status Condition
# (and Event) Register.
#
# Refer to Programmer's Guide chapters on Status Reporting and
# Synchronizing Acquisitions.
RUN_BIT = 3
# The run bit is the 4th bit (see next set of comments @
# Completion Criteria).
RUN_MASK = 1<<RUN_BIT
# This basically means: 2^3 = 8, or rather, in Python 2**3