- Show clearer that a calibration is loaded

- Real/imaginary chart updates
- Setting default frequencies if span on startup is 0
pull/23/head
Rune B. Broberg 2019-09-22 21:19:08 +02:00
rodzic 44fd87c7d6
commit 65d03dd36a
4 zmienionych plików z 29 dodań i 17 usunięć

Wyświetl plik

@ -231,12 +231,12 @@ class CalibrationWindow(QtWidgets.QWidget):
def loadFile(self, filename):
self.app.calibration.loadCalibration(filename)
if self.app.calibration.isValid1Port():
self.cal_short_label.setText("Calibrated")
self.cal_open_label.setText("Calibrated")
self.cal_load_label.setText("Calibrated")
self.cal_short_label.setText("Loaded (" + str(len(self.app.calibration.s11short)) + ")")
self.cal_open_label.setText("Loaded (" + str(len(self.app.calibration.s11open)) + ")")
self.cal_load_label.setText("Loaded (" + str(len(self.app.calibration.s11load)) + ")")
if self.app.calibration.isValid2Port():
self.cal_through_label.setText("Calibrated")
self.cal_isolation_label.setText("Calibrated")
self.cal_through_label.setText("Loaded (" + str(len(self.app.calibration.s21through)) + ")")
self.cal_isolation_label.setText("Loaded (" + str(len(self.app.calibration.s21isolation)) + ")")
self.calculate()
self.app.settings.setValue("CalibrationFile", filename)

Wyświetl plik

@ -1145,8 +1145,8 @@ class TDRChart(Chart):
class RealImaginaryChart(Chart):
def __init__(self, name=""):
super().__init__(name)
self.leftMargin = 35
self.rightMargin = 35
self.leftMargin = 45
self.rightMargin = 45
self.chartWidth = 230
self.chartHeight = 250
self.fstart = 0
@ -1231,11 +1231,16 @@ class RealImaginaryChart(Chart):
if im < min_imag:
min_imag = im
max_real = math.ceil(max_real)
max_real = max(8, math.ceil(max_real)) # Always have at least 8 numbered horizontal lines
min_real = max(0, math.floor(min_real)) # Negative real resistance? No.
max_imag = math.ceil(max_imag)
min_imag = math.floor(min_imag)
if max_imag - min_imag < 8:
missing = 8 - (max_imag - min_imag)
max_imag += math.ceil(missing/2)
min_imag -= math.floor(missing/2)
self.max_real = max_real
self.max_imag = max_imag
@ -1254,13 +1259,13 @@ class RealImaginaryChart(Chart):
qp.setPen(QtGui.QPen(self.foregroundColor))
qp.drawLine(self.leftMargin - 5, y, self.leftMargin + self.chartWidth + 5, y)
qp.setPen(QtGui.QPen(self.textColor))
re = max_real - round(i * span_real / horizontal_ticks)
im = max_imag - round(i * span_imag / horizontal_ticks)
qp.drawText(3, y + 4, str(re))
qp.drawText(self.leftMargin + self.chartWidth + 8, y + 4, str(im))
re = max_real - i * span_real / horizontal_ticks
im = max_imag - i * span_imag / horizontal_ticks
qp.drawText(3, y + 4, str(round(re, 1)))
qp.drawText(self.leftMargin + self.chartWidth + 8, y + 4, str(round(im, 1)))
qp.drawText(3, self.chartHeight + 20, str(min_real))
qp.drawText(self.leftMargin + self.chartWidth + 8, self.chartHeight + 20, str(min_imag))
qp.drawText(3, self.chartHeight + 20, str(round(min_real, 1)))
qp.drawText(self.leftMargin + self.chartWidth + 8, self.chartHeight + 20, str(round(min_imag, 1)))
qp.drawText(self.leftMargin-20, 20 + self.chartHeight + 15, LogMagChart.shortenFrequency(fstart))
ticks = math.floor(self.chartWidth/100) # Number of ticks does not include the origin

Wyświetl plik

@ -586,8 +586,12 @@ class NanoVNASaver(QtWidgets.QWidget):
frequencies = self.readValues("frequencies")
logger.info("Read starting frequency %s and end frequency %s", frequencies[0], frequencies[100])
self.sweepStartInput.setText(str(frequencies[0]))
self.sweepEndInput.setText(str(frequencies[100]))
if int(frequencies[0]) == int(frequencies[100]) and (self.sweepStartInput.text() == "" or self.sweepEndInput.text() == ""):
self.sweepStartInput.setText(frequencies[0])
self.sweepEndInput.setText(str(int(frequencies[100]) + 100000))
elif self.sweepStartInput.text() == "" or self.sweepEndInput.text() == "":
self.sweepStartInput.setText(frequencies[0])
self.sweepEndInput.setText(frequencies[100])
logger.debug("Starting initial sweep")
self.sweep()
@ -965,6 +969,9 @@ class NanoVNASaver(QtWidgets.QWidget):
self.tdr_window.show()
QtWidgets.QApplication.setActiveWindow(self.tdr_window)
def showError(self, text):
QtWidgets.QErrorMessage.showMessage(text)
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
self.worker.stopped = True
self.settings.setValue("Marker1Color", self.markers[0].color)

Wyświetl plik

@ -78,7 +78,7 @@ class SweepWorker(QtCore.QRunnable):
sweep_from = NanoVNASaver.parseFrequency(self.app.sweepStartInput.text())
sweep_to = NanoVNASaver.parseFrequency(self.app.sweepEndInput.text())
logger.debug("Parsed sweep range as %d to %d", sweep_from, sweep_to)
if sweep_from < 0 or sweep_to < 0:
if sweep_from < 0 or sweep_to < 0 or sweep_from == sweep_to:
logger.warning("Can't sweep from %s to %s",
self.app.sweepStartInput.text(),
self.app.sweepEndInput.text())