Added connected() method to VNA class

pull/226/head
Holger Müller 2020-07-05 13:00:03 +02:00
rodzic 764a9aaa0b
commit cd9b4da1af
6 zmienionych plików z 12 dodań i 11 usunięć

Wyświetl plik

@ -17,7 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
from logging import log
import struct
from time import sleep
from typing import List
@ -80,7 +79,7 @@ class NanoVNA(VNA):
def getScreenshot(self) -> QtGui.QPixmap:
logger.debug("Capturing screenshot...")
if not self.serial.is_open:
if not self.connected():
return QtGui.QPixmap()
try:
rgba_array = self._capture_data()

Wyświetl plik

@ -17,7 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
import struct
import serial
import numpy as np
@ -35,7 +34,7 @@ class NanoVNA_F(NanoVNA):
def getScreenshot(self) -> QtGui.QPixmap:
logger.debug("Capturing screenshot...")
if not self.serial.is_open:
if not self.connected():
return QtGui.QPixmap()
try:
rgba_array = self._capture_data()

Wyświetl plik

@ -62,12 +62,15 @@ class VNA:
def isValid(self):
return False
def connected(self) -> bool:
return self.serial.is_open
def getFeatures(self) -> List[str]:
return self.features
def getCalibration(self) -> str:
logger.debug("Reading calibration info.")
if not self.serial.is_open:
if not self.connected():
return "Not connected."
with self.serial.lock:
try:
@ -154,7 +157,7 @@ class VNA:
def readVersion(self) -> str:
logger.debug("Reading version info.")
if not self.serial.is_open:
if not self.connected():
return ""
try:
with self.serial.lock:
@ -174,7 +177,7 @@ class VNA:
return ""
def writeSerial(self, command):
if not self.serial.is_open:
if not self.connected():
logger.warning("Writing without serial port being opened (%s)",
command)
return

Wyświetl plik

@ -597,7 +597,7 @@ class NanoVNASaver(QtWidgets.QWidget):
return
def serialButtonClick(self):
if not self.interface.is_open:
if not self.vna.connected():
self.connect_device()
else:
self.disconnect_device()
@ -664,7 +664,7 @@ class NanoVNASaver(QtWidgets.QWidget):
def sweep(self):
# Run the device data update
if not self.interface.is_open:
if not self.vna.connected():
return
self.worker.stopped = False

Wyświetl plik

@ -83,7 +83,7 @@ class SweepWorker(QtCore.QRunnable):
logger.info("Initializing SweepWorker")
self.running = True
self.percentage = 0
if not self.app.interface.is_open:
if not self.app.vna.connected():
logger.debug(
"Attempted to run without being connected to the NanoVNA")
self.running = False

Wyświetl plik

@ -633,7 +633,7 @@ class CalibrationWindow(QtWidgets.QWidget):
self.btn_automatic.setDisabled(False)
return
logger.info("Starting automatic calibration assistant.")
if not self.app.serial.is_open:
if not self.app.vna.connected():
QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Information,
"NanoVNA not connected",