2020-06-09 15:56:53 +00:00
|
|
|
# NanoVNASaver
|
2020-06-25 17:52:30 +00:00
|
|
|
#
|
2020-06-09 15:56:53 +00:00
|
|
|
# A python program to view and export Touchstone data from a NanoVNA
|
2020-06-25 17:52:30 +00:00
|
|
|
# Copyright (C) 2019, 2020 Rune B. Broberg
|
2021-06-30 05:21:14 +00:00
|
|
|
# Copyright (C) 2020,2021 NanoVNA-Saver Authors
|
2019-08-29 13:10:35 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-09-16 13:47:37 +00:00
|
|
|
import logging
|
2019-08-28 18:20:07 +00:00
|
|
|
|
2020-06-09 15:56:53 +00:00
|
|
|
from PyQt5 import QtWidgets, QtCore
|
2019-08-28 18:20:07 +00:00
|
|
|
|
2020-06-09 15:56:53 +00:00
|
|
|
from NanoVNASaver.Analysis import Analysis, LowPassAnalysis, HighPassAnalysis, \
|
|
|
|
BandPassAnalysis, BandStopAnalysis, VSWRAnalysis, \
|
2020-07-08 13:41:52 +00:00
|
|
|
SimplePeakSearchAnalysis, MagLoopAnalysis
|
2020-12-20 14:42:57 +00:00
|
|
|
from NanoVNASaver.Analysis.VSWRAnalysis import ResonanceAnalysis
|
|
|
|
from NanoVNASaver.Analysis.VSWRAnalysis import EFHWAnalysis
|
|
|
|
from NanoVNASaver.Analysis import PeakSearchAnalysis
|
2019-08-28 18:20:07 +00:00
|
|
|
|
2019-09-16 13:47:37 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2019-09-03 20:04:08 +00:00
|
|
|
|
2019-10-04 10:51:20 +00:00
|
|
|
class AnalysisWindow(QtWidgets.QWidget):
|
|
|
|
analyses = []
|
|
|
|
analysis: Analysis = None
|
|
|
|
|
2020-06-09 15:56:53 +00:00
|
|
|
def __init__(self, app: QtWidgets.QWidget):
|
2019-10-04 10:51:20 +00:00
|
|
|
super().__init__()
|
|
|
|
|
2020-06-09 15:56:53 +00:00
|
|
|
self.app = app
|
2019-10-04 10:51:20 +00:00
|
|
|
self.setWindowTitle("Sweep analysis")
|
|
|
|
self.setWindowIcon(self.app.icon)
|
|
|
|
|
2020-06-09 15:56:53 +00:00
|
|
|
QtWidgets.QShortcut(QtCore.Qt.Key_Escape, self, self.hide)
|
2019-10-04 10:51:20 +00:00
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
select_analysis_box = QtWidgets.QGroupBox("Select analysis")
|
|
|
|
select_analysis_layout = QtWidgets.QFormLayout(select_analysis_box)
|
2019-10-05 13:43:23 +00:00
|
|
|
self.analysis_list = QtWidgets.QComboBox()
|
2020-12-20 14:42:57 +00:00
|
|
|
self.analysis_list.addItem(
|
|
|
|
"Low-pass filter", LowPassAnalysis(self.app))
|
|
|
|
self.analysis_list.addItem(
|
|
|
|
"Band-pass filter", BandPassAnalysis(self.app))
|
|
|
|
self.analysis_list.addItem(
|
|
|
|
"High-pass filter", HighPassAnalysis(self.app))
|
|
|
|
self.analysis_list.addItem(
|
|
|
|
"Band-stop filter", BandStopAnalysis(self.app))
|
2020-12-21 19:48:36 +00:00
|
|
|
self.analysis_list.addItem(
|
|
|
|
"Simple Peak search", SimplePeakSearchAnalysis(self.app))
|
2020-12-20 14:42:57 +00:00
|
|
|
self.analysis_list.addItem(
|
|
|
|
"Peak search", PeakSearchAnalysis(self.app))
|
2019-11-01 11:48:03 +00:00
|
|
|
self.analysis_list.addItem("VSWR analysis", VSWRAnalysis(self.app))
|
2020-12-20 14:42:57 +00:00
|
|
|
self.analysis_list.addItem(
|
|
|
|
"Resonance analysis", ResonanceAnalysis(self.app))
|
|
|
|
self.analysis_list.addItem(
|
|
|
|
"HWEF analysis", EFHWAnalysis(self.app))
|
|
|
|
self.analysis_list.addItem(
|
|
|
|
"MagLoop analysis", MagLoopAnalysis(self.app))
|
2019-10-05 13:43:23 +00:00
|
|
|
select_analysis_layout.addRow("Analysis type", self.analysis_list)
|
|
|
|
self.analysis_list.currentIndexChanged.connect(self.updateSelection)
|
2019-10-04 10:51:20 +00:00
|
|
|
|
|
|
|
btn_run_analysis = QtWidgets.QPushButton("Run analysis")
|
|
|
|
btn_run_analysis.clicked.connect(self.runAnalysis)
|
|
|
|
select_analysis_layout.addRow(btn_run_analysis)
|
|
|
|
|
2020-12-20 14:42:57 +00:00
|
|
|
self.checkbox_run_automatically = QtWidgets.QCheckBox(
|
|
|
|
"Run automatically")
|
|
|
|
self.checkbox_run_automatically.stateChanged.connect(
|
|
|
|
self.toggleAutomaticRun)
|
2019-11-01 15:58:38 +00:00
|
|
|
select_analysis_layout.addRow(self.checkbox_run_automatically)
|
|
|
|
|
2019-10-04 10:51:20 +00:00
|
|
|
analysis_box = QtWidgets.QGroupBox("Analysis")
|
2020-06-09 15:56:53 +00:00
|
|
|
analysis_box.setSizePolicy(
|
|
|
|
QtWidgets.QSizePolicy.MinimumExpanding,
|
|
|
|
QtWidgets.QSizePolicy.MinimumExpanding)
|
2019-10-04 10:51:20 +00:00
|
|
|
|
2019-10-05 13:43:23 +00:00
|
|
|
self.analysis_layout = QtWidgets.QVBoxLayout(analysis_box)
|
2019-11-01 11:48:03 +00:00
|
|
|
self.analysis_layout.setContentsMargins(0, 0, 0, 0)
|
2019-10-05 13:43:23 +00:00
|
|
|
|
2019-10-04 10:51:20 +00:00
|
|
|
layout.addWidget(select_analysis_box)
|
|
|
|
layout.addWidget(analysis_box)
|
|
|
|
|
2019-10-05 15:28:03 +00:00
|
|
|
self.updateSelection()
|
|
|
|
|
2019-10-04 10:51:20 +00:00
|
|
|
def runAnalysis(self):
|
|
|
|
if self.analysis is not None:
|
|
|
|
self.analysis.runAnalysis()
|
2019-10-05 13:43:23 +00:00
|
|
|
|
|
|
|
def updateSelection(self):
|
|
|
|
self.analysis = self.analysis_list.currentData()
|
2019-10-05 15:28:03 +00:00
|
|
|
old_item = self.analysis_layout.itemAt(0)
|
|
|
|
if old_item is not None:
|
|
|
|
old_widget = self.analysis_layout.itemAt(0).widget()
|
2020-12-20 14:42:57 +00:00
|
|
|
self.analysis_layout.replaceWidget(
|
|
|
|
old_widget, self.analysis.widget())
|
2019-10-05 15:28:03 +00:00
|
|
|
old_widget.hide()
|
|
|
|
else:
|
|
|
|
self.analysis_layout.addWidget(self.analysis.widget())
|
2019-10-05 13:43:23 +00:00
|
|
|
self.analysis.widget().show()
|
|
|
|
self.update()
|
2019-10-28 14:17:38 +00:00
|
|
|
|
2019-11-01 15:58:38 +00:00
|
|
|
def toggleAutomaticRun(self, state: QtCore.Qt.CheckState):
|
|
|
|
if state == QtCore.Qt.Checked:
|
|
|
|
self.analysis_list.setDisabled(True)
|
|
|
|
self.app.dataAvailable.connect(self.runAnalysis)
|
|
|
|
else:
|
2019-11-03 11:56:37 +00:00
|
|
|
self.analysis_list.setDisabled(False)
|
2019-11-01 15:58:38 +00:00
|
|
|
self.app.dataAvailable.disconnect(self.runAnalysis)
|