pull/482/head
Holger Müller 2022-03-17 17:54:52 +01:00
rodzic d0dad2a746
commit 630d6fafc3
6 zmienionych plików z 21 dodań i 31 usunięć

Wyświetl plik

@ -115,17 +115,13 @@ def format_complex_adm(z: complex, allow_negative: bool = False) -> str:
return "- S" return "- S"
adm = 1/z adm = 1/z
fmt_re = FMT_COMPLEX fmt_re = FMT_COMPLEX_NEG if allow_negative else FMT_COMPLEX
if allow_negative:
fmt_re = FMT_COMPLEX_NEG
re = SITools.Value(adm.real, fmt=fmt_re) re = SITools.Value(adm.real, fmt=fmt_re)
im = SITools.Value(abs(adm.imag), fmt=FMT_COMPLEX) im = SITools.Value(abs(adm.imag), fmt=FMT_COMPLEX)
return f"{re}{'-' if adm.imag < 0 else '+'}j{im} S" return f"{re}{'-' if adm.imag < 0 else '+'}j{im} S"
def format_complex_imp(z: complex, allow_negative: bool = False) -> str: def format_complex_imp(z: complex, allow_negative: bool = False) -> str:
fmt_re = FMT_COMPLEX fmt_re = FMT_COMPLEX_NEG if allow_negative else FMT_COMPLEX
if allow_negative:
fmt_re = FMT_COMPLEX_NEG
re = SITools.Value(z.real, fmt=fmt_re) re = SITools.Value(z.real, fmt=fmt_re)
im = SITools.Value(abs(z.imag), fmt=FMT_COMPLEX) im = SITools.Value(abs(z.imag), fmt=FMT_COMPLEX)
return f"{re}{'-' if z.imag < 0 else '+'}j{im} ""\N{OHM SIGN}" return f"{re}{'-' if z.imag < 0 else '+'}j{im} ""\N{OHM SIGN}"

Wyświetl plik

@ -114,11 +114,5 @@ class TinySA(VNA):
def readValues(self, value) -> List[str]: def readValues(self, value) -> List[str]:
logger.debug("Read: %s", value) logger.debug("Read: %s", value)
if value == "data 0": if value == "data 0":
self._sweepdata = [] self._sweepdata = [f"0 {line.strip()}" for line in self.exec_command("data")]
for line in self.exec_command("data"):
self._sweepdata.append(f"0 {line.strip()}")
return self._sweepdata return self._sweepdata
if value == "data 0":
return [x[0] for x in self._sweepdata]
if value == "data 1":
return [x[0] for x in self._sweepdata]

Wyświetl plik

@ -141,9 +141,8 @@ class VNA:
return [1000, ] return [1000, ]
def set_bandwidth(self, bandwidth: int): def set_bandwidth(self, bandwidth: int):
bw_val = bandwidth bw_val = DISLORD_BW[bandwidth] \
if self.bw_method == "dislord": if self.bw_method == "dislord" else bandwidth
bw_val = DISLORD_BW[bandwidth]
result = " ".join(self.exec_command(f"bandwidth {bw_val}")) result = " ".join(self.exec_command(f"bandwidth {bw_val}"))
if self.bw_method == "ttrftech" and result: if self.bw_method == "ttrftech" and result:
raise IOError(f"set_bandwith({bandwidth}: {result}") raise IOError(f"set_bandwith({bandwidth}: {result}")

Wyświetl plik

@ -62,10 +62,10 @@ class BandsModel(QtCore.QAbstractTableModel):
self.settings.setIniCodec("UTF-8") self.settings.setIniCodec("UTF-8")
self.enabled = self.settings.value("ShowBands", False, bool) self.enabled = self.settings.value("ShowBands", False, bool)
self.bands = [] self.bands = [
band.split(";")
for band in self.settings.value("bands", _DEFAULT_BANDS): for band in self.settings.value("bands", _DEFAULT_BANDS)
self.bands.append(band.split(";")) ]
def saveSettings(self): def saveSettings(self):
self.settings.setValue( self.settings.setValue(
@ -74,9 +74,7 @@ class BandsModel(QtCore.QAbstractTableModel):
self.settings.sync() self.settings.sync()
def resetBands(self): def resetBands(self):
self.bands = [] self.bands = [band.split(";") for band in _DEFAULT_BANDS]
for band in _DEFAULT_BANDS:
self.bands.append(band.split(";"))
self.layoutChanged.emit() self.layoutChanged.emit()
self.saveSettings() self.saveSettings()
@ -87,8 +85,9 @@ class BandsModel(QtCore.QAbstractTableModel):
return len(self.bands) return len(self.bands)
def data(self, index: QModelIndex, role: int = ...) -> QtCore.QVariant: def data(self, index: QModelIndex, role: int = ...) -> QtCore.QVariant:
if (role == QtCore.Qt.DisplayRole or if role in [
role == QtCore.Qt.ItemDataRole or role == QtCore.Qt.EditRole): QtCore.Qt.DisplayRole, QtCore.Qt.ItemDataRole, QtCore.Qt.EditRole,
]:
return QtCore.QVariant(self.bands[index.row()][index.column()]) return QtCore.QVariant(self.bands[index.row()][index.column()])
if role == QtCore.Qt.TextAlignmentRole: if role == QtCore.Qt.TextAlignmentRole:
if index.column() == 0: if index.column() == 0:

Wyświetl plik

@ -85,11 +85,13 @@ class Sweep():
return round(self.span / (self.points * self.segments - 1)) return round(self.span / (self.points * self.segments - 1))
def check(self): def check(self):
if not(self.segments > 0 and if (
self.points > 0 and self.segments <= 0
self.start > 0 and or self.points <= 0
self.end > 0 and or self.start <= 0
self.stepsize >= 1): or self.end <= 0
or self.stepsize < 1
):
raise ValueError(f"Illegal sweep settings: {self}") raise ValueError(f"Illegal sweep settings: {self}")
def _exp_factor(self, index: int) -> float: def _exp_factor(self, index: int) -> float:

Wyświetl plik

@ -154,7 +154,7 @@ class AboutWindow(QtWidgets.QWidget):
latest_url = "" latest_url = ""
try: try:
req = request.Request(VERSION_URL) req = request.Request(VERSION_URL)
req.add_header('User-Agent', "NanoVNA-Saver/" + self.app.version) req.add_header('User-Agent', f'NanoVNA-Saver/{self.app.version}')
for line in request.urlopen(req, timeout=3): for line in request.urlopen(req, timeout=3):
line = line.decode("utf-8") line = line.decode("utf-8")
if line.startswith("VERSION ="): if line.startswith("VERSION ="):