now magloopanalysis set and run new sweep

to center minimum
pull/386/head
Mauro Gaioni 2021-04-05 13:36:59 +02:00
rodzic 503af5ff84
commit 3200c1b445
1 zmienionych plików z 34 dodań i 11 usunięć

Wyświetl plik

@ -15,6 +15,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from PyQt5.Qt import QTimer
'''
Created on May 30th 2020
@ -57,11 +60,12 @@ class MagLoopAnalysis(VSWRAnalysis):
if self.min_freq is None:
self.min_freq = new_start
self.max_freq = new_end
print (f"limiti {self.min_freq}- {self.max_freq} ")
logger.debug("setting hard limits to %s - %s",
self.min_freq, self.max_freq)
if len(self.minimums) > 1:
self.layout.addRow("", QtWidgets.QLabel(
"Not magloop or try to lower VSWR limit"))
"Multiple minimums, not magloop or try to lower VSWR limit"))
return
elif len(self.minimums) == 1:
m = self.minimums[0]
@ -75,31 +79,50 @@ class MagLoopAnalysis(VSWRAnalysis):
"Q", QtWidgets.QLabel("{}".format(int(Q))))
new_start = self.app.data11[start].freq - self.bandwith
new_end = self.app.data11[end].freq + self.bandwith
logger.debug("Single Spot, new scan on %s-%s",
new_start, new_end)
else:
new_start = self.app.data11[start].freq - 2 * self.bandwith
new_end = self.app.data11[end].freq + 2 * self.bandwith
logger.debug(" Zoom to %s-%s", new_start, new_end)
if self.vswr_limit_value > self.vswr_bandwith_value:
self.vswr_limit_value = max(
self.vswr_bandwith_value, self.vswr_limit_value - 2)
self.vswr_bandwith_value, self.vswr_limit_value - 1)
self.input_vswr_limit.setValue(self.vswr_limit_value)
logger.debug(
"found higher minimum, lowering vswr search to %s", self.vswr_limit_value)
else:
new_start = new_start - 5 * self.bandwith
new_end = new_end + 5 * self.bandwith
if all((new_start <= self.min_freq,
new_end >= self.max_freq)):
if self.vswr_limit_value < 10:
print(f"aumento limite a {self.vswr_limit_value}")
self.vswr_limit_value += 2
self.input_vswr_limit.setValue(self.vswr_limit_value)
print(f"aumento limite a {self.vswr_limit_value}")
print("start è ", self.app.sweep_control.get_start())
logger.debug(
"no minimum found, looking for higher value %s", self.vswr_limit_value)
new_start = max(self.min_freq, new_start)
new_end = min(self.max_freq, new_end)
print(f"nuova analisi limitata {new_start} {new_end}")
logger.debug("next search will be %s - %s for vswr %s",
new_start,
new_end,
self.vswr_limit_value)
self.app.sweep_control.set_start(new_start)
self.app.sweep_control.set_end(new_end)
# self.app.sweep_control.update_sweep()
# set timer to let finish all stuff before new sweep
QTimer.singleShot(2000, self._safe_sweep)
def _safe_sweep(self):
'''
sweep only if button enabled
to prevent multiple/concurrent sweep
'''
if self.app.sweep_control.btn_start.isEnabled():
self.app.sweep_start()
else:
logger.error("sweep alredy running")