From ed80f240e9fca64030626f6f02f75acd4daf575d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Thu, 18 May 2017 01:52:30 +0000 Subject: [PATCH] Add temporary simpler Tx scheduler for WSPR-LF Until the advanced band hopping scheduler is upgraded to work with T/R periods other than 2 minutes this scheduler uses a strictly random scheduler, except that Tx percentages less than 40 defer Tx periods that would otherwise be consecutive. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7687 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- WSPRBandHopping.cpp | 37 ++++++++++++++++++++++++++++++++++++- WSPRBandHopping.hpp | 2 +- mainwindow.cpp | 2 +- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/WSPRBandHopping.cpp b/WSPRBandHopping.cpp index 0ea3d7632..61469ea52 100644 --- a/WSPRBandHopping.cpp +++ b/WSPRBandHopping.cpp @@ -1,5 +1,7 @@ #include "WSPRBandHopping.hpp" +#include + #include #include #include @@ -210,6 +212,10 @@ public: , configuration_ {configuration} , tx_percent_ {0} , parent_widget_ {parent_widget} + , last_was_tx_ {false} + , carry_ {false} + , gen_ {rd_ ()} + , dist_ {1, 100} { auto num_bands = configuration_->bands ()->rowCount (); for (auto& flags : bands_) @@ -218,6 +224,8 @@ public: } } + bool simple_scheduler (); + QSettings * settings_; Configuration const * configuration_; int tx_percent_; @@ -232,8 +240,31 @@ public: int gray_line_duration_; QPointer dialog_; + bool last_was_tx_; + bool carry_; + std::random_device rd_; + std::mt19937 gen_; + std::uniform_int_distribution dist_; }; +bool WSPRBandHopping::impl::simple_scheduler () +{ + auto tx = carry_ || tx_percent_ > dist_ (gen_); + if (carry_) + { + carry_ = false; + } + else if (tx_percent_ < 40 && last_was_tx_ && tx) + { + // if percentage is less than 40 then avoid consecutive tx but + // always catch up on the next round + tx = false; + carry_ = true; + } + last_was_tx_ = tx; + return tx; +} + WSPRBandHopping::WSPRBandHopping (QSettings * settings, Configuration const * configuration, QWidget * parent_widget) : m_ {settings, configuration, parent_widget} { @@ -436,8 +467,12 @@ auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop }; } -bool WSPRBandHopping::next_is_tx () +bool WSPRBandHopping::next_is_tx (bool simple_schedule) { + if (simple_schedule) + { + return m_->simple_scheduler (); + } if (100 == m_->tx_percent_) { return true; diff --git a/WSPRBandHopping.hpp b/WSPRBandHopping.hpp index 5fac8c644..91625bac6 100644 --- a/WSPRBandHopping.hpp +++ b/WSPRBandHopping.hpp @@ -73,7 +73,7 @@ public: // return the next band parameters Hop next_hop (bool tx_enabled); // determine if the next period should be a transmit period - bool next_is_tx (); + bool next_is_tx (bool simple_schedule = false); private: // implementation hidden from public interface diff --git a/mainwindow.cpp b/mainwindow.cpp index 56b847a7a..3009e8447 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6078,7 +6078,7 @@ void MainWindow::WSPR_scheduling () band_hopping_label.setText (hop_data.period_name_); } else { - m_WSPR_tx_next = m_WSPR_band_hopping.next_is_tx (); + m_WSPR_tx_next = m_WSPR_band_hopping.next_is_tx ("WSPR-LF" == m_mode); } }