mirror of
				https://github.com/saitohirga/WSJT-X.git
				synced 2025-10-25 10:00:23 -04: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
							
								
									f1989b3874
								
							
						
					
					
						commit
						bdef43aed7
					
				| @ -6,6 +6,7 @@ | |||||||
| #include <QList> | #include <QList> | ||||||
| #include <QSet> | #include <QSet> | ||||||
| #include <QtWidgets> | #include <QtWidgets> | ||||||
|  | #include <sys/time.h> | ||||||
| 
 | 
 | ||||||
| #include "SettingsGroup.hpp" | #include "SettingsGroup.hpp" | ||||||
| #include "Configuration.hpp" | #include "Configuration.hpp" | ||||||
| @ -118,6 +119,12 @@ Dialog::Dialog (QSettings * settings, Configuration const * configuration, BandL | |||||||
|   main_layout->addLayout (bottom_layout); |   main_layout->addLayout (bottom_layout); | ||||||
| 
 | 
 | ||||||
|   setLayout (main_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 () | Dialog::~Dialog () | ||||||
|  | |||||||
| @ -50,11 +50,22 @@ int tx_sum() | |||||||
| 
 | 
 | ||||||
| int tx_add_one(char* tx) | int tx_add_one(char* tx) | ||||||
| { | { | ||||||
|     int i; |     int i, j, txflag, ngap; | ||||||
|     for (i=1; i<59; i++) { |     // adds one tx slot to an existing array without
 | ||||||
|         if( tx[i-1]==0 && tx[i]==0 && tx[i+1]==0 ) { |     // creating successive tx slots. 
 | ||||||
|             tx[i]=1; |     // try to fill largest gaps first  
 | ||||||
|             return 1; |     // 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; |     return 0; | ||||||
| @ -62,8 +73,16 @@ int tx_add_one(char* tx) | |||||||
| 
 | 
 | ||||||
| int tx_trim(char* tx, int ntxlim) | 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; |     int i,nrun,sum; | ||||||
|  | 
 | ||||||
|  |     if( tx[0] == 1 ) tx[0] = 0; | ||||||
|     nrun=0; |     nrun=0; | ||||||
|     for (i=0; i<60; i++) { |     for (i=0; i<60; i++) { | ||||||
|         if( tx[i]==1 ) { |         if( tx[i]==1 ) { | ||||||
| @ -100,20 +119,24 @@ int create_tx_schedule(int pctx) | |||||||
| { | { | ||||||
|     char bsum[10]; |     char bsum[10]; | ||||||
|     int i, j, k, sum, ntxlim, ntxbandmin, needed; |     int i, j, k, sum, ntxlim, ntxbandmin, needed; | ||||||
|     int iflag; |     int iflag, nrx; | ||||||
|  |     float rxavg,x; | ||||||
|      |      | ||||||
|     needed=60*(pctx/100.0)+0.5; |     needed=60*(pctx/100.0)+0.5; | ||||||
|      |      | ||||||
|     srand(time(NULL)); |  | ||||||
|     memset(tx,0,sizeof(char)*60); |     memset(tx,0,sizeof(char)*60); | ||||||
|      |      | ||||||
|     if( pctx < 17 ) { |     if( pctx <= 25 ) { // Use K1JT's algorithm in this regime
 | ||||||
|         needed=pctx*60/100; |         rxavg=100.0/pctx-1.0; | ||||||
|         for (i=0; i<needed; i++) { |         i=0;  | ||||||
|             tx[rand()%6][rand()%10]=1; |         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; |         return 1; | ||||||
|     } else if( pctx >= 17 && pctx < 33 ) { |     } else if( pctx > 25 && pctx < 33 ) { | ||||||
|         ntxlim=1; |         ntxlim=1; | ||||||
|         ntxbandmin=1; |         ntxbandmin=1; | ||||||
|     } else if( pctx >= 33 && pctx < 50 ) { |     } else if( pctx >= 33 && pctx < 50 ) { | ||||||
| @ -126,7 +149,10 @@ int create_tx_schedule(int pctx) | |||||||
|         ntxlim=3; |         ntxlim=3; | ||||||
|         ntxbandmin=4; |         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
 |     // start by filling each band slot with ntxbandmin tx's
 | ||||||
|     for (i=0; i<ntxbandmin; i++) { |     for (i=0; i<ntxbandmin; i++) { | ||||||
|         for (j=0; j<10; j++) { |         for (j=0; j<10; j++) { | ||||||
| @ -155,7 +181,7 @@ int create_tx_schedule(int pctx) | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     for(j=0; j < (needed-sum); j++ ) { |     for(j=0; j < (needed-sum); j++ ) { | ||||||
|         tx_add_one(*tx); |         tx_add_one(*tx);  | ||||||
|     } |     } | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user