mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-24 05:08:38 -05:00
Remove scheduler debug writes to stdout, clean up hopping.f90, add next_hopping_band() function.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5541 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
29b24c4ca0
commit
4f6904943b
@ -19,8 +19,8 @@ extern "C"
|
||||
#else
|
||||
#include "FC.h"
|
||||
void FC_hopping (int const * year, int const * month, int const * nday, float const * uth, char const * my_grid
|
||||
, int const * nduration, int const * npctx, int * isun, int * iband
|
||||
, int * ntxnext, int my_grid_len);
|
||||
, int const * nduration, int * isun
|
||||
, int my_grid_len);
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -263,11 +263,12 @@ auto WSPRBandHopping::next_hop () -> Hop
|
||||
|
||||
// look up band for this period
|
||||
FC_hopping (&year, &month, &day, &uth, my_grid.toLatin1 ().constData ()
|
||||
, &m_->gray_line_duration_, &m_->tx_percent_, &period_index, &band_index
|
||||
, &tx_next, my_grid.size ());
|
||||
, &m_->gray_line_duration_, &period_index
|
||||
, my_grid.size ());
|
||||
|
||||
// consult scheduler to determine if next period should be a tx interval
|
||||
tx_next = next_tx_state(m_->tx_percent_);
|
||||
band_index = next_hopping_band();
|
||||
|
||||
if (100 == m_->tx_percent_)
|
||||
{
|
||||
|
@ -176,6 +176,15 @@ int next_tx_state(int pctx)
|
||||
tx_table_pctx = pctx;
|
||||
}
|
||||
|
||||
tx_print();
|
||||
// tx_print();
|
||||
return tx[tx_20min_slot][tx_2min_slot];
|
||||
}
|
||||
|
||||
int next_hopping_band()
|
||||
{
|
||||
time_t now=time(0)+30;
|
||||
tm *ltm = localtime(&now);
|
||||
int minute = ltm->tm_min;
|
||||
int tx_2min_slot = (minute%20)/2;
|
||||
return tx_2min_slot;
|
||||
}
|
||||
|
@ -2,5 +2,6 @@
|
||||
#define WSPR_TX_SCHEDULER_H_
|
||||
|
||||
int next_tx_state (int pctx);
|
||||
int next_hopping_band();
|
||||
|
||||
#endif
|
||||
|
170
lib/hopping.f90
170
lib/hopping.f90
@ -1,176 +1,8 @@
|
||||
subroutine txbandtot(tx,ibtot)
|
||||
integer tx(10,6), ibtot(10)
|
||||
do j=1,10
|
||||
ibtot(j)=0
|
||||
do i=1,6
|
||||
ibtot(j)=ibtot(j)+tx(j,i)
|
||||
enddo
|
||||
enddo
|
||||
return
|
||||
end subroutine txbandtot
|
||||
|
||||
subroutine txadd(tx,iband)
|
||||
!add one tx to the requested band
|
||||
integer tx(10,6)
|
||||
isuccess=0
|
||||
do k=1,10
|
||||
call random_number(rr)
|
||||
islot=rr*6
|
||||
islot=islot+1
|
||||
if( islot .gt. 6 ) then
|
||||
write(*,*) "should not happen"
|
||||
islot=6
|
||||
endif
|
||||
if( tx(iband,islot).eq.0 ) then
|
||||
tx(iband,islot)=1
|
||||
isuccess=1
|
||||
endif
|
||||
if( isuccess.eq.1 ) then
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
return
|
||||
end subroutine txadd
|
||||
|
||||
subroutine txtrim(tx,ntxmax,ntot)
|
||||
!limit sequential runlength to ntxmax
|
||||
integer tx(10,6)
|
||||
nrun=0
|
||||
do i=1,6
|
||||
do j=1,10
|
||||
if( tx(j,i).eq.1 ) then
|
||||
nrun=nrun+1
|
||||
if(nrun.gt.ntxmax) then
|
||||
tx(j,i)=0
|
||||
nrun=0
|
||||
endif
|
||||
else
|
||||
nrun=0
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
|
||||
ntot=0
|
||||
do j=1,10
|
||||
do i=1,6
|
||||
if(tx(j,i).eq.1) then
|
||||
ntot=ntot+1
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
return
|
||||
end subroutine txtrim
|
||||
|
||||
subroutine hopping(nyear,month,nday,uth,mygrid,nduration,npctx,isun, &
|
||||
iband,ntxnext)
|
||||
|
||||
! Determine Rx or Tx in coordinated hopping mode.
|
||||
subroutine hopping(nyear,month,nday,uth,mygrid,nduration,isun)
|
||||
|
||||
character*6 mygrid
|
||||
integer tx(10,6) !T/R array for 2 hours: 10 bands, 6 time slots
|
||||
real r(6) !Random numbers
|
||||
integer ii(1),ibtot(10)
|
||||
data n2hr0/-999/
|
||||
save n2hr0,tx
|
||||
|
||||
call grayline(nyear,month,nday,uth,mygrid,nduration,isun)
|
||||
|
||||
ns0=uth*3600.0
|
||||
pctx=npctx
|
||||
nrx=0
|
||||
ntxnext=0
|
||||
nsec=(ns0+10)/120 !Round up to start of next 2-min slot
|
||||
nsec=nsec*120
|
||||
n2hr=nsec/7200 !2-hour slot number
|
||||
|
||||
if(n2hr.ne.n2hr0) then
|
||||
! Compute a new Rx/Tx pattern for this 2-hour interval
|
||||
n2hr0=n2hr !Mark this one as done
|
||||
tx=0 !Clear the tx array
|
||||
do j=1,10 !Loop over all 10 bands
|
||||
call random_number(r)
|
||||
do i=1,6,2 !Select one each of 3 pairs of the
|
||||
if(r(i).gt.r(i+1)) then ! 6 slots for Tx
|
||||
tx(j,i)=1
|
||||
r(i+1)=0.
|
||||
else
|
||||
tx(j,i+1)=1
|
||||
r(i)=0.
|
||||
endif
|
||||
enddo
|
||||
|
||||
if(pctx.lt.50.0) then !If pctx < 50, we may kill one Tx slot
|
||||
ii=maxloc(r)
|
||||
i=ii(1)
|
||||
call random_number(rr)
|
||||
rrtest=(50.0-pctx)/16.667
|
||||
if(rr.lt.rrtest) then
|
||||
tx(j,i)=0
|
||||
r(i)=0.
|
||||
endif
|
||||
endif
|
||||
|
||||
if(pctx.lt.33.333) then !If pctx < 33, may kill another
|
||||
ii=maxloc(r)
|
||||
i=ii(1)
|
||||
call random_number(rr)
|
||||
rrtest=(33.333-pctx)/16.667
|
||||
if(rr.lt.rrtest) then
|
||||
tx(j,i)=0
|
||||
r(i)=0.
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
|
||||
! We now have 1 to 3 Tx periods per band in the 2-hour interval.
|
||||
! Now, iteratively massage the array to try to satisfy the constraints
|
||||
ntxlimit=2
|
||||
if( pctx .lt. 33.333 ) then
|
||||
minperband=1
|
||||
elseif( (pctx .ge. 33.333) .and. (pctx .lt. 50.0) ) then
|
||||
minperband=2
|
||||
else
|
||||
minperband=3
|
||||
endif
|
||||
n_needed=60*pctx/100+0.5
|
||||
! Allow up to 20 iterations
|
||||
do k=1,20
|
||||
call txtrim(tx,ntxlimit,ntot)
|
||||
call txbandtot(tx,ibtot)
|
||||
! write(*,3001) ibtot
|
||||
do j=1,10
|
||||
if( ibtot(j).le.minperband) then
|
||||
do m=1,minperband-ibtot(j)
|
||||
call txadd(tx,j)
|
||||
enddo
|
||||
endif
|
||||
enddo
|
||||
call txtrim(tx,ntxlimit,ntot)
|
||||
if( abs(ntot-n_needed) .le. 1 ) then
|
||||
! write(*,*) "Success! Iteration converged"
|
||||
exit
|
||||
endif
|
||||
! write(*,*) "Iteration: ",k,ntot,n_needed
|
||||
! iteration loop
|
||||
enddo
|
||||
actual_pct=ntot/60.0
|
||||
! write(*,*) "Actual percentage: ",actual_pct
|
||||
endif
|
||||
|
||||
iband=mod(nsec/120,10) + 1
|
||||
iseq=mod(nsec/1200,6) + 1
|
||||
if(iseq.lt.1) iseq=1
|
||||
if(tx(iband,iseq).eq.1) then
|
||||
ntxnext=1
|
||||
else
|
||||
nrx=1
|
||||
endif
|
||||
iband=iband-1
|
||||
|
||||
! write(*,3000) iband+1,iseq,nrx,ntxnext
|
||||
!3000 format('Fortran iband, iseq,nrx,ntxnext:',4i5)
|
||||
! write(*,3001) int(tx)
|
||||
!3001 format(10i2)
|
||||
|
||||
return
|
||||
end subroutine hopping
|
||||
|
Loading…
Reference in New Issue
Block a user