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
This commit is contained in:
Bill Somerville 2017-05-18 01:52:30 +00:00
parent b71b5c225d
commit ed80f240e9
3 changed files with 38 additions and 3 deletions

View File

@ -1,5 +1,7 @@
#include "WSPRBandHopping.hpp" #include "WSPRBandHopping.hpp"
#include <random>
#include <QPointer> #include <QPointer>
#include <QSettings> #include <QSettings>
#include <QBitArray> #include <QBitArray>
@ -210,6 +212,10 @@ public:
, configuration_ {configuration} , configuration_ {configuration}
, tx_percent_ {0} , tx_percent_ {0}
, parent_widget_ {parent_widget} , parent_widget_ {parent_widget}
, last_was_tx_ {false}
, carry_ {false}
, gen_ {rd_ ()}
, dist_ {1, 100}
{ {
auto num_bands = configuration_->bands ()->rowCount (); auto num_bands = configuration_->bands ()->rowCount ();
for (auto& flags : bands_) for (auto& flags : bands_)
@ -218,6 +224,8 @@ public:
} }
} }
bool simple_scheduler ();
QSettings * settings_; QSettings * settings_;
Configuration const * configuration_; Configuration const * configuration_;
int tx_percent_; int tx_percent_;
@ -232,8 +240,31 @@ public:
int gray_line_duration_; int gray_line_duration_;
QPointer<Dialog> dialog_; QPointer<Dialog> dialog_;
bool last_was_tx_;
bool carry_;
std::random_device rd_;
std::mt19937 gen_;
std::uniform_int_distribution<int> 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) WSPRBandHopping::WSPRBandHopping (QSettings * settings, Configuration const * configuration, QWidget * parent_widget)
: m_ {settings, configuration, 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_) if (100 == m_->tx_percent_)
{ {
return true; return true;

View File

@ -73,7 +73,7 @@ public:
// return the next band parameters // return the next band parameters
Hop next_hop (bool tx_enabled); Hop next_hop (bool tx_enabled);
// determine if the next period should be a transmit period // determine if the next period should be a transmit period
bool next_is_tx (); bool next_is_tx (bool simple_schedule = false);
private: private:
// implementation hidden from public interface // implementation hidden from public interface

View File

@ -6078,7 +6078,7 @@ void MainWindow::WSPR_scheduling ()
band_hopping_label.setText (hop_data.period_name_); band_hopping_label.setText (hop_data.period_name_);
} }
else { 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);
} }
} }