Skip to content

Commit

Permalink
Test suite and BFs for TekDPO70000 (#256)
Browse files Browse the repository at this point in the history
* Test suite and BFs for TekDPO70000

**Bug Fixes**:
- Two properties were called as `unitful_property` instead of
  `enum_property`. As the "unit", an enum was given. Seems to be a
  copy&paste error.
- The second of these properties also had the wrong enum specified.
  Swapped out for correct enum.
- Double checked all fixes with manual.

**Test suite**:
- Full, and likely overkill, test suite added (needs discussion).
- One test that is intentionally skipped added for binary waveform
  reading (needs discussion).
- Full coverage not achieved.

* Remove `if self._testing` to skip `time.sleep` in tests, replace w/ mock

Also assert that time.sleep is called in the main routine, since it is
required by the instrument.

* Change TekDPO70000 to always read termination character after waveform

The loopback communicator used in testing does not flush the input,
thus a termination character is stuck in the queue that does not get
read. According to the manual, a `<newline>` character is always sent
after transmitting the waveform.
Flushing the input is now simplified and includes a `read_raw` for one
character. This takes care of proper testing. Tests were adjusted
accordingly.

* Removed unnecessary `@pytest.mark.parametrize` statements for channels

Testing of all channels is not necessary for property factories and
should be shifted to their tests.
Test suites still checks that `sendcmd` and `query` are working
properly for all parametrized scenarios.
  • Loading branch information
trappitsch committed Sep 8, 2020
1 parent f10497d commit e2c9bfb
Show file tree
Hide file tree
Showing 2 changed files with 1,933 additions and 11 deletions.
17 changes: 6 additions & 11 deletions instruments/tektronix/tekdpo70000.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,8 @@ def read_waveform(self, bin_format=True):
)
self._parent.sendcmd("CURV?")
raw = self._parent.binblockread(n_bytes, fmt=dtype)
# Clear the queue by trying to read.
# FIXME: this is a hack-y way of doing so.
if hasattr(self._parent._file, 'flush_input'):
self._parent._file.flush_input()
else:
self._parent._file.read()
# Clear the queue by reading the end of line character
self._parent._file.read_raw(1)

return self._scale_raw_data(raw)

Expand Down Expand Up @@ -372,17 +368,17 @@ class SpectralWindow(Enum):
inst_false="OFF"
)

spectral_mag = unitful_property(
spectral_mag = enum_property(
"SPEC:MAG",
Mag,
doc="""
Whether the spectral magnitude is linear, db, or dbm.
"""
)

spectral_phase = unitful_property(
spectral_phase = enum_property(
"SPEC:PHASE",
Mag,
Phase,
doc="""
Whether the spectral phase is degrees, radians, or group delay.
"""
Expand Down Expand Up @@ -799,8 +795,7 @@ def data_source(self, newval):

# Some Tek scopes require this after the DAT:SOU command, or else
# they will stop responding.
if not self._testing:
time.sleep(0.02)
time.sleep(0.02)

horiz_acq_duration = unitful_property(
'HOR:ACQDURATION',
Expand Down

0 comments on commit e2c9bfb

Please sign in to comment.