mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 04:11:16 -05:00
WsprTxScheduler improvements.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5715 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
0a7bf935bc
commit
5e2507e179
@ -6,6 +6,7 @@
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QtWidgets>
|
||||
#include <sys/time.h>
|
||||
|
||||
#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 ()
|
||||
|
@ -50,20 +50,39 @@ 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;
|
||||
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<ngap; j++) {
|
||||
if( tx[i+j]==1 )
|
||||
txflag=1;
|
||||
}
|
||||
if( txflag == 0 ) { // found a gap of size ngap
|
||||
tx[i+ngap/2]=1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tx_trim(char* tx, int ntxlim)
|
||||
{
|
||||
// trim array to that ntxlim is not exceeded
|
||||
/* ntxlim is max number of successive transmissions
|
||||
* trim array so that ntxlim is not exceeded
|
||||
* also make sure that first slot is never a tx slot
|
||||
* this enures that we won't get a double tx because of the
|
||||
* last slot of one table and the first slot of the next table
|
||||
* both being tx slots.
|
||||
*/
|
||||
int i,nrun,sum;
|
||||
|
||||
if( tx[0] == 1 ) tx[0] = 0;
|
||||
nrun=0;
|
||||
for (i=0; i<60; i++) {
|
||||
if( tx[i]==1 ) {
|
||||
@ -100,20 +119,24 @@ int create_tx_schedule(int pctx)
|
||||
{
|
||||
char bsum[10];
|
||||
int i, j, k, sum, ntxlim, ntxbandmin, needed;
|
||||
int iflag;
|
||||
int iflag, nrx;
|
||||
float rxavg,x;
|
||||
|
||||
needed=60*(pctx/100.0)+0.5;
|
||||
|
||||
srand(time(NULL));
|
||||
memset(tx,0,sizeof(char)*60);
|
||||
|
||||
if( pctx < 17 ) {
|
||||
needed=pctx*60/100;
|
||||
for (i=0; i<needed; i++) {
|
||||
tx[rand()%6][rand()%10]=1;
|
||||
if( pctx <= 25 ) { // Use K1JT's algorithm in this regime
|
||||
rxavg=100.0/pctx-1.0;
|
||||
i=0;
|
||||
while(i<60) {
|
||||
x=(rand()%100)/100.0;
|
||||
nrx=(rxavg+3.0*x-1.0); //2-5 for 25%
|
||||
i=i+nrx+1;
|
||||
tx[i/10][i%10]=1;
|
||||
}
|
||||
return 1;
|
||||
} else if( pctx >= 17 && pctx < 33 ) {
|
||||
} else if( pctx > 25 && pctx < 33 ) {
|
||||
ntxlim=1;
|
||||
ntxbandmin=1;
|
||||
} else if( pctx >= 33 && pctx < 50 ) {
|
||||
@ -127,6 +150,9 @@ int create_tx_schedule(int pctx)
|
||||
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<ntxbandmin; i++) {
|
||||
for (j=0; j<10; j++) {
|
||||
|
Loading…
Reference in New Issue
Block a user