summaryrefslogtreecommitdiff
path: root/tests/unit/map65/decode_history
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-10-09 14:12:35 +0200
committerChristoph Berg <myon@debian.org>2026-10-09 14:12:35 +0200
commitffc62c792c9a5196cb4ce7a353287dfe20db6524 (patch)
tree1269efa852935b183daae4bb33a58d1b4d2ffb53 /tests/unit/map65/decode_history
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
New upstream version 3.3.0~beta1+dfsgupstream/3.3.0_beta1+dfsg
Diffstat (limited to 'tests/unit/map65/decode_history')
-rw-r--r--tests/unit/map65/decode_history/decode_history_stubs.f9016
-rw-r--r--tests/unit/map65/decode_history/test_map65_decode_history.f90108
2 files changed, 119 insertions, 5 deletions
diff --git a/tests/unit/map65/decode_history/decode_history_stubs.f90 b/tests/unit/map65/decode_history/decode_history_stubs.f90
index 9582e19a..89dd9bac 100644
--- a/tests/unit/map65/decode_history/decode_history_stubs.f90
+++ b/tests/unit/map65/decode_history/decode_history_stubs.f90
@@ -5,6 +5,12 @@ module decode_history_observations
integer :: jt65_attempts = 0, q65_successes = 0
integer :: phase_attempts(0:12) = 0
integer :: summary_count = 0, fitted_phase = -999
+ integer :: display_calls = 0
+ ! decode1a's fit values (a), and whether ccf65 reports each bin's
+ ! shorthand sync from ss(2,1) of that bin instead of -99, so a test can
+ ! place a shorthand's two tones in chosen bins.
+ real :: stub_fit = 0.0
+ logical :: stub_short_from_ss = .false.
logical :: phase_has_signal(0:12) = .true.
end module
@@ -47,6 +53,7 @@ contains
end module
module ccf65_legacy_mod
+ use decode_history_observations
implicit none
contains
subroutine ccf65(ss_plane, nhsym, ssmax, sync1, ipol1, jpz, dt1, flipk, &
@@ -59,6 +66,7 @@ contains
dt1 = 0.0
flipk = 1.0
syncshort = -99.0
+ if (stub_short_from_ss) syncshort = ss_plane(2,1)
snr2 = 0.0
dt2 = 0.0
ipol1 = 1
@@ -96,7 +104,7 @@ contains
endif
decoded = 'K1ABC W9XYZ FN42'
sync2 = 100.0
- a = 0.0
+ a = stub_fit
dt = 0.0
pol = 0.0
qual = 5.0 + 4.0*sin(dphi)
@@ -139,11 +147,13 @@ contains
end module
module display_mod
+ use decode_history_observations
implicit none
contains
- subroutine display(nkeep, ftol)
- integer, intent(in) :: nkeep
+ subroutine display(nkeep, ftol, nutc)
+ integer, intent(in) :: nkeep, nutc
real, intent(in) :: ftol
+ display_calls = display_calls + 1
end subroutine
end module
diff --git a/tests/unit/map65/decode_history/test_map65_decode_history.f90 b/tests/unit/map65/decode_history/test_map65_decode_history.f90
index eb5ce18c..bd2eb9dc 100644
--- a/tests/unit/map65/decode_history/test_map65_decode_history.f90
+++ b/tests/unit/map65/decode_history/test_map65_decode_history.f90
@@ -4,10 +4,17 @@ program test_map65_decode_history
use datcom_ptrs_mod, only: ss_old, savg_old
use decodes_mod, only: nhsym1, nhsym2
use map65a_mod, only: map65a
+ use message_history_mod, only: message_record, recent_messages
use decode_history_observations
implicit none
real, allocatable :: samples(:,:)
integer :: unit, before_jt65, before_q65
+ integer :: messages, rx_log, before_display
+ integer :: band_nfa = 0, band_nfb = 0, cursor_khz = 0, fits(3), test_nmode = 11
+ integer :: click_bin
+ real :: rec_khz
+ character(len=128) :: rec
+ character(len=*), parameter :: JT65_MSG = 'K1ABC W9XYZ FN42'
! Only the center bin has signal power; DSP stand-ins never read samples.
nfft_active = 1024
@@ -60,9 +67,84 @@ program test_map65_decode_history
call run_pass(nhsym2, 0, 0)
call require(jt65_attempts == before_jt65+2 .and. q65_successes == before_q65+2, &
'final pass retains successes after a skipped-period boundary')
+
+ ! A double-click decode reaches Messages/Band Map and map65_rx.log
+ ! without repeating a decode already recorded by the wideband pass.
+ messages = count_history_records(JT65_MSG)
+ rx_log = count_records(21, JT65_MSG)
+ call require(messages >= 1 .and. rx_log >= 1, 'wideband pass records the JT65 decode')
+ before_jt65 = jt65_attempts
+ before_display = display_calls
+ call click()
+ call require(jt65_attempts == before_jt65+1, 'click decodes JT65 at the cursor')
+ call require(count_history_records(JT65_MSG) == messages .and. count_records(21, JT65_MSG) == rx_log, &
+ 'click does not repeat a decode the wideband pass recorded')
+ call require(display_calls == before_display+1, 'click refreshes the Messages window')
+ active_input_generation = 4
+ call click()
+ call require(count_history_records(JT65_MSG) == messages+1 .and. count_records(21, JT65_MSG) == rx_log+1, &
+ 'click records a decode the wideband pass did not')
+ call click()
+ call require(count_history_records(JT65_MSG) == messages+1 .and. count_records(21, JT65_MSG) == rx_log+1, &
+ 'second click on the same signal is not recorded again')
+
+ ! A click on a JT65C RRR shorthand: its sync tone in the clicked bin and
+ ! the upper tone 30*4 tone spacings (~3 bins) above, noise elsewhere. It
+ ! must be found although the click's best JT65 sync bin is elsewhere, be
+ ! labeled RRR, be recorded at the clicked kHz (band center (nfa+nfb)/2 =
+ ! 130 kHz, cursor 130 kHz: 144.130 MHz), and carry no fit values left in
+ ! sig by an earlier decode.
+ stub_fit = 7.0
+ active_input_generation = 5
+ call run_pass(nhsym1, 0, 0)
+ stub_fit = 0.0
+ click_bin = nfft_active/2 + 1
+ ss_old(2,1,:) = -99.0
+ ss_old(2,1,click_bin) = 10.0
+ ss_old(2,1,click_bin + nint(3*4*10.0*(11025.0/4096.0)/(96000.0/nfft_active))) = 10.0
+ stub_short_from_ss = .true.
+ test_nmode = 13
+ band_nfa = 100
+ band_nfb = 160
+ cursor_khz = 130
+ active_input_generation = 6
+ call click()
+ call require(last_history_record('RRR', rec), 'shorthand click is found and labeled RRR')
+ read(rec(1:8), *) rec_khz
+ read(rec(14:22), '(3i3)') fits
+ call require(abs(rec_khz - 144.130) < 0.0005, 'shorthand click is recorded at the clicked kHz')
+ call require(all(fits == 0), 'shorthand click records no stale fit values')
print '(a)', 'MAP65 decode history tests passed.'
contains
+ integer function count_history_records(text)
+ character(len=*), intent(in) :: text
+ type(message_record), allocatable :: records(:)
+ integer :: i
+
+ call recent_messages(huge(0), records)
+ count_history_records = 0
+ do i = 1, size(records)
+ if (index(records(i)%line, text) > 0) count_history_records = count_history_records + 1
+ enddo
+ end function
+
+ logical function last_history_record(text, found)
+ character(len=*), intent(in) :: text
+ character(len=*), intent(out) :: found
+ type(message_record), allocatable :: records(:)
+ integer :: i
+
+ call recent_messages(huge(0), records)
+ last_history_record = .false.
+ found = ' '
+ do i = 1, size(records)
+ if (index(records(i)%line, text) == 0) cycle
+ found = records(i)%line
+ last_history_record = .true.
+ enddo
+ end function
+
subroutine run_pass(half_symbols, again, find_phase)
integer, intent(in) :: half_symbols, again, find_phase
integer :: newdat, utc, done, ndphi, mcall3b, nsum, nsave
@@ -74,11 +156,33 @@ contains
nsum = 0
nsave = 0
call system_clock(t_start)
- call map65a(samples,newdat,utc,144.0_real64,100,0,0,0,0,0,again,done,0,ndphi,0, &
+ call map65a(samples,newdat,utc,144.0_real64,100,0,band_nfa,band_nfb,0,cursor_khz, &
+ again,done,0,ndphi,0, &
-1270,20,mcall3b,nsum,nsave,0,'K1ABC ','FN42 ',0,3,0, &
- 'W9XYZ ','EN50 ',half_symbols,96000,0,1,11,0)
+ 'W9XYZ ','EN50 ',half_symbols,96000,0,1,test_nmode,0)
end subroutine
+ subroutine click()
+ ! MainWindow::freezeDecode() sets nagain=1 and the manual decode flag.
+ manualDecodeFlag = 1
+ call run_pass(nhsym2, 1, 0)
+ end subroutine
+
+ integer function count_records(u, text)
+ integer, intent(in) :: u
+ character(len=*), intent(in) :: text
+ character(len=128) :: rec
+ integer :: ios
+ count_records = 0
+ rewind(u)
+ do
+ read(u, '(a)', iostat=ios) rec
+ if (ios /= 0) exit
+ if (index(rec, text) > 0) count_records = count_records + 1
+ enddo
+ backspace(u)
+ end function
+
subroutine require(condition, description)
logical, intent(in) :: condition
character(len=*), intent(in) :: description