Skip to content

Commit 5066994

Browse files
committed
Fixing missing imports, typos, removing unnecessary imports, removing unused variables
1 parent 65cb03e commit 5066994

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

src/pymso5000/fetchmso5000.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from pathlib import Path
55
import numpy as np
66
import matplotlib.pyplot as plt
7-
import datetime
87

98
import argparse
109
import logging
@@ -84,8 +83,8 @@ def loadConfigFile(cfname = ".config/mso5000.cfg"):
8483
cfg = json.load(cfgFile)
8584
except FileNotFoundError:
8685
return None
87-
except JSONDecodeError as e:
88-
print(f"Failed to load configuration file {cfgname}")
86+
except json.JSONDecodeError as e:
87+
print(f"Failed to load configuration file {cfgPath}")
8988
print(e)
9089
sys.exit(1)
9190

@@ -230,14 +229,14 @@ def main():
230229
newmax = np.max(dataDiff[f"y{ich}"])
231230
newmin = np.min(dataDiff[f"y{ich}"])
232231
maxYDval = np.max((newmax, np.abs(newmin), maxYDval))
233-
sfYD, sfYDLabel = getScaleFactorAndPrefix(maxYDval)
232+
sfYD, _ = getScaleFactorAndPrefix(maxYDval)
234233

235234
sfX, sfXLabel = getScaleFactorAndPrefix(np.max(data["x"]))
236235

237236
if args.noautoscale:
238237
sfX, sfXLabel = 1, ""
239238
sfY, sfYLabel = 1, ""
240-
sfYD, sfYDLabel = 1, ""
239+
sfYD, _ = 1, ""
241240

242241
xlabel = "Time "
243242
ylabel = "Signal "

src/pymso5000/mso5000.py

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
from labdevices.exceptions import CommunicationError_ProtocolViolation
2-
from labdevices.exceptions import CommunicationError_Timeout
3-
from labdevices.exceptions import CommunicationError_NotConnected
2+
#from labdevices.exceptions import CommunicationError_Timeout
3+
#from labdevices.exceptions import CommunicationError_NotConnected
44

5-
from labdevices.oscilloscope import Oscilloscope, OscilloscopeSweepMode, OscilloscopeTriggerMode, OscilloscopeTimebaseMode, OscilloscopeRunMode
5+
from labdevices.oscilloscope import Oscilloscope, OscilloscopeSweepMode, OscilloscopeTriggerMode, OscilloscopeTimebaseMode, OscilloscopeRunMode, OscilloscopeCouplingMode
66
from labdevices.scpi import SCPIDeviceEthernet
77
import atexit
88

9-
from time import sleep
10-
11-
import socket
12-
13-
import logging
14-
import datetime
15-
169
class MSO5000(Oscilloscope):
1710
def __init__(
1811
self,
@@ -164,7 +157,7 @@ def _set_sweep_mode(self, mode):
164157
raise ValueError(f"Unknown sweep mode {mode} passed")
165158

166159
def _get_sweep_mode(self):
167-
resp = self._scpi.scpiCommand(f":TRIG:SWE?")
160+
resp = self._scpi.scpiCommand(":TRIG:SWE?")
168161

169162
modes = {
170163
"NORM" : OscilloscopeSweepMode.NORMAL,
@@ -186,7 +179,7 @@ def _set_trigger_mode(self, mode):
186179
self._scpi.scpiCommand(":TRIG:MODE SLOP")
187180

188181
def _get_trigger_mode(self):
189-
resp = self._scpi.scpiQuery(f":TRIG:MODE?")
182+
resp = self._scpi.scpiQuery(":TRIG:MODE?")
190183

191184
modes = {
192185
"EDGE" : OscilloscopeTriggerMode.EDGE,
@@ -232,7 +225,7 @@ def _set_timebase_mode(self, mode):
232225
self._scpi.scpiCommand(f":TIM:MODE {modestr[mode]}")
233226

234227
def _get_timebase_mode(self):
235-
resp = self._scpi.scpiQuery(f":TIM:MODE?")
228+
resp = self._scpi.scpiQuery(":TIM:MODE?")
236229

237230
modes = {
238231
"MAIN" : OscilloscopeTimebaseMode.MAIN,
@@ -441,13 +434,13 @@ def _query_waveform(self, channel, stats = None):
441434
if self._rawMode:
442435
if self._get_run_mode() != OscilloscopeRunMode.STOP:
443436
raise CommunicationError_ProtocolViolation("You must run OscilloscopeRunMode.STOP before capturing in raw mode")
444-
self._scpi.scpiCommand(f":WAV:MODE RAW")
445-
self._scpi.scpiCommand(f":WAV:POIN RAW")
437+
self._scpi.scpiCommand(":WAV:MODE RAW")
438+
self._scpi.scpiCommand(":WAV:POIN RAW")
446439
else:
447-
self._scpi.scpiCommand(f":WAV:MODE NORM")
440+
self._scpi.scpiCommand(":WAV:MODE NORM")
448441
self._scpi.scpiCommand(f":WAV:POIN {self._samplePoints} NORM")
449442
self._scpi.scpiCommand(f":WAV:SOUR CHAN{channel+1}")
450-
self._scpi.scpiCommand(f":WAV:FORM ASCII")
443+
self._scpi.scpiCommand(":WAV:FORM ASCII")
451444
resppre = self._scpi.scpiQuery(":WAV:PRE?")
452445
respdata = self._scpi.scpiQuery(":WAV:DATA?")
453446

@@ -463,14 +456,14 @@ def _query_waveform(self, channel, stats = None):
463456
raise CommunicationError_ProtocolViolation(f"Requested ASCII but received format {pre[0]}")
464457
if (int(pre[1]) != 0) and (int(pre[1]) != 2):
465458
raise CommunicationError_ProtocolViolation(f"Requested Normal(0)/Raw(2) data, but received {pre[1]}")
466-
points = int(pre[2])
467-
avgcount = int(pre[3])
459+
#points = int(pre[2])
460+
#avgcount = int(pre[3])
468461
xinc = float(pre[4])
469462
xorigin = float(pre[5])
470-
xref = float(pre[6])
471-
yinc = float(pre[7])
472-
yorigin = float(pre[8])
473-
yref = float(pre[9])
463+
#xref = float(pre[6])
464+
#yinc = float(pre[7])
465+
#yorigin = float(pre[8])
466+
#yref = float(pre[9])
474467

475468
# Parse data ...
476469
if respdata[0:2] != '#9':

0 commit comments

Comments
 (0)