From 5e2507e179939ff25991d96c850fd7140d044164 Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Sun, 12 Jul 2015 01:06:24 +0000 Subject: [PATCH] WsprTxScheduler improvements. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5715 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- WSPRBandHopping.cpp | 7 ++++++ WsprTxScheduler.cpp | 56 +++++++++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/WSPRBandHopping.cpp b/WSPRBandHopping.cpp index 1638f5368..ce1e1d568 100644 --- a/WSPRBandHopping.cpp +++ b/WSPRBandHopping.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "SettingsGroup.hpp" #include "Configuration.hpp" @@ -118,6 +119,12 @@ Dialog::Dialog (QSettings * settings, Configuration const * configuration, BandL main_layout->addLayout (bottom_layout); setLayout (main_layout); + + //init random seed for random number generator used in tx scheduler + struct timeval time; + gettimeofday(&time,NULL); + srand((time.tv_sec*1000)+(time.tv_usec/1000)); + } Dialog::~Dialog () diff --git a/WsprTxScheduler.cpp b/WsprTxScheduler.cpp index 61df3f360..6941ad4b8 100644 --- a/WsprTxScheduler.cpp +++ b/WsprTxScheduler.cpp @@ -50,11 +50,22 @@ int tx_sum() int tx_add_one(char* tx) { - int i; - for (i=1; i<59; i++) { - if( tx[i-1]==0 && tx[i]==0 && tx[i+1]==0 ) { - tx[i]=1; - return 1; + int i, j, txflag, ngap; + // adds one tx slot to an existing array without + // creating successive tx slots. + // try to fill largest gaps first + // try gap sizes of 13, 11, 9, 7, 5, and finally 3 + for (ngap=13; ngap>=3; ngap=ngap-2) { + for (i=0; i< 60-ngap; i++) { + txflag=0; + for (j=0; j= 17 && pctx < 33 ) { + } else if( pctx > 25 && pctx < 33 ) { ntxlim=1; ntxbandmin=1; } else if( pctx >= 33 && pctx < 50 ) { @@ -126,7 +149,10 @@ int create_tx_schedule(int pctx) ntxlim=3; ntxbandmin=4; } - + + // when txpct>25% create a table that guarantees that all + // bands will be visited 1, 2, or 3 times, as appropriate. + // // start by filling each band slot with ntxbandmin tx's for (i=0; i