diff options
| author | Dave Hibberd <hibby@debian.org> | 2026-10-20 22:35:06 +0100 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2026-10-20 22:35:06 +0100 |
| commit | 82ebb1ed1af30cee4dfbb1c628431d32885a00e0 (patch) | |
| tree | 1a1f782d3e576b758be0bc61171574a7cd8f2376 /lib/streaming_emit.f90 | |
| parent | 061658210acb6425517733ea012dda803a7f72a1 (diff) | |
| parent | 61d684922b0f1c8455cc60eb3d123df058c9e1f5 (diff) | |
Merge tag 'debian/3.3.0_beta2+dfsg-1' into hibbian/trixie-backports
tagging wsjtx 3.3.0~beta2+dfsg-1
Diffstat (limited to 'lib/streaming_emit.f90')
| -rw-r--r-- | lib/streaming_emit.f90 | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/lib/streaming_emit.f90 b/lib/streaming_emit.f90 index fc86246a..0b6e4590 100644 --- a/lib/streaming_emit.f90 +++ b/lib/streaming_emit.f90 @@ -13,8 +13,6 @@ ! error (version) {"v":1,"t":"error","code":"unknown_schema_version","got":N} ! error (type) {"v":1,"t":"error","code":"configure_type_error", ! "key":"depth","expected":"int","got":"string"} -! warning {"v":1,"t":"warning","code":"period_boundary_discard", -! "discarded_samples":N} ! ! Activation: program jt9 calls streaming_emit_set_enabled(.true.) when ! --stream is parsed. Decoder per-mode sites in lib/decoder.f90 query @@ -28,8 +26,11 @@ module streaming_emit private logical, save :: enabled_ = .false. + logical, save :: utc_from_iso_ = .false. + real(8), save :: trperiod_ = 60.d0 public :: streaming_emit_set_enabled + public :: streaming_emit_set_time_form public :: streaming_emit_enabled public :: streaming_emit_ready public :: streaming_emit_decode @@ -38,7 +39,6 @@ module streaming_emit public :: streaming_emit_error_code public :: streaming_emit_error_version public :: streaming_emit_error_type - public :: streaming_emit_warning_samples contains @@ -47,6 +47,20 @@ contains enabled_ = flag end subroutine streaming_emit_set_enabled + ! Called after each applied configure. An ISO utc is HHMMSS; a numeric nutc + ! is HHMMSS when the period is under a minute or the value exceeds 2359, + ! and HHMM otherwise. + subroutine streaming_emit_set_time_form(utc_set, nutc_set, trperiod) + logical, intent(in) :: utc_set, nutc_set + real(8), intent(in) :: trperiod + if (utc_set) then + utc_from_iso_ = .true. + else if (nutc_set) then + utc_from_iso_ = .false. + end if + trperiod_ = trperiod + end subroutine streaming_emit_set_time_form + pure function streaming_emit_enabled() result(v) logical :: v v = enabled_ @@ -70,13 +84,14 @@ contains ! dt : DT seconds (float) ! freq : decode frequency offset in Hz (integer) ! msg : decoded message text (gets JSON-escaped + trimmed) - subroutine streaming_emit_decode(mode_str, nutc, snr, dt, freq, msg) + subroutine streaming_emit_decode(mode_str, nutc, snr, dt, freq, msg, utc_is_hhmmss) character(len=*), intent(in) :: mode_str integer, intent(in) :: nutc integer, intent(in) :: snr real, intent(in) :: dt integer, intent(in) :: freq character(len=*), intent(in) :: msg + logical, optional, intent(in) :: utc_is_hhmmss character(len=8) :: time_str character(len=320) :: msg_escaped @@ -85,7 +100,7 @@ contains if (.not. enabled_) return - call format_utc_(nutc, time_str) + call format_utc_(nutc, time_str, utc_is_hhmmss) call json_escape_(msg, msg_escaped, msg_len) call format_dt_(dt, dt_str) @@ -100,11 +115,12 @@ contains flush(output_unit) end subroutine streaming_emit_decode - subroutine streaming_emit_decode_finished(nutc) + subroutine streaming_emit_decode_finished(nutc, utc_is_hhmmss) integer, intent(in) :: nutc + logical, optional, intent(in) :: utc_is_hhmmss character(len=8) :: time_str if (.not. enabled_) return - call format_utc_(nutc, time_str) + call format_utc_(nutc, time_str, utc_is_hhmmss) write(output_unit, '(3a)') & '{"v":1,"t":"decode_finished","period_end":"', trim(time_str), & '"}' @@ -166,16 +182,6 @@ contains flush(output_unit) end subroutine streaming_emit_error_type - subroutine streaming_emit_warning_samples(code, discarded_samples) - character(len=*), intent(in) :: code - integer(int64), intent(in) :: discarded_samples - if (.not. enabled_) return - write(output_unit, '(3a,i0,a)') & - '{"v":1,"t":"warning","code":"', trim(code), & - '","discarded_samples":', discarded_samples, '}' - flush(output_unit) - end subroutine streaming_emit_warning_samples - ! Internals ------------------------------------------------------------- ! Format dt (real seconds) as a JSON-safe number. gfortran's f0.x format @@ -198,17 +204,23 @@ contains ! Format the integer nutc time as 6 chars. 4-digit HHMM gets ! zero-extended to HHMM00 so consumers always see a 6-char field. - subroutine format_utc_(nutc, str) + subroutine format_utc_(nutc, str, utc_is_hhmmss) integer, intent(in) :: nutc character(len=*), intent(out) :: str + logical, optional, intent(in) :: utc_is_hhmmss integer :: hh, mm, ss + logical :: full_time + full_time=utc_from_iso_.or.trperiod_.lt.60.d0.or.nutc.gt.2359 + if(present(utc_is_hhmmss)) full_time=full_time.or.utc_is_hhmmss str = '000000' - if (nutc .ge. 100000) then + if (nutc .lt. 0) then + return + else if (full_time) then hh = nutc / 10000 mm = mod(nutc/100, 100) ss = mod(nutc, 100) write(str, '(i2.2,i2.2,i2.2)') hh, mm, ss - else if (nutc .ge. 0) then + else hh = nutc / 100 mm = mod(nutc, 100) write(str, '(i2.2,i2.2,a2)') hh, mm, '00' |
