Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions oscope_scpi/keysight.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ def _waveformDataNew(self, channel, points=None):
# Create array for meta data
meta = []

# Set the waveform source.
self._instWrite("WAVeform:SOURce {}".format(self.channelStr(channel)))
wav_source = self._instQuery("WAVeform:SOURce?")

# Get the waveform view.
Expand Down Expand Up @@ -603,8 +601,6 @@ def _waveformDataLegacy(self, channel, points=None):
# Create array for meta data
meta = []

# Set the waveform source.
self._instWrite("WAVeform:SOURce {}".format(self.channelStr(channel)))
wav_source = self._instQuery("WAVeform:SOURce?")

# Get the waveform view.
Expand Down Expand Up @@ -770,7 +766,7 @@ def _waveformDataLegacy(self, channel, points=None):
def waveformData(self, channel=None, points=None):
""" Download waveform data of a selected channel

channel - channel, as string, to be measured - set to None to use the default channel
channel - channel to be measured - set to None to use the default channel

points - number of points to capture - if None, captures all available points
for newer devices, the captured points are centered around the center of the display
Expand All @@ -786,15 +782,23 @@ def waveformData(self, channel=None, points=None):
if type(self.channel) is list or type(channel) is list:
raise ValueError('Channel cannot be a list for WAVEFORM!')

chan_str = self.channelStr(self.channel)
# Check channel value
if (self.channel not in self.chanAllValidList):
raise ValueError('INVALID Channel Value for WAVEFORM: {} SKIPPING!'.format(self.channel))
if (chan_str not in self.chanAllValidList):
raise ValueError('INVALID Channel Value for WAVEFORM: {} SKIPPING!'.format(chan_str))

# Set the waveform source.
self._instWrite("WAVeform:SOURce {}".format(chan_str))

# Check for data
complete = int(self._instQuery('WAVeform:COMPlete?')) # get percent complete
if complete == 0:
raise BufferError('No waveform data')

if (self._version > self._versionLegacy):
(x, y, header, meta) = self._waveformDataNew(self.channel, points)
(x, y, header, meta) = self._waveformDataNew(chan_str, points)
else:
(x, y, header, meta) = self._waveformDataLegacy(self.channel, points)
(x, y, header, meta) = self._waveformDataLegacy(chan_str, points)

return (x, y, header, meta)

Expand Down