kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Sweep code updates
rodzic
06b379afb4
commit
b178301435
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
VERSION = "0.3.7-pre04"
|
||||
VERSION = "0.3.7-pre05"
|
||||
VERSION_URL = (
|
||||
"https://raw.githubusercontent.com/"
|
||||
"NanoVNA-Saver/nanovna-saver/master/NanoVNASaver/About.py")
|
||||
|
|
|
@ -179,6 +179,7 @@ class SweepControl(QtWidgets.QGroupBox):
|
|||
return
|
||||
self.input_span.setText(fspan)
|
||||
self.input_center.setText(fcenter)
|
||||
self.update_sweep()
|
||||
|
||||
def update_start_end(self):
|
||||
fcenter = self.get_center()
|
||||
|
@ -191,9 +192,7 @@ class SweepControl(QtWidgets.QGroupBox):
|
|||
return
|
||||
self.input_start.setText(fstart)
|
||||
self.input_end.setText(fstop)
|
||||
with self.app.sweep.lock:
|
||||
self.app.sweep.start = parse_frequency(fstart)
|
||||
self.app.sweep.end = parse_frequency(fstop)
|
||||
self.update_sweep()
|
||||
|
||||
def update_step_size(self):
|
||||
fspan = self.get_span()
|
||||
|
@ -204,6 +203,12 @@ class SweepControl(QtWidgets.QGroupBox):
|
|||
fstep = fspan / (segments * self.app.vna.datapoints - 1)
|
||||
self.label_step.setText(
|
||||
f"{format_frequency_short(fstep)}/step")
|
||||
with self.app.sweep.lock:
|
||||
self.app.sweep.points = self.app.vna.datapoints
|
||||
self.app.sweep.segments = segments
|
||||
self.update_sweep()
|
||||
|
||||
def update_sweep(self):
|
||||
sweep = self.app.sweep
|
||||
with sweep.lock:
|
||||
sweep.start = self.get_start()
|
||||
sweep.end = self.get_end()
|
||||
sweep.points = self.app.vna.datapoints
|
||||
sweep.segments = self.get_segments()
|
||||
|
|
|
@ -292,13 +292,13 @@ class Marker(QtCore.QObject, Value):
|
|||
self.location = round(len(s11data) / 2)
|
||||
else:
|
||||
self.location = 0
|
||||
self.frequencyInput.setText(s11data[self.location].freq)
|
||||
try:
|
||||
s11 = s11data[self.location]
|
||||
except IndexError:
|
||||
self.location = 0
|
||||
return
|
||||
|
||||
self.frequencyInput.setText(s11.freq)
|
||||
self.store(self.location, s11data, s21data)
|
||||
|
||||
imp = s11.impedance()
|
||||
|
|
|
@ -72,6 +72,10 @@ class Sweep():
|
|||
self.segments == other.segments and
|
||||
self.properties == other.properties)
|
||||
|
||||
def copy(self) -> 'Sweep':
|
||||
return Sweep(self.start, self.end, self.points, self.segments,
|
||||
self.properties)
|
||||
|
||||
@property
|
||||
def span(self) -> int:
|
||||
return self.end - self.start
|
||||
|
|
|
@ -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 copy import copy
|
||||
from time import sleep
|
||||
from typing import List, Tuple
|
||||
|
||||
|
@ -97,7 +96,8 @@ class SweepWorker(QtCore.QRunnable):
|
|||
return
|
||||
|
||||
with self.app.sweep.lock:
|
||||
sweep = copy(self.app.sweep)
|
||||
sweep = self.app.sweep.copy()
|
||||
|
||||
averages = 1
|
||||
if sweep.properties.mode == SweepMode.AVERAGE:
|
||||
averages = sweep.properties.averages[0]
|
||||
|
@ -109,18 +109,18 @@ class SweepWorker(QtCore.QRunnable):
|
|||
|
||||
finished = False
|
||||
while not finished:
|
||||
for i in range(self.sweep.segments):
|
||||
for i in range(sweep.segments):
|
||||
logger.debug("Sweep segment no %d", i)
|
||||
if self.stopped:
|
||||
logger.debug("Stopping sweeping as signalled")
|
||||
finished = True
|
||||
break
|
||||
start, stop = self.sweep.get_index_range(i)
|
||||
start, stop = sweep.get_index_range(i)
|
||||
|
||||
try:
|
||||
freq, values11, values21 = self.readAveragedSegment(
|
||||
start, stop, averages)
|
||||
self.percentage = (i + 1) * 100 / self.sweep.segments
|
||||
self.percentage = (i + 1) * 100 / sweep.segments
|
||||
self.updateData(freq, values11, values21, i)
|
||||
except ValueError as e:
|
||||
self.error_message = str(e)
|
||||
|
@ -131,9 +131,9 @@ class SweepWorker(QtCore.QRunnable):
|
|||
if not sweep.properties.mode == SweepMode.CONTINOUS:
|
||||
finished = True
|
||||
|
||||
if self.sweep.segments > 1:
|
||||
start = self.app.sweep_control.get_start()
|
||||
end = self.app.sweep_control.get_end()
|
||||
if sweep.segments > 1:
|
||||
start = sweep.start
|
||||
end = sweep.end
|
||||
logger.debug("Resetting NanoVNA sweep to full range: %d to %d",
|
||||
start, end)
|
||||
self.app.vna.resetSweep(start, end)
|
||||
|
|
Ładowanie…
Reference in New Issue