Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be889681a9 | ||
|
|
f93e1c5898 | ||
|
|
2d67e3d57f | ||
|
|
1a32e4a228 | ||
|
|
b318aa66cc | ||
|
|
6cbe29fef1 | ||
|
|
96b5f2d91f | ||
|
|
ee004c1c62 | ||
|
|
b00552f617 | ||
|
|
4dbc773343 | ||
|
|
ec347e1b7a | ||
|
|
b0bbe3e402 | ||
|
|
85061ab673 | ||
|
|
ab68e4a84e | ||
|
|
f6532b2e85 | ||
|
|
8685dbd6cf | ||
|
|
b7c87def5b | ||
|
|
ae8e5b1bc6 | ||
|
|
ad69371f6a | ||
|
|
3f97084246 | ||
|
|
74dfc3a725 |
@@ -26,6 +26,7 @@ import (
|
||||
"hamlog/internal/antgenius"
|
||||
"hamlog/internal/applog"
|
||||
"hamlog/internal/audio"
|
||||
"hamlog/internal/autocall"
|
||||
"hamlog/internal/award"
|
||||
"hamlog/internal/awardref"
|
||||
"hamlog/internal/backup"
|
||||
@@ -54,6 +55,7 @@ import (
|
||||
"hamlog/internal/powergenius"
|
||||
"hamlog/internal/profile"
|
||||
"hamlog/internal/pskr"
|
||||
"hamlog/internal/pskrtgt"
|
||||
"hamlog/internal/psu"
|
||||
"hamlog/internal/qslcard"
|
||||
"hamlog/internal/qso"
|
||||
@@ -100,6 +102,7 @@ const (
|
||||
keyStationCallsign = "station.callsign"
|
||||
keyStationOperator = "station.operator"
|
||||
keyWatchlistContestPattern = "watchlist.contest_pattern" // auto-add contest calls containing this
|
||||
keyWatchlistContestCalls = "watchlist.contest_calls" // …and these, named one by one
|
||||
keyStationMyGrid = "station.my_grid"
|
||||
keyStationCountry = "station.my_country"
|
||||
keyStationSOTA = "station.my_sota_ref"
|
||||
@@ -195,6 +198,7 @@ const (
|
||||
keyAudioQSOPlayGain = "audio.qso_play_gain" // QSO-recording playback level %
|
||||
keyAudioPTTMethod = "audio.ptt_method" // "none" (VOX) | "rts" | "dtr"
|
||||
keyAudioPTTPort = "audio.ptt_port" // COM port for serial PTT
|
||||
keyAudioPTTData = "audio.ptt_data" // keyer audio arrives on the rig DATA/USB input
|
||||
keyAudioFormat = "audio.qso_format" // "wav" | "mp3"
|
||||
keyAudioFromGain = "audio.from_gain" // From Radio (RX) mix level, percent
|
||||
keyAudioMicGain = "audio.mic_gain" // mic mix level, percent
|
||||
@@ -753,6 +757,31 @@ type App struct {
|
||||
// It is the source that makes VHF detection work at all: the cluster and RBN
|
||||
// carry a handful of 6 m spots where PSK Reporter carries hundreds.
|
||||
pskr *pskr.Watcher
|
||||
// pskTgt is the SECOND PSK Reporter connection: the per-station analysis behind
|
||||
// the FT decodes panel. Separate from a.pskr because the two want opposite
|
||||
// slices of the same feed — everything heard near here, against everything
|
||||
// about one callsign anywhere. Built on first use, nil while the panel is
|
||||
// closed.
|
||||
pskTgtMu sync.Mutex
|
||||
pskTgt *pskrtgt.Watcher
|
||||
// Auto-call: the engine, the period being collected, and the last transmit
|
||||
// state the decoder reported. One mutex — every field here is touched by the
|
||||
// UDP event loop and by the two-second sweeper, and never for long.
|
||||
acMu sync.Mutex
|
||||
ac *autocall.Engine
|
||||
// Keyed by RECEIVER. Two decoders have two independent slot clocks — an
|
||||
// FT8 window and an FT4 one do not even share a period length — and one
|
||||
// buffer for both cut every slot into fragments, each judged as a period of
|
||||
// its own. The engine then counted a missed period several times a slot.
|
||||
acPeriod map[string]string
|
||||
acAt map[string]time.Time
|
||||
acTR map[string]int
|
||||
acBuf map[string][]acDecode
|
||||
acTX autocall.TXState
|
||||
acReason string
|
||||
acLastJudge time.Time
|
||||
// acTXPeriod is the last transmit period already counted — see autoCallNoteTX.
|
||||
acTXPeriod string
|
||||
// Self-spot throttle: when and on what frequency we last announced ourselves.
|
||||
// Held in memory only — a restart legitimately re-announces the station.
|
||||
selfSpotMu sync.Mutex
|
||||
@@ -768,12 +797,20 @@ type App struct {
|
||||
|
||||
// WSJT-X decode highlighting (message 13) — see app_wsjt_highlight.go.
|
||||
wsjtHighlightOn atomic.Bool
|
||||
wsjtHLMu sync.Mutex
|
||||
wsjtHLSent map[string]string
|
||||
watchPattern atomic.Value // auto-contest pattern (string), loaded at startup
|
||||
operating *operating.Repo
|
||||
udp *udp.Manager
|
||||
udpRepo *udp.Repo
|
||||
// Greying out what is already worked is a sub-option of the same feature —
|
||||
// read on the decode path, so an atomic rather than a settings lookup per
|
||||
// decode.
|
||||
wsjtHLWorkedOn atomic.Bool
|
||||
wsjtHLMu sync.Mutex
|
||||
wsjtHLSent map[string]string
|
||||
watchPattern atomic.Value // auto-contest pattern (string), loaded at startup
|
||||
// The named contest callsigns, as a set, loaded with the pattern and read on
|
||||
// the same hot path — one spot per station on the band, so no settings
|
||||
// lookup and no split per spot.
|
||||
watchCalls atomic.Value // map[string]struct{}
|
||||
operating *operating.Repo
|
||||
udp *udp.Manager
|
||||
udpRepo *udp.Repo
|
||||
// Program id of the last decoding application that reported its status.
|
||||
// Halt Tx is routed by id, and the panel's Halt button must work even when
|
||||
// nothing is transmitting at that instant — so the id is remembered from
|
||||
@@ -929,6 +966,7 @@ type App struct {
|
||||
opLon float64
|
||||
opSet bool
|
||||
opCall string // active profile callsign, cached for outbound UDP emitters
|
||||
opGrid string // active profile locator, cached the same way and for the same reason
|
||||
|
||||
// Dedup for the frequency/mode outbound UDP emitters (PstRotator, N1MM): only
|
||||
// send when the frequency or mode actually changes.
|
||||
@@ -978,6 +1016,7 @@ func (a *App) refreshOperatorGrid() {
|
||||
return
|
||||
}
|
||||
a.opCall = strings.ToUpper(strings.TrimSpace(p.Callsign))
|
||||
a.opGrid = strings.ToUpper(strings.TrimSpace(p.MyGrid))
|
||||
lat, lon, ok := gridToLatLon(p.MyGrid)
|
||||
if !ok {
|
||||
return
|
||||
@@ -1486,7 +1525,9 @@ func (a *App) startup(ctx context.Context) {
|
||||
a.pota = pota.New(func(format string, args ...any) { applog.Printf(format, args...) })
|
||||
a.startWatchlistClubLog()
|
||||
a.watchPattern.Store(strings.ToUpper(strings.TrimSpace(a.settingOr(keyWatchlistContestPattern, ""))))
|
||||
a.watchCalls.Store(parseContestCalls(a.settingOr(keyWatchlistContestCalls, "")))
|
||||
a.wsjtHighlightOn.Store(a.settingOr(keyWsjtHighlight, "0") == "1")
|
||||
a.wsjtHLWorkedOn.Store(a.settingOr(keyWsjtHLWorked, "0") == "1")
|
||||
go a.pota.Run(a.ctx)
|
||||
|
||||
// DX Cluster (multi-server): the spot callback enriches each spot
|
||||
@@ -1615,6 +1656,9 @@ func (a *App) startup(ctx context.Context) {
|
||||
// PSK Reporter. After the operator's grid is known: without it there is no
|
||||
// distance to measure and no receiver squares to filter on, so it stays down.
|
||||
a.startBandOpenFeed()
|
||||
// Auto-call. After the watch list and the logbook: the ladder is meaningless
|
||||
// without either, and it must never call anybody on a log it cannot read.
|
||||
a.startAutoCall()
|
||||
// One-time tidy-up of a field nothing used to record. Background, once.
|
||||
a.backfillDistancesOnce()
|
||||
|
||||
@@ -1878,6 +1922,7 @@ func (a *App) shutdown(ctx context.Context) {
|
||||
// logger has spent seconds tearing down ports.
|
||||
applog.Printf("shutdown: closing autostart programs")
|
||||
a.CloseAutostartPrograms()
|
||||
a.stopPSKTarget() // one TLS socket to a public broker; nothing to flush
|
||||
applog.Printf("shutdown: stopping UDP")
|
||||
if a.udp != nil {
|
||||
a.udp.StopAll()
|
||||
@@ -8330,8 +8375,15 @@ func (a *App) GetCATSettings() (CATSettings, error) {
|
||||
if n, _ := strconv.Atoi(m[keyCATIcomBaud]); n > 0 {
|
||||
out.IcomBaud = n
|
||||
}
|
||||
if n, _ := strconv.Atoi(m[keyCATIcomAddr]); n > 0 && n <= 0xFF {
|
||||
out.IcomAddr = n
|
||||
// 0x00 is a real CI-V address an operator may need (a bare interface, a rig
|
||||
// left at its factory broadcast address), and "> 0" silently sent them back
|
||||
// to the IC-7610 default with no way to say what they meant. An EMPTY
|
||||
// setting is what means "never configured" — so the error is what decides,
|
||||
// not the value.
|
||||
if v := strings.TrimSpace(m[keyCATIcomAddr]); v != "" {
|
||||
if n, err := strconv.Atoi(v); err == nil && n >= 0 && n <= 0xFF {
|
||||
out.IcomAddr = n
|
||||
}
|
||||
}
|
||||
if out.Backend == "" {
|
||||
out.Backend = "omnirig"
|
||||
@@ -8522,11 +8574,15 @@ type AudioSettings struct {
|
||||
PrerollSeconds int `json:"preroll_seconds"` // rolling pre-roll (default 8)
|
||||
PTTMethod string `json:"ptt_method"` // "none" (VOX) | "rts" | "dtr"
|
||||
PTTPort string `json:"ptt_port"` // COM port for serial PTT
|
||||
Format string `json:"format"` // "wav" | "mp3"
|
||||
FromGain int `json:"from_gain"` // From Radio (RX) mix level %, default 100
|
||||
MicGain int `json:"mic_gain"` // mic mix level %, default 100
|
||||
TXGain int `json:"tx_gain"` // voice-keyer playback level %, default 100
|
||||
QSOPlayGain int `json:"qso_play_gain"` // QSO-recording playback level %, default 100
|
||||
// PTTData: the keyer's audio reaches the radio on its DATA/USB input, not
|
||||
// the microphone socket. CAT keying only — it changes which transmit
|
||||
// command is sent (a Kenwood TS-590 takes TX1 instead of TX).
|
||||
PTTData bool `json:"ptt_data"`
|
||||
Format string `json:"format"` // "wav" | "mp3"
|
||||
FromGain int `json:"from_gain"` // From Radio (RX) mix level %, default 100
|
||||
MicGain int `json:"mic_gain"` // mic mix level %, default 100
|
||||
TXGain int `json:"tx_gain"` // voice-keyer playback level %, default 100
|
||||
QSOPlayGain int `json:"qso_play_gain"` // QSO-recording playback level %, default 100
|
||||
}
|
||||
|
||||
// ListAudioInputDevices / ListAudioOutputDevices enumerate WASAPI endpoints
|
||||
@@ -8583,7 +8639,7 @@ func (a *App) GetAudioSettings() (AudioSettings, error) {
|
||||
}
|
||||
m, err := a.settings.GetMany(a.ctx,
|
||||
keyAudioFromRadio, keyAudioToRadio, keyAudioRecDevice, keyAudioListenDevice,
|
||||
keyAudioQSORecord, keyAudioQSODir, keyAudioPreroll, keyAudioPTTMethod, keyAudioPTTPort, keyAudioFormat,
|
||||
keyAudioQSORecord, keyAudioQSODir, keyAudioPreroll, keyAudioPTTMethod, keyAudioPTTPort, keyAudioPTTData, keyAudioFormat,
|
||||
keyAudioFromGain, keyAudioMicGain, keyAudioTXGain, keyAudioQSOPlayGain)
|
||||
if err != nil {
|
||||
return out, err
|
||||
@@ -8595,6 +8651,7 @@ func (a *App) GetAudioSettings() (AudioSettings, error) {
|
||||
out.PTTMethod = v
|
||||
}
|
||||
out.PTTPort = m[keyAudioPTTPort]
|
||||
out.PTTData = m[keyAudioPTTData] == "1"
|
||||
out.FromRadio = m[keyAudioFromRadio]
|
||||
out.ToRadio = m[keyAudioToRadio]
|
||||
out.RecordingDevice = m[keyAudioRecDevice]
|
||||
@@ -8665,6 +8722,7 @@ func (a *App) SaveAudioSettings(s AudioSettings) error {
|
||||
keyAudioPreroll: strconv.Itoa(s.PrerollSeconds),
|
||||
keyAudioPTTMethod: pttMethod,
|
||||
keyAudioPTTPort: strings.TrimSpace(s.PTTPort),
|
||||
keyAudioPTTData: boolStr(s.PTTData),
|
||||
keyAudioFormat: format,
|
||||
keyAudioFromGain: strconv.Itoa(s.FromGain),
|
||||
keyAudioMicGain: strconv.Itoa(s.MicGain),
|
||||
@@ -10235,14 +10293,26 @@ func (a *App) applyClublogException(q *qso.QSO, force bool) bool {
|
||||
}
|
||||
e, ok := a.clublog.Resolve(q.Callsign, date)
|
||||
if !ok {
|
||||
// No exception COVERS this QSO's date. If the call nonetheless HAS a
|
||||
// date-ranged exception (e.g. G1T = Scotland only from 2024-02-21), then
|
||||
// cty.dat's date-blind "=G1T → Scotland" override is WRONG for an older
|
||||
// QSO — resolve it by ClubLog's date-aware PREFIX table instead (G1 →
|
||||
// England for a 2012 contact). Ordinary calls (no exception) are left to
|
||||
// cty.dat.
|
||||
if a.clublog.HasException(q.Callsign) {
|
||||
if pe, pok := a.clublog.ResolvePrefix(q.Callsign, date); pok {
|
||||
// No exception covers this QSO's date, so the question becomes which
|
||||
// country file knows the PREFIX better.
|
||||
//
|
||||
// ClubLog's prefix table is date-ranged and cty.dat's is not, and that
|
||||
// is not a detail: cty.dat describes the world as it is TODAY. Niue
|
||||
// moved to E6, so ZK2 went back to New Zealand there — and every ZK2
|
||||
// contact ever made was silently relabelled New Zealand, taking a
|
||||
// confirmed entity out of an operator's DXCC with it. ZK1 loses the
|
||||
// Cook Islands the same way. ClubLog still knows both.
|
||||
//
|
||||
// It only speaks when it HAS an answer (E6, TO5A and their like are not
|
||||
// in its prefix table at all), and never over an exact "=CALLSIGN" entry
|
||||
// in cty.dat: that is somebody having looked at this very callsign, and
|
||||
// a prefix rule does not overrule it.
|
||||
if pe, pok := a.clublog.ResolvePrefix(q.Callsign, date); pok {
|
||||
ctyExact := false
|
||||
if m, mok := a.dxcc.Lookup(q.Callsign); mok {
|
||||
ctyExact = m.Exact
|
||||
}
|
||||
if !ctyExact {
|
||||
e, ok = pe, true
|
||||
}
|
||||
}
|
||||
@@ -10592,7 +10662,7 @@ func (a *App) pttKey(cfg AudioSettings) error {
|
||||
if a.cat == nil {
|
||||
return fmt.Errorf("CAT not initialized")
|
||||
}
|
||||
if err := a.cat.SetPTT(true); err != nil {
|
||||
if err := a.cat.SetPTTSource(true, cfg.PTTData); err != nil {
|
||||
applog.Printf("ptt: CAT SetPTT failed: %v", err)
|
||||
return err
|
||||
}
|
||||
@@ -11705,7 +11775,14 @@ func (a *App) UploadQSOsManual(service string, ids []int64) error {
|
||||
return fmt.Errorf("db not initialized")
|
||||
}
|
||||
svc := extsvc.Service(service)
|
||||
if uploadColumnFor(service) == "" && svc != extsvc.ServiceHamlog && svc != extsvc.ServiceHamQTH {
|
||||
// Cloudlog/Wavelog has no sent-status column ON PURPOSE — it dedupes
|
||||
// server-side, which is exactly why an explicit selection needs no column to
|
||||
// be safe. HAMLOG.online and HamQTH keep theirs in ADIF extras.
|
||||
if svc == extsvc.ServiceHamlog {
|
||||
return extsvc.ErrHamlogClosed
|
||||
}
|
||||
if uploadColumnFor(service) == "" &&
|
||||
svc != extsvc.ServiceHamQTH && svc != extsvc.ServiceCloudlog {
|
||||
return fmt.Errorf("unknown service %q", service)
|
||||
}
|
||||
cfg := a.loadExternalServices()
|
||||
@@ -11929,7 +12006,7 @@ func (a *App) runManualUpload(svc extsvc.Service, ids []int64, cfg extsvc.Extern
|
||||
}
|
||||
flush()
|
||||
}
|
||||
} else if svc == extsvc.ServiceHamlog || svc == extsvc.ServiceHamQTH {
|
||||
} else if svc == extsvc.ServiceHamlog || svc == extsvc.ServiceHamQTH || svc == extsvc.ServiceCloudlog {
|
||||
// One record per request, extras-stamped services. Hamlog used to fall
|
||||
// through to the QRZ branch below and got uploaded to the WRONG service
|
||||
// with the QRZ key — the context menu offered what the loop never handled.
|
||||
@@ -11949,10 +12026,13 @@ func (a *App) runManualUpload(svc extsvc.Service, ids []int64, cfg extsvc.Extern
|
||||
}
|
||||
var res extsvc.UploadResult
|
||||
var err error
|
||||
if svc == extsvc.ServiceHamlog {
|
||||
switch svc {
|
||||
case extsvc.ServiceHamlog:
|
||||
res, err = extsvc.UploadHamlog(ctx, nil, cfg.Hamlog, rec)
|
||||
} else {
|
||||
case extsvc.ServiceHamQTH:
|
||||
res, err = extsvc.UploadHamQTH(ctx, nil, cfg.HamQTH, rec)
|
||||
default:
|
||||
res, err = extsvc.UploadCloudlog(ctx, nil, cfg.Cloudlog, rec)
|
||||
}
|
||||
if err == nil && res.OK {
|
||||
a.markExtUploaded(svc, id, res.LogID)
|
||||
@@ -12008,6 +12088,7 @@ func (a *App) runManualUpload(svc extsvc.Service, ids []int64, cfg extsvc.Extern
|
||||
extsvc.ServiceQRZ: "QRZ.com", extsvc.ServiceClublog: "Club Log", extsvc.ServiceHRDLog: "HRDLog",
|
||||
extsvc.ServiceLoTW: "LoTW", extsvc.ServiceEQSL: "eQSL",
|
||||
extsvc.ServiceHamlog: "HAMLOG.online", extsvc.ServiceHamQTH: "HamQTH",
|
||||
extsvc.ServiceCloudlog: "Cloudlog / Wavelog",
|
||||
}[svc]
|
||||
if label == "" {
|
||||
label = string(svc)
|
||||
@@ -14291,6 +14372,17 @@ func (a *App) consumeUDPEvents() {
|
||||
map[bool]string{true: "", false: " — nothing we send can start a transmission while this is false"}[now.enabled])
|
||||
}
|
||||
}
|
||||
// Auto-call counts what actually goes on the air from here: a reply
|
||||
// we sent is a request, and this is the answer to whether the
|
||||
// decoder acted on it.
|
||||
acTX := autocall.TXState{
|
||||
Transmitting: ev.Transmitting, Enabled: ev.TxEnabled,
|
||||
DXCall: ev.DXCall, Msg: ev.TxMessage, Instance: ev.ProgramID,
|
||||
}
|
||||
a.autoCallSetTX(acTX)
|
||||
if ev.Transmitting {
|
||||
a.autoCallNoteTX(acTX)
|
||||
}
|
||||
wruntime.EventsEmit(a.ctx, "udp:tx_state", map[string]any{
|
||||
"msg": ev.TxMessage,
|
||||
"transmitting": ev.Transmitting,
|
||||
@@ -14348,10 +14440,20 @@ func (a *App) consumeUDPEvents() {
|
||||
// false on a Replay's resent history — shown, never auto-answered.
|
||||
"is_new": ev.DecodeIsNew,
|
||||
})
|
||||
// Auto-call sees the decode after the panel, never before: the list
|
||||
// the operator reads must not wait on a decision about calling.
|
||||
a.autoCallFeed(autocall.Decode{
|
||||
Call: ev.DecodeCall, Band: bandForHz(ev.DecodeFreqHz), Mode: ev.Mode,
|
||||
Msg: ev.DecodeMsg, SNR: ev.DecodeSNR, At: at, TRPeriod: ev.DecodeTRPeriod,
|
||||
Instance: ev.ProgramID, CQ: ev.DecodeCQ,
|
||||
Ms: ev.DecodeMs, DT: ev.DecodeDT, AudioHz: int64(ev.DecodeAudioHz),
|
||||
ModeRaw: ev.DecodeModeRaw, MsgRaw: ev.DecodeMsgRaw, LowConf: ev.DecodeLowConf,
|
||||
IsNew: ev.DecodeIsNew,
|
||||
})
|
||||
// Log-aware colour in the decoder's own window (see
|
||||
// app_wsjt_highlight.go). After the emit: painting must never delay
|
||||
// the panel.
|
||||
a.maybeHighlightDecode(ev.ProgramID, ev.DecodeCall, bandForHz(ev.DecodeFreqHz))
|
||||
a.maybeHighlightDecode(ev.ProgramID, ev.DecodeCall, bandForHz(ev.DecodeFreqHz), ev.Mode)
|
||||
// A WSJT-X decode (heard station). Render it on the FlexRadio
|
||||
// panadapter when the option is on; green + SNR comment, auto-expiring
|
||||
// after the configured duration. De-duped per call in the Flex backend.
|
||||
@@ -15130,6 +15232,53 @@ func (a *App) IcomSetPower(on bool) error {
|
||||
return a.cat.IcomDo(func(ic cat.IcomController) error { return ic.SetPower(on) })
|
||||
}
|
||||
|
||||
// icomBandCodes maps a band label to the code the band stacking registers use
|
||||
// (CI-V 0x1A 0x01). Deliberately partial.
|
||||
//
|
||||
// The HF codes 01-09 are the same on every Icom that has HF, and are safe. What
|
||||
// is NOT the same is everything above them: 50 MHz is 10 on an HF+6 rig, while
|
||||
// an IC-9700 has no HF at all and numbers its three bands 144/430/1200 as 1/2/3.
|
||||
// A band missing here is not a failure — the caller falls back to sending a
|
||||
// frequency, which is what the button did before — so an unlisted band or an
|
||||
// unlisted model loses nothing, and a GUESSED code would land the operator on
|
||||
// another band entirely.
|
||||
func icomBandCodes(model string) map[string]int {
|
||||
m := strings.ToUpper(model)
|
||||
if strings.Contains(m, "9700") {
|
||||
return map[string]int{"2": 1, "70cm": 2, "23cm": 3}
|
||||
}
|
||||
// HF + 6 m: the 7300 / 7610 / 7760 / 7100 / 7851 / 705 / 9100 class. 60 m and
|
||||
// 4 m are absent on purpose — they are not a band key on these radios.
|
||||
return map[string]int{
|
||||
"160": 1, "80": 2, "40": 3, "30": 4, "20": 5,
|
||||
"17": 6, "15": 7, "12": 8, "10": 9, "6": 0x10,
|
||||
}
|
||||
}
|
||||
|
||||
// IcomRecallBand puts the radio where its own band stacking register says the
|
||||
// operator last was on that band — the front panel's band key, from here.
|
||||
//
|
||||
// reg is 1, 2 or 3, so pressing the same band button again walks through the
|
||||
// registers exactly as the radio's key does. Returns the frequency landed on;
|
||||
// an error means nothing was changed and the caller should send its own
|
||||
// frequency instead.
|
||||
func (a *App) IcomRecallBand(band string, reg int) (int64, error) {
|
||||
if a.cat == nil {
|
||||
return 0, fmt.Errorf("cat not initialized")
|
||||
}
|
||||
code, ok := icomBandCodes(a.cat.State().Rig)[strings.ToLower(strings.TrimSpace(band))]
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("no band stacking register for %s on this radio", band)
|
||||
}
|
||||
var hz int64
|
||||
err := a.cat.IcomDo(func(ic cat.IcomController) error {
|
||||
var e error
|
||||
hz, e = ic.RecallBandStack(code, reg)
|
||||
return e
|
||||
})
|
||||
return hz, err
|
||||
}
|
||||
|
||||
// IcomSetScope enables/disables the spectrum-scope waveform stream.
|
||||
func (a *App) IcomSetScope(on bool) error {
|
||||
if a.cat == nil {
|
||||
@@ -16540,6 +16689,14 @@ func (a *App) reloadAfterProfileSwitch() {
|
||||
// per-profile settings too — rebuilt so a switch doesn't keep showing the
|
||||
// previous profile's view of who is worth chasing.
|
||||
a.startWatchlistClubLog()
|
||||
// Auto-call is per profile — attempts, the "call only" callsign, whether it
|
||||
// is on at all — and it TRANSMITS. A switch that left the previous profile's
|
||||
// settings running would have the wrong station calling on the wrong log.
|
||||
// Re-applied rather than restarted: the loop is one goroutine for the life
|
||||
// of the process, and applyAutoCall clears the target when the feature is
|
||||
// off in the profile just activated.
|
||||
a.applyAutoCall()
|
||||
a.autoCallEngine().Reset()
|
||||
}
|
||||
|
||||
// DuplicateProfile clones an existing profile under newName. Useful when
|
||||
|
||||
+69
-5
@@ -42,6 +42,62 @@ func (a *App) SetWatchlistContestPattern(p string) {
|
||||
a.setSettingGlobal(keyWatchlistContestPattern, p)
|
||||
}
|
||||
|
||||
// The named contest callsigns: the other half of the auto-add, and the half the
|
||||
// pattern cannot express.
|
||||
//
|
||||
// A special-event fleet is usually a common string in the callsign — WWA in
|
||||
// TM29WWA, HB9WWA, F4WWA/P — and the pattern collects those on sight. But an
|
||||
// entry list is not a naming convention: R7W can be part of the same event and
|
||||
// share nothing with it, and no pattern will ever catch that station without
|
||||
// catching half the band with it. So the two work together: the pattern for the
|
||||
// family, this list for everybody else.
|
||||
//
|
||||
// Stored GLOBALLY, like the pattern and the list itself — an event is worth
|
||||
// hunting whichever station profile is on.
|
||||
func (a *App) GetWatchlistContestCalls() string {
|
||||
return a.settingOr(keyWatchlistContestCalls, "")
|
||||
}
|
||||
|
||||
// SetWatchlistContestCalls stores the list as typed and caches the parsed set.
|
||||
//
|
||||
// The RAW text is what is stored: the operator's line breaks and their order
|
||||
// are how the list is read back a week later, and rewriting it into a
|
||||
// normalised single line loses the only structure it has.
|
||||
func (a *App) SetWatchlistContestCalls(list string) {
|
||||
a.setSettingGlobal(keyWatchlistContestCalls, list)
|
||||
a.watchCalls.Store(parseContestCalls(list))
|
||||
applog.Printf("watchlist: %d named contest callsigns", len(parseContestCalls(list)))
|
||||
}
|
||||
|
||||
// parseContestCalls splits the box into a set. One per line is what is asked
|
||||
// for, and commas, semicolons and spaces are accepted too: a list pasted from
|
||||
// an announcement arrives in whatever shape the announcement used.
|
||||
func parseContestCalls(list string) map[string]struct{} {
|
||||
out := map[string]struct{}{}
|
||||
for _, tok := range strings.FieldsFunc(strings.ToUpper(list), func(r rune) bool {
|
||||
return r == ',' || r == ';' || r == ' ' || r == '\t' || r == '\n' || r == '\r'
|
||||
}) {
|
||||
if tok = strings.TrimSpace(tok); tok != "" {
|
||||
out[tok] = struct{}{}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// isNamedContestCall answers the hot path from the cached set.
|
||||
func (a *App) isNamedContestCall(call string) bool {
|
||||
v := a.watchCalls.Load()
|
||||
if v == nil {
|
||||
return false
|
||||
}
|
||||
set, ok := v.(map[string]struct{})
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
_, found := set[strings.ToUpper(strings.TrimSpace(call))]
|
||||
return found
|
||||
}
|
||||
|
||||
// WatchlistEntries returns the list for the tab.
|
||||
func (a *App) WatchlistEntries() []watchlist.Entry {
|
||||
if a.watchlist == nil {
|
||||
@@ -210,12 +266,20 @@ func (a *App) watchSpot(dxCall, band, mode, country, comment string, freqHz int6
|
||||
}
|
||||
entry, notify, ok := a.watchlist.MarkSeen(dxCall)
|
||||
if !ok {
|
||||
// Not watched yet — the auto-contest pattern may claim it. Contains, not
|
||||
// prefix: the event string sits anywhere in these calls (HB9WWA, F4WWA/P).
|
||||
if p := a.GetWatchlistContestPattern(); p != "" &&
|
||||
strings.Contains(strings.ToUpper(dxCall), p) {
|
||||
// Not watched yet — the contest pattern or the named list may claim it.
|
||||
// Contains, not prefix, for the pattern: the event string sits anywhere
|
||||
// in those calls (HB9WWA, F4WWA/P). The named list is exact, and is what
|
||||
// catches the entries whose callsign says nothing about the event.
|
||||
p := a.GetWatchlistContestPattern()
|
||||
byPattern := p != "" && strings.Contains(strings.ToUpper(dxCall), p)
|
||||
byName := a.isNamedContestCall(dxCall)
|
||||
if byPattern || byName {
|
||||
if err := a.watchlist.Add(dxCall, true); err == nil {
|
||||
applog.Printf("watchlist: auto-added %s (contest pattern %q)", dxCall, p)
|
||||
why := fmt.Sprintf("contest pattern %q", p)
|
||||
if byName {
|
||||
why = "named in the contest list"
|
||||
}
|
||||
applog.Printf("watchlist: auto-added %s (%s)", dxCall, why)
|
||||
entry, notify, ok = a.watchlist.MarkSeen(dxCall)
|
||||
if a.ctx != nil {
|
||||
wruntime.EventsEmit(a.ctx, "watchlist:changed")
|
||||
|
||||
+73
-13
@@ -17,6 +17,7 @@ import (
|
||||
const (
|
||||
keyWsjtHighlight = "udp.wsjt.highlight"
|
||||
keyWsjtFollowMode = "udp.wsjt.followmode" // spot clicks switch the decoder's mode
|
||||
keyWsjtHLWorked = "udp.wsjt.highlight_worked"
|
||||
)
|
||||
|
||||
// wsjtModes are the modes a Configure message can meaningfully ask for — the
|
||||
@@ -60,8 +61,55 @@ var (
|
||||
hlNewBand = udp.RGB{R: 226, G: 122, B: 24} // orange
|
||||
hlWhite = udp.RGB{R: 255, G: 255, B: 255}
|
||||
hlBlack = udp.RGB{R: 20, G: 20, B: 20}
|
||||
// Worked already, on this band and in this mode. Grey on purpose, and the
|
||||
// only DIM colour of the four: the others say "look at this", and this one
|
||||
// says the opposite — it has to recede, not compete with them.
|
||||
hlWorked = udp.RGB{R: 75, G: 85, B: 99}
|
||||
hlWorkedFg = udp.RGB{R: 203, G: 213, B: 225}
|
||||
)
|
||||
|
||||
// GetWsjtHighlightWorked reports whether stations already worked on this band
|
||||
// and mode are greyed out as well.
|
||||
//
|
||||
// Its own switch, and off by default. The other three verdicts pick out a
|
||||
// handful of decodes in a period; this one can match most of them on a
|
||||
// well-filled log, and a screen where nearly every line is coloured has stopped
|
||||
// saying anything. It is worth having only for an operator who wants the dupes
|
||||
// struck out rather than the catches picked out.
|
||||
func (a *App) GetWsjtHighlightWorked() bool {
|
||||
return a.settingOr(keyWsjtHLWorked, "0") == "1"
|
||||
}
|
||||
|
||||
// SetWsjtHighlightWorked flips it, and repaints.
|
||||
//
|
||||
// Turning it OFF has to clear what it painted: those callsigns keep their grey
|
||||
// in the decoder's window otherwise, and nothing would ever say another word
|
||||
// about them — the de-duplication remembers that they were already told.
|
||||
func (a *App) SetWsjtHighlightWorked(on bool) {
|
||||
v := "0"
|
||||
if on {
|
||||
v = "1"
|
||||
}
|
||||
a.setSetting(keyWsjtHLWorked, v)
|
||||
a.wsjtHLWorkedOn.Store(on)
|
||||
a.clearWsjtHighlights()
|
||||
applog.Printf("wsjt highlight: worked stations %v", on)
|
||||
}
|
||||
|
||||
// clearWsjtHighlights wipes every instruction OpsLog installed, in every
|
||||
// running decoder, and forgets what it had said.
|
||||
func (a *App) clearWsjtHighlights() {
|
||||
if a.udp == nil {
|
||||
return
|
||||
}
|
||||
for _, inst := range a.udp.Instances() {
|
||||
_ = a.udp.SendClearHighlights(inst)
|
||||
}
|
||||
a.wsjtHLMu.Lock()
|
||||
a.wsjtHLSent = map[string]string{}
|
||||
a.wsjtHLMu.Unlock()
|
||||
}
|
||||
|
||||
// GetWsjtHighlight reports whether decode highlighting is on.
|
||||
func (a *App) GetWsjtHighlight() bool {
|
||||
return a.settingOr(keyWsjtHighlight, "0") == "1"
|
||||
@@ -77,13 +125,8 @@ func (a *App) SetWsjtHighlight(on bool) {
|
||||
}
|
||||
a.setSetting(keyWsjtHighlight, v)
|
||||
a.wsjtHighlightOn.Store(on)
|
||||
if !on && a.udp != nil {
|
||||
for _, inst := range a.udp.Instances() {
|
||||
_ = a.udp.SendClearHighlights(inst)
|
||||
}
|
||||
a.wsjtHLMu.Lock()
|
||||
a.wsjtHLSent = map[string]string{}
|
||||
a.wsjtHLMu.Unlock()
|
||||
if !on {
|
||||
a.clearWsjtHighlights()
|
||||
applog.Printf("wsjt highlight: off — cleared in every instance")
|
||||
}
|
||||
}
|
||||
@@ -92,12 +135,14 @@ func (a *App) SetWsjtHighlight(on bool) {
|
||||
// it, when the option is on and the verdict is worth a colour. De-duplicated
|
||||
// per instance+call+verdict: a station CQing all evening is decoded four times
|
||||
// a minute, and the instruction only needs to be said once.
|
||||
func (a *App) maybeHighlightDecode(instance, call, band string) {
|
||||
func (a *App) maybeHighlightDecode(instance, call, band, mode string) {
|
||||
if !a.wsjtHighlightOn.Load() || a.udp == nil || call == "" || instance == "" {
|
||||
return
|
||||
}
|
||||
bg, fg, verdict := a.decodeHighlightVerdict(call, band)
|
||||
key := instance + "|" + strings.ToUpper(call) + "|" + band
|
||||
bg, fg, verdict := a.decodeHighlightVerdict(call, band, mode)
|
||||
// The MODE is part of the key: one receiver can be handed FT8 and FT4 in
|
||||
// the same session, and the verdict on a callsign is not the same in both.
|
||||
key := instance + "|" + strings.ToUpper(call) + "|" + band + "|" + strings.ToUpper(mode)
|
||||
a.wsjtHLMu.Lock()
|
||||
if a.wsjtHLSent == nil {
|
||||
a.wsjtHLSent = map[string]string{}
|
||||
@@ -124,9 +169,11 @@ func (a *App) maybeHighlightDecode(instance, call, band string) {
|
||||
}
|
||||
|
||||
// decodeHighlightVerdict ranks a callsign: watchlist beats new-DXCC beats
|
||||
// new-band; anything else is "no colour". The empty verdict doubles as the
|
||||
// clear signal in maybeHighlightDecode.
|
||||
func (a *App) decodeHighlightVerdict(call, band string) (bg, fg *udp.RGB, verdict string) {
|
||||
// new-band, and "already worked here" comes last of all — it is the only
|
||||
// verdict that says do NOT call, so anything worth calling for outranks it.
|
||||
// Anything else is "no colour", and the empty verdict doubles as the clear
|
||||
// signal in maybeHighlightDecode.
|
||||
func (a *App) decodeHighlightVerdict(call, band, mode string) (bg, fg *udp.RGB, verdict string) {
|
||||
if a.watchlist != nil {
|
||||
if _, ok := a.watchlist.Match(call); ok {
|
||||
c := hlWatchlist
|
||||
@@ -151,5 +198,18 @@ func (a *App) decodeHighlightVerdict(call, band string) (bg, fg *udp.RGB, verdic
|
||||
}
|
||||
}
|
||||
}
|
||||
// Worked already, this exact callsign on this band in this mode — a dupe,
|
||||
// judged by the same ledger and the same digital-mode grouping the cluster
|
||||
// uses, so the two windows cannot disagree about what "worked" means.
|
||||
if a.wsjtHLWorkedOn.Load() && band != "" && mode != "" {
|
||||
m := strings.ToUpper(strings.TrimSpace(mode))
|
||||
if c.normMode != nil {
|
||||
m = c.normMode(m)
|
||||
}
|
||||
if _, ok := c.workedCallSlots[strings.ToUpper(call)+"|"+strings.ToLower(band)+"|"+m]; ok {
|
||||
bgc, fgc := hlWorked, hlWorkedFg
|
||||
return &bgc, &fgc, "worked"
|
||||
}
|
||||
}
|
||||
return nil, nil, ""
|
||||
}
|
||||
|
||||
+494
@@ -0,0 +1,494 @@
|
||||
package main
|
||||
|
||||
// Auto-call — the wiring around internal/autocall.
|
||||
//
|
||||
// The DECISION is in that package, alone and tested. This file does the three
|
||||
// things it cannot do for itself: cut the decode stream into periods, tell it
|
||||
// what the log still needs from each station, and carry out what it decides.
|
||||
//
|
||||
// It lives in the backend rather than in the panel because it keys a
|
||||
// transmitter: it must behave identically whether the FT decodes tab is open,
|
||||
// behind another tab, or the window is minimised — and because every rule it
|
||||
// applies is then a Go test rather than something only the air can check.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
|
||||
"hamlog/internal/applog"
|
||||
"hamlog/internal/autocall"
|
||||
)
|
||||
|
||||
const (
|
||||
keyAutoCallOn = "autocall.enabled"
|
||||
keyAutoCallOnly = "autocall.only"
|
||||
keyAutoCallAttempts = "autocall.attempts"
|
||||
keyAutoCallWatched = "autocall.watched_attempts"
|
||||
keyAutoCallMisses = "autocall.misses"
|
||||
keyAutoCallRounds = "autocall.max_rounds"
|
||||
keyAutoCallRestMin = "autocall.rest_min"
|
||||
)
|
||||
|
||||
// AutoCallSettings is the panel's shape. Durations are in minutes because that
|
||||
// is what the operator is asked for.
|
||||
type AutoCallSettings struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Only string `json:"only"`
|
||||
// Attempts / WatchedAttempts: how many calls one station gets before it is
|
||||
// released. The larger allowance is for a callsign on the watch list.
|
||||
Attempts int `json:"attempts"`
|
||||
WatchedAttempts int `json:"watched_attempts"`
|
||||
// Misses: periods in which the station itself transmits, with no decode of
|
||||
// it, before it is given up on.
|
||||
Misses int `json:"misses"`
|
||||
// MaxRounds: how many series of calls one station gets in a session, and
|
||||
// RestMin the pause between two of them.
|
||||
MaxRounds int `json:"max_rounds"`
|
||||
RestMin int `json:"rest_min"`
|
||||
}
|
||||
|
||||
func (a *App) GetAutoCallSettings() AutoCallSettings {
|
||||
d := autocall.Defaults()
|
||||
num := func(key string, def int) int {
|
||||
n, err := strconv.Atoi(strings.TrimSpace(a.settingOr(key, "")))
|
||||
if err != nil || n <= 0 {
|
||||
return def
|
||||
}
|
||||
return n
|
||||
}
|
||||
return AutoCallSettings{
|
||||
// Never on from a stored value alone — see startAutoCall.
|
||||
Enabled: a.settingOr(keyAutoCallOn, "0") == "1",
|
||||
Only: strings.ToUpper(strings.TrimSpace(a.settingOr(keyAutoCallOnly, ""))),
|
||||
Attempts: num(keyAutoCallAttempts, d.Attempts),
|
||||
WatchedAttempts: num(keyAutoCallWatched, d.WatchedAttempts),
|
||||
Misses: num(keyAutoCallMisses, d.Misses),
|
||||
MaxRounds: num(keyAutoCallRounds, d.MaxRounds),
|
||||
RestMin: num(keyAutoCallRestMin, int(d.Rest/time.Minute)),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) SaveAutoCallSettings(s AutoCallSettings) error {
|
||||
a.setSetting(keyAutoCallOn, map[bool]string{true: "1", false: "0"}[s.Enabled])
|
||||
a.setSetting(keyAutoCallOnly, strings.ToUpper(strings.TrimSpace(s.Only)))
|
||||
for key, v := range map[string]int{
|
||||
keyAutoCallAttempts: s.Attempts, keyAutoCallWatched: s.WatchedAttempts,
|
||||
keyAutoCallMisses: s.Misses, keyAutoCallRounds: s.MaxRounds,
|
||||
keyAutoCallRestMin: s.RestMin,
|
||||
} {
|
||||
if v > 0 {
|
||||
a.setSetting(key, strconv.Itoa(v))
|
||||
}
|
||||
}
|
||||
a.applyAutoCall()
|
||||
applog.Printf("autocall: %v (only=%q, %d/%d calls, %d misses, %d rounds)",
|
||||
s.Enabled, s.Only, s.Attempts, s.WatchedAttempts, s.Misses, s.MaxRounds)
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetAutoCallOnly is the chase-list field in the decodes toolbar.
|
||||
//
|
||||
// Its own binding rather than a settings round-trip: the toolbar knows one
|
||||
// field, and handing back a whole struct it never read is how a Preferences
|
||||
// window left open somewhere quietly reverts a limit that was just changed.
|
||||
func (a *App) SetAutoCallOnly(list string) error {
|
||||
s := a.GetAutoCallSettings()
|
||||
s.Only = list
|
||||
return a.SaveAutoCallSettings(s)
|
||||
}
|
||||
|
||||
// SetAutoCall is the toolbar switch above the decodes.
|
||||
func (a *App) SetAutoCall(on bool) error {
|
||||
s := a.GetAutoCallSettings()
|
||||
s.Enabled = on
|
||||
return a.SaveAutoCallSettings(s)
|
||||
}
|
||||
|
||||
// autoCallEngine returns the engine, built on first use.
|
||||
func (a *App) autoCallEngine() *autocall.Engine {
|
||||
a.acMu.Lock()
|
||||
defer a.acMu.Unlock()
|
||||
if a.ac == nil {
|
||||
a.ac = autocall.New(a.autoCallSettings())
|
||||
}
|
||||
return a.ac
|
||||
}
|
||||
|
||||
func (a *App) autoCallSettings() autocall.Settings {
|
||||
s := a.GetAutoCallSettings()
|
||||
return autocall.Settings{
|
||||
Enabled: s.Enabled, Only: s.Only,
|
||||
Attempts: s.Attempts, WatchedAttempts: s.WatchedAttempts,
|
||||
Misses: s.Misses, MaxRounds: s.MaxRounds,
|
||||
Rest: time.Duration(s.RestMin) * time.Minute,
|
||||
}
|
||||
}
|
||||
|
||||
// applyAutoCall pushes the settings into the engine, and clears its state when
|
||||
// the feature is switched off — an operator turning it off is entitled to have
|
||||
// it forget the station it was calling, not resume it half an hour later.
|
||||
func (a *App) applyAutoCall() {
|
||||
e := a.autoCallEngine()
|
||||
s := a.autoCallSettings()
|
||||
e.SetSettings(s)
|
||||
if !s.Enabled {
|
||||
e.Reset()
|
||||
a.acMu.Lock()
|
||||
a.acPeriod, a.acBuf = nil, nil
|
||||
a.acMu.Unlock()
|
||||
}
|
||||
a.emitAutoCall()
|
||||
}
|
||||
|
||||
// ResetAutoCall is the operator's restart after it gave up — and what Halt
|
||||
// does, since halting means "not this station".
|
||||
func (a *App) ResetAutoCall() {
|
||||
a.autoCallEngine().Reset()
|
||||
a.emitAutoCall()
|
||||
}
|
||||
|
||||
// AutoCallStatus is what the toolbar shows.
|
||||
type AutoCallStatus struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
// Only is the chase list, carried in the status so the field in the decodes
|
||||
// toolbar and the one in Preferences are never two versions of the truth:
|
||||
// whichever is typed into, both show it.
|
||||
Only string `json:"only"`
|
||||
Target string `json:"target"`
|
||||
Calls int `json:"calls"`
|
||||
Max int `json:"max"`
|
||||
Misses int `json:"misses"`
|
||||
MaxMiss int `json:"max_miss"`
|
||||
Stopped bool `json:"stopped"`
|
||||
// Reason is the last decision in plain words. An auto-call that is doing
|
||||
// nothing on purpose looks exactly like one that is broken.
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
func (a *App) GetAutoCallStatus() AutoCallStatus {
|
||||
st := a.autoCallEngine().Status()
|
||||
a.acMu.Lock()
|
||||
reason := a.acReason
|
||||
a.acMu.Unlock()
|
||||
set := a.GetAutoCallSettings()
|
||||
return AutoCallStatus{
|
||||
Enabled: set.Enabled, Only: set.Only,
|
||||
Target: st.Target, Calls: st.Attempts, Max: st.Max,
|
||||
Misses: st.Misses, MaxMiss: st.MaxMiss, Stopped: st.Stopped,
|
||||
Reason: reason,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) emitAutoCall() {
|
||||
if a.ctx == nil {
|
||||
return
|
||||
}
|
||||
wruntime.EventsEmit(a.ctx, "autocall:status", a.GetAutoCallStatus())
|
||||
}
|
||||
|
||||
// TakeAutoCallTarget adopts the station the operator has just clicked, so a
|
||||
// manual pick gets the same watchdogs as an automatic one — the click is the
|
||||
// choice of station, not a decision to call it for ever.
|
||||
func (a *App) TakeAutoCallTarget(call, band, mode string) {
|
||||
if !a.GetAutoCallSettings().Enabled {
|
||||
return
|
||||
}
|
||||
call = strings.ToUpper(strings.TrimSpace(call))
|
||||
if call == "" {
|
||||
return
|
||||
}
|
||||
a.autoCallEngine().Take(autocall.Candidate{
|
||||
Decode: autocall.Decode{Call: call, Band: band, Mode: mode, At: time.Now().UTC(), IsNew: true},
|
||||
Need: a.autoCallNeed(call, band, mode),
|
||||
Watched: a.autoCallWatched(call),
|
||||
})
|
||||
a.emitAutoCall()
|
||||
}
|
||||
|
||||
// ── The decode stream, cut into periods ───────────────────────────────────
|
||||
|
||||
// acDecode is one decode held until its period is complete.
|
||||
type acDecode struct {
|
||||
d autocall.Decode
|
||||
tx bool // the decode is our own transmission echoed back
|
||||
}
|
||||
|
||||
// autoCallFeed takes one decode from the UDP loop.
|
||||
//
|
||||
// Decodes arrive one datagram at a time and a decision needs the whole period:
|
||||
// the best station in it, and whether the target was there at all. They are
|
||||
// therefore buffered under the period they belong to, and the period is judged
|
||||
// when the next one starts — or, if the band goes quiet, by the sweeper below,
|
||||
// which is what makes "not decoded for three of its periods" reachable when the
|
||||
// answer is that nothing is being decoded at all.
|
||||
func (a *App) autoCallFeed(d autocall.Decode) {
|
||||
if !a.GetAutoCallSettings().Enabled {
|
||||
return
|
||||
}
|
||||
inst := d.Instance
|
||||
key := acPeriodKey(d.At, d.TRPeriod)
|
||||
a.acMu.Lock()
|
||||
if a.acPeriod == nil {
|
||||
a.acPeriod, a.acAt, a.acTR, a.acBuf = map[string]string{}, map[string]time.Time{}, map[string]int{}, map[string][]acDecode{}
|
||||
}
|
||||
if prev := a.acPeriod[inst]; prev != "" && prev != key {
|
||||
prevAt, prevTR, buf := a.acAt[inst], a.acTR[inst], a.acBuf[inst]
|
||||
a.acPeriod[inst], a.acAt[inst], a.acTR[inst] = key, d.At, d.TRPeriod
|
||||
a.acBuf[inst] = []acDecode{{d: d}}
|
||||
a.acMu.Unlock()
|
||||
a.autoCallJudge(inst, prev, prevAt, prevTR, buf)
|
||||
return
|
||||
}
|
||||
a.acPeriod[inst], a.acAt[inst], a.acTR[inst] = key, d.At, d.TRPeriod
|
||||
a.acBuf[inst] = append(a.acBuf[inst], acDecode{d: d})
|
||||
a.acMu.Unlock()
|
||||
}
|
||||
|
||||
// autoCallSweep closes the periods nothing has closed for us. Called on a timer.
|
||||
//
|
||||
// Per receiver, because with two decoders one may fall silent while the other
|
||||
// is busy — and it is the silent one's period that has to close for a missed
|
||||
// period to be counted at all.
|
||||
func (a *App) autoCallSweep() {
|
||||
if !a.GetAutoCallSettings().Enabled {
|
||||
return
|
||||
}
|
||||
type due struct {
|
||||
inst, key string
|
||||
at time.Time
|
||||
tr int
|
||||
buf []acDecode
|
||||
}
|
||||
var ready []due
|
||||
a.acMu.Lock()
|
||||
for inst, key := range a.acPeriod {
|
||||
if key == "" {
|
||||
continue
|
||||
}
|
||||
tr := a.acTR[inst]
|
||||
if tr <= 0 {
|
||||
tr = 15
|
||||
}
|
||||
// One slot plus a margin: decodes for a period keep arriving for a
|
||||
// second or two after it ends, and judging early would count a station
|
||||
// as missing that is about to be listed.
|
||||
if time.Since(a.acAt[inst]) < time.Duration(tr)*time.Second+4*time.Second {
|
||||
continue
|
||||
}
|
||||
ready = append(ready, due{inst, key, a.acAt[inst], tr, a.acBuf[inst]})
|
||||
delete(a.acPeriod, inst)
|
||||
delete(a.acBuf, inst)
|
||||
}
|
||||
a.acMu.Unlock()
|
||||
for _, d := range ready {
|
||||
a.autoCallJudge(d.inst, d.key, d.at, d.tr, d.buf)
|
||||
}
|
||||
}
|
||||
|
||||
// autoCallSilence is the empty period. With the band dead, no decode ever
|
||||
// arrives to close the next one, and the target's absence would never be
|
||||
// counted — so a period with nothing in it is still a period.
|
||||
//
|
||||
// Only for the receiver the target is being called on: an idle second decoder
|
||||
// has no periods to miss.
|
||||
func (a *App) autoCallSilence() {
|
||||
if !a.GetAutoCallSettings().Enabled {
|
||||
return
|
||||
}
|
||||
inst, target := a.autoCallEngine().TargetInstance()
|
||||
if target == "" {
|
||||
return
|
||||
}
|
||||
a.acMu.Lock()
|
||||
quiet := a.acPeriod[inst] == "" && time.Since(a.acLastJudge) > 20*time.Second
|
||||
tr := a.acTR[inst]
|
||||
a.acMu.Unlock()
|
||||
if !quiet {
|
||||
return
|
||||
}
|
||||
now := time.Now().UTC()
|
||||
a.autoCallJudge(inst, acPeriodKey(now, tr), now, tr, nil)
|
||||
}
|
||||
|
||||
func acPeriodKey(at time.Time, trSec int) string {
|
||||
if trSec <= 0 {
|
||||
trSec = 15
|
||||
}
|
||||
return fmt.Sprintf("%d", at.UTC().Unix()/int64(trSec))
|
||||
}
|
||||
|
||||
// autoCallJudge resolves what the log needs from each station in the period,
|
||||
// runs the decision, and carries it out.
|
||||
func (a *App) autoCallJudge(inst, key string, at time.Time, tr int, buf []acDecode) {
|
||||
a.acMu.Lock()
|
||||
a.acLastJudge = time.Now()
|
||||
a.acMu.Unlock()
|
||||
|
||||
// One status call for the whole period. It reads a cached worked-index, but
|
||||
// it is still per-callsign work and a busy period is thirty of them.
|
||||
seen := map[string]bool{}
|
||||
var q []SpotQuery
|
||||
var uniq []acDecode
|
||||
for _, dd := range buf {
|
||||
k := dd.d.Call + "|" + dd.d.Band + "|" + dd.d.Mode
|
||||
if seen[k] {
|
||||
// The same station twice in one period is one candidate, judged on
|
||||
// its most callable line — the engine's bestOf does that, so both
|
||||
// decodes are kept; only the status lookup is deduplicated.
|
||||
uniq = append(uniq, dd)
|
||||
continue
|
||||
}
|
||||
seen[k] = true
|
||||
uniq = append(uniq, dd)
|
||||
q = append(q, SpotQuery{Call: dd.d.Call, Band: dd.d.Band, Mode: dd.d.Mode})
|
||||
}
|
||||
status := map[string]SpotStatus{}
|
||||
for _, st := range a.ClusterSpotStatuses(q) {
|
||||
status[st.Call+"|"+st.Band+"|"+st.Mode] = st
|
||||
}
|
||||
|
||||
cands := make([]autocall.Candidate, 0, len(uniq))
|
||||
for _, dd := range uniq {
|
||||
st := status[dd.d.Call+"|"+dd.d.Band+"|"+dd.d.Mode]
|
||||
cands = append(cands, autocall.Candidate{
|
||||
Decode: dd.d,
|
||||
Need: autoCallNeedOf(st.Status),
|
||||
Watched: a.autoCallWatched(dd.d.Call),
|
||||
Worked: st.Status == "worked",
|
||||
})
|
||||
}
|
||||
|
||||
tx := a.autoCallTX()
|
||||
act := a.autoCallEngine().OnPeriod(autocall.Period{
|
||||
Instance: inst, Key: key, At: at, TRPeriod: tr, Decodes: cands, TX: tx,
|
||||
MyCall: a.opCall,
|
||||
})
|
||||
a.autoCallDo(act)
|
||||
}
|
||||
|
||||
// autoCallDo carries out a decision and records it.
|
||||
func (a *App) autoCallDo(act autocall.Action) {
|
||||
if act.Reason != "" {
|
||||
a.acMu.Lock()
|
||||
a.acReason = act.Reason
|
||||
a.acMu.Unlock()
|
||||
applog.Printf("autocall: %s", act.Reason)
|
||||
}
|
||||
switch act.Kind {
|
||||
case autocall.DoReply:
|
||||
d := act.Decode
|
||||
if err := a.AnswerDecode(d.Instance, d.Ms, d.SNR, d.DT, d.AudioHz, d.ModeRaw, d.MsgRaw, d.LowConf); err != nil {
|
||||
applog.Printf("autocall: the call to %s could not be sent: %v", d.Call, err)
|
||||
}
|
||||
case autocall.DoHalt:
|
||||
// autoTxOnly=false: stop now. The whole point of a brake is that it does
|
||||
// not wait for the over in progress to finish.
|
||||
if err := a.HaltDecodeTx("", false); err != nil {
|
||||
applog.Printf("autocall: halt failed: %v", err)
|
||||
}
|
||||
}
|
||||
if act.Kind != autocall.DoNothing || act.Reason != "" {
|
||||
a.emitAutoCall()
|
||||
}
|
||||
}
|
||||
|
||||
// autoCallNoteTX is the attempt counter, fed from the decoder's own status.
|
||||
//
|
||||
// ONCE PER TRANSMIT PERIOD. Status arrives every second and says "transmitting"
|
||||
// throughout the over, so counting each one would spend the whole allowance of
|
||||
// seven calls inside a single fifteen-second slot — the counter has to measure
|
||||
// transmissions, not seconds of carrier.
|
||||
func (a *App) autoCallNoteTX(tx autocall.TXState) {
|
||||
if !a.GetAutoCallSettings().Enabled {
|
||||
return
|
||||
}
|
||||
a.acMu.Lock()
|
||||
// Per receiver as well as per period: in a split view both decoders report
|
||||
// their own transmissions, and one key for both would let the second one's
|
||||
// carrier swallow the first one's count.
|
||||
key := tx.Instance + "|" + acPeriodKey(time.Now().UTC(), a.acTR[tx.Instance])
|
||||
if a.acTXPeriod == key {
|
||||
a.acMu.Unlock()
|
||||
return
|
||||
}
|
||||
a.acTXPeriod = key
|
||||
a.acMu.Unlock()
|
||||
a.autoCallDo(a.autoCallEngine().NoteTX(tx))
|
||||
}
|
||||
|
||||
// autoCallTX is the last transmit state reported, as the engine wants it.
|
||||
func (a *App) autoCallTX() autocall.TXState {
|
||||
a.acMu.Lock()
|
||||
defer a.acMu.Unlock()
|
||||
return a.acTX
|
||||
}
|
||||
|
||||
func (a *App) autoCallSetTX(tx autocall.TXState) {
|
||||
a.acMu.Lock()
|
||||
a.acTX = tx
|
||||
a.acMu.Unlock()
|
||||
}
|
||||
|
||||
// autoCallNeedOf maps the cluster's own status vocabulary onto the ladder. One
|
||||
// vocabulary for both, so a station that reads NEW BAND in the decodes list is
|
||||
// the same NEW BAND the auto-call ranks — two answers to one question is how
|
||||
// the panel and the caller quietly start disagreeing.
|
||||
func autoCallNeedOf(status string) autocall.Need {
|
||||
switch status {
|
||||
case "new":
|
||||
return autocall.NeedDXCC
|
||||
case "new-band-mode", "new-band":
|
||||
// New on both counts is at least a new band, and it is the better catch
|
||||
// of the two — it must not fall below a plain new band.
|
||||
return autocall.NeedBand
|
||||
case "new-mode":
|
||||
return autocall.NeedMode
|
||||
case "new-slot":
|
||||
return autocall.NeedSlot
|
||||
}
|
||||
return autocall.NeedNone
|
||||
}
|
||||
|
||||
func (a *App) autoCallNeed(call, band, mode string) autocall.Need {
|
||||
st := a.ClusterSpotStatuses([]SpotQuery{{Call: call, Band: band, Mode: mode}})
|
||||
if len(st) == 0 {
|
||||
return autocall.NeedNone
|
||||
}
|
||||
return autoCallNeedOf(st[0].Status)
|
||||
}
|
||||
|
||||
// autoCallWatched asks the watch list, which is the same list the spot alerts
|
||||
// and the cluster colouring use.
|
||||
func (a *App) autoCallWatched(call string) bool {
|
||||
if a.watchlist == nil {
|
||||
return false
|
||||
}
|
||||
_, ok := a.watchlist.Match(strings.ToUpper(strings.TrimSpace(call)))
|
||||
return ok
|
||||
}
|
||||
|
||||
// startAutoCall arms the engine at launch.
|
||||
//
|
||||
// The stored "on" is honoured, and the engine starts with NO target: a program
|
||||
// that came up already calling a station chosen before the last shutdown is not
|
||||
// something an operator can be expected to anticipate.
|
||||
func (a *App) startAutoCall() {
|
||||
a.applyAutoCall()
|
||||
go a.autoCallLoop()
|
||||
}
|
||||
|
||||
func (a *App) autoCallLoop() {
|
||||
t := time.NewTicker(2 * time.Second)
|
||||
defer t.Stop()
|
||||
for range t.C {
|
||||
if a.ctx == nil {
|
||||
return
|
||||
}
|
||||
a.autoCallSweep()
|
||||
a.autoCallSilence()
|
||||
}
|
||||
}
|
||||
+27
-4
@@ -93,14 +93,27 @@ func keepKnownBands(want []string) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// pskrMaxGrids bounds the receiver squares the broker is asked to filter on.
|
||||
// Each is one subscription, and the traffic follows the area: 2000 km is about
|
||||
// 615 squares, which the broker takes in batches without complaint. The cap is
|
||||
// there so an absurd radius cannot turn into thousands of subscriptions — past
|
||||
// it the nearest squares are kept, and the log says how many.
|
||||
const pskrMaxGrids = 900
|
||||
|
||||
// bandOpenNearKm reads the stored receiver radius, falling back to the default
|
||||
// for anything unset or out of range. The bounds are the two ways to make the
|
||||
// watch useless: below 25 km almost nobody is ever near enough to hear anything,
|
||||
// and past 1000 km the reports stop being about the operator's own path — which
|
||||
// is the entire premise of measuring from a receiver rather than a transmitter.
|
||||
// and past 3000 km a "nearby" receiver is on the far side of a continent, which
|
||||
// says nothing about the operator's own path.
|
||||
//
|
||||
// The ceiling was 1000 km, chosen with Europe in mind, where that radius holds a
|
||||
// dozen countries' worth of receivers. It is the wrong number in VK: a station
|
||||
// there can have almost nobody inside 300 km, and the chase list stayed empty
|
||||
// not because nothing was on the air but because nothing was listening close
|
||||
// enough to count.
|
||||
func bandOpenNearKm(raw string) int {
|
||||
n, err := strconv.Atoi(strings.TrimSpace(raw))
|
||||
if err != nil || n < 25 || n > 1000 {
|
||||
if err != nil || n < 25 || n > 3000 {
|
||||
return pskr.DefaultNearKm
|
||||
}
|
||||
return n
|
||||
@@ -194,7 +207,17 @@ func (a *App) startBandOpenFeed() {
|
||||
// hundred survived the NearKm test below. One ring of squares — about the
|
||||
// same 300 km — is 0.2 to 1.2 a second, and the same for every operator,
|
||||
// where filtering by DXCC ranged from 1.2 (OH) to 72.5 (K).
|
||||
rxGrids := geo.NeighbourGrids(a.opLat, a.opLon, 1)
|
||||
//
|
||||
// The set follows the radius the operator asked for. It was one fixed ring
|
||||
// whatever they set — about 300 km — so raising the radius bought nothing:
|
||||
// the reports that would have satisfied it were never sent to us in the
|
||||
// first place, and an operator in a thinly-populated region who widened the
|
||||
// circle to find some receivers saw no change at all.
|
||||
rxGrids := geo.GridsWithin(a.opLat, a.opLon, float64(s.NearKm), pskrMaxGrids)
|
||||
if len(rxGrids) == 0 {
|
||||
rxGrids = geo.NeighbourGrids(a.opLat, a.opLon, 1)
|
||||
}
|
||||
applog.Printf("pskr: receiver filter — %d squares within %d km of the station", len(rxGrids), s.NearKm)
|
||||
|
||||
var onGrid func(call, grid string)
|
||||
if chaseGrids {
|
||||
|
||||
+110
@@ -1,4 +1,114 @@
|
||||
[
|
||||
{
|
||||
"version": "0.27.12",
|
||||
"date": "",
|
||||
"en": [
|
||||
"Help menu: “Join the Discord” opens the OpsLog Discord server in your browser.",
|
||||
"Icom console: a tick box makes the band buttons recall the radio's own band stacking registers — where you last were on that band, in the mode you were in. Press the same band again to step through its three registers, exactly as the radio's band key does. A band the register cannot be read for still sends the fixed frequency.",
|
||||
"Shared CAT: a frequency or mode just commanded is reported back at once instead of on the next poll, and a mode the radio is already in is no longer re-sent. WSJT-X waits for that readback before it believes the band changed — over a network CI-V link that wait was several seconds.",
|
||||
"Chase new / band openings: the receiver radius goes up to 3000 km, and the PSK Reporter subscription now follows it. Widening the circle used to change nothing, because the reports it would have accepted were never sent to us. 300 km holds no receivers at all in much of VK, ZL or North America.",
|
||||
"The radius is also reachable from the Chase new option itself, rather than only from inside the band-opening watch.",
|
||||
"New PSK Reporter panel beside the FT decodes, which can be hidden: for the station you are calling, has he decoded YOU and how long ago, who near you he is hearing, who near him heard you, how many stations he is working through, and where his receive passband is free. Follows the station you click or call. Off by default — Settings → DXHunter/spots. The narrow feed is a few messages a second; a whole-band option is there for a fast machine.",
|
||||
"FT Map: the arcs no longer run off the side of the map. The map shows one world, and a path crossing the antimeridian was drawn past 180° into the blank space beside it — from VK or ZL that is most of them, each one ending nowhere while its own marker sat on the far coast. A path now leaves one edge and re-enters at the other, at the latitude it left.",
|
||||
"NEW — Auto-call: OpsLog can answer FT8/FT4 decodes on its own. It picks the best station on the air by what the log still needs — a watched callsign outranking the same need from anybody else — and, above all, it knows when to stop: 7 calls (15 for a watched callsign), 3 of the station’s own transmit periods with no decode of it, a four-minute backstop, and three series per station for a whole session. A station in the middle of a QSO with somebody else is never called, because it cannot answer. Every decision is written to the log with its reason, the toolbar button shows the target and the count as it goes, and Halt stops it. OFF by default — Settings → DXHunter/spots. It keys your transmitter without asking, so read that panel’s warning before switching it on, and switch DXHunter’s own auto-call off: two programs answering decodes from one shack transmit over each other.",
|
||||
"PSK Reporter panel: the window is ten minutes, and the history query now fills BOTH directions when the target changes. Side by side with DXHunter on the same station at the same moment it showed 18 decodes against 27, and a co-area station missing — five minutes catches about one upload cycle per reporting station, and most of them report every five.",
|
||||
"Auto-call: “Chase only” takes SEVERAL callsigns, separated by spaces or commas. Nothing off the list is called, the priority ladder still orders the ones on it, and working one leaves the others callable.",
|
||||
"Two new themes on DXHunter’s palette: “DXHunter”, its slate and its blue exactly, and “DXHunter orange”, the same slate with OpsLog’s own orange accent. Both carry its status colours (emerald, amber, cyan, red), so a green number means the same thing in either window. Settings → General → Theme.",
|
||||
"The auto-call chase list is also in the decodes toolbar, beside the Auto button: naming the station you are waiting for is done while watching the band, not in a settings tree. It is the same setting as the one in Preferences — type into either and both show it.",
|
||||
"FT decodes: one click SELECTS a station — it fills the entry and points the panels at it, like a cluster spot — and a double click calls it. A single click used to hand the decode straight to WSJT-X as a reply, so brushing a row while reading the band started transmitting.",
|
||||
"Auto-call with two decoders running: while a station is being called, a period from the other receiver is not looked at. It cannot start a second QSO over the one in progress however good the station it hears, its periods count no missed periods against a target that was never on its band, and its transmissions are not counted as calls to that target.",
|
||||
"Watchlist: drawn as DXHunter draws it — the callsign in the interface font rather than monospaced (the difference that shows with the two windows side by side), badges at its size, a check or a warning triangle at the head of each spot line, and frequencies as 7.056 rather than 7.0560.",
|
||||
"A decoder is named by what it IS, not by what it announces: Nexus sends its packets as “Tempo”, the engine inside it, and OpsLog showed a program the operator had never heard of. The id itself is untouched — it is what a reply, a halt and the auto-call are routed by.",
|
||||
"WSJT-X colouring can grey out a station already worked on this band AND in this mode — the duplicate. Its own switch under the highlight option, off by default: the other three verdicts pick out a handful of decodes, this one can match most of a period on a well-filled log. Grey rather than a colour, because it says the opposite of the others.",
|
||||
"Contest watchlist (Settings → DXHunter): beside the auto-add pattern there is now a list of callsigns, one per line. A pattern collects a fleet that shares a string — TM29WWA, HB9WWA, F4WWA/P — but not the station taking part under a callsign that says nothing about the event. Named in the list, it joins the contest watchlist the moment it is spotted."
|
||||
],
|
||||
"fr": [
|
||||
"Menu Aide : « Rejoindre le Discord » ouvre le serveur Discord d’OpsLog dans votre navigateur.",
|
||||
"Console Icom : une case à cocher fait rappeler aux boutons de bande les registres de bande de la radio — là où vous étiez la dernière fois sur cette bande, dans le mode où vous étiez. Réappuyez sur la même bande pour parcourir ses trois registres, comme le fait la touche de bande du poste. Une bande dont le registre est illisible envoie toujours la fréquence fixe.",
|
||||
"CAT partagé : une fréquence ou un mode qu’on vient de commander est renvoyé immédiatement, sans attendre le sondage suivant, et un mode que la radio a déjà n’est plus réémis. WSJT-X attend cette relecture avant de croire au changement de bande — sur une liaison CI-V réseau, cette attente durait plusieurs secondes.",
|
||||
"Chase new / ouvertures : le rayon des récepteurs monte à 3000 km, et l’abonnement PSK Reporter le suit désormais. Élargir le cercle ne changeait rien, car les reports qu’il aurait acceptés ne nous étaient jamais envoyés. 300 km ne contient aucun récepteur dans une bonne partie de VK, ZL ou d’Amérique du Nord.",
|
||||
"Ce rayon est aussi accessible depuis l’option Chase new elle-même, et non plus seulement depuis la veille d’ouvertures.",
|
||||
"Nouveau panneau PSK Reporter à côté des décodages FTx, masquable : pour la station que vous appelez, vous a-t-il décodé et depuis combien de temps, qui entend-il près de chez vous, qui près de lui vous a entendu, combien de stations défilent chez lui, et où son passe-bande est libre. Il suit la station que vous cliquez ou appelez. Désactivé par défaut — Réglages → DXHunter/spots. Le flux étroit ne coûte que quelques messages par seconde ; une option « toute la bande » existe pour une machine rapide.",
|
||||
"FT Map : les arcs ne partent plus hors de la carte. La carte n’affiche qu’un seul monde, et un chemin franchissant l’antiméridien était tracé au-delà de 180°, dans le vide à côté — depuis VK ou ZL c’est la majorité d’entre eux, chacun finissant nulle part alors que son propre marqueur était sur la côte opposée. Un chemin sort désormais par un bord et revient par l’autre, à la latitude où il est sorti.",
|
||||
"NOUVEAU — Appel automatique : OpsLog peut répondre seul aux décodages FT8/FT4. Il choisit la meilleure station en fonction de ce qui manque au log — un indicatif surveillé passant devant le même besoin chez un autre — et surtout il sait s’arrêter : 7 appels (15 pour un indicatif surveillé), 3 périodes d’émission de la station sans la décoder, un butoir de quatre minutes, et trois séries par station pour toute une session. Une station en plein QSO avec quelqu’un d’autre n’est jamais appelée : elle ne peut pas répondre. Chaque décision est écrite dans le journal avec sa raison, le bouton de la barre affiche la cible et le décompte en direct, et Stop l’interrompt. DÉSACTIVÉ par défaut — Réglages → DXHunter/spots. Il met votre émetteur en marche sans vous demander : lisez l’avertissement du panneau avant de l’activer, et coupez l’appel automatique de DXHunter — deux programmes qui répondent aux décodages du même shack s’émettent dessus.",
|
||||
"Panneau PSK Reporter : la fenêtre passe à dix minutes, et la requête d’historique remplit désormais les DEUX sens au changement de cible. Côte à côte avec DXHunter sur la même station au même instant, il affichait 18 décodages contre 27, et une station de la région manquait — cinq minutes ne captent qu’un cycle d’envoi par station, et la plupart n’envoient que toutes les cinq minutes.",
|
||||
"Appel automatique : « Chasser uniquement » accepte PLUSIEURS indicatifs, séparés par des espaces ou des virgules. Rien hors de la liste n’est appelé, l’échelle de priorité départage ceux qui y sont, et en travailler un laisse les autres appelables.",
|
||||
"Deux nouveaux thèmes sur la palette de DXHunter : « DXHunter », son ardoise et son bleu à l’identique, et « DXHunter orange », la même ardoise avec l’orange d’OpsLog. Les deux reprennent ses couleurs d’état (émeraude, ambre, cyan, rouge) : un nombre vert veut dire la même chose dans les deux fenêtres. Réglages → Général → Thème.",
|
||||
"La liste de chasse de l’appel automatique est aussi dans la barre des décodages, à côté du bouton Auto : nommer la station qu’on attend se fait en regardant la bande, pas dans un arbre de réglages. C’est le même réglage que dans les Préférences — saisi dans l’un, il apparaît dans l’autre.",
|
||||
"Décodages FT : un clic SÉLECTIONNE une station — il remplit la saisie et y pointe les panneaux, comme un spot du cluster — et un double-clic l’appelle. Un simple clic passait le décodage directement à WSJT-X en réponse : frôler une ligne en lisant la bande déclenchait une émission.",
|
||||
"Appel automatique avec deux décodeurs : pendant qu’une station est appelée, une période de l’autre récepteur n’est pas examinée. Il ne peut pas ouvrir un second QSO par-dessus celui en cours, si bonne que soit la station qu’il entend ; ses périodes ne comptent aucune période manquée contre une cible qui n’a jamais été sur sa bande, et ses émissions ne comptent pas comme des appels vers elle.",
|
||||
"Watchlist : dessinée comme DXHunter la dessine — l’indicatif dans la police de l’interface plutôt qu’en chasse fixe (la différence qui saute aux yeux avec les deux fenêtres côte à côte), pastilles à sa taille, coche ou triangle d’alerte en tête de chaque ligne de spot, et fréquences en 7.056 plutôt que 7.0560.",
|
||||
"Un décodeur est nommé par ce qu’il EST, non par ce qu’il annonce : Nexus envoie ses paquets sous le nom « Tempo », le moteur qu’il embarque, et OpsLog affichait un programme inconnu de l’opérateur. L’identifiant lui-même n’est pas touché : c’est par lui que passent une réponse, un Stop et l’appel automatique.",
|
||||
"Coloration WSJT-X : possibilité de griser une station déjà travaillée sur cette bande ET dans ce mode — le doublon. Sa propre case sous l’option de coloration, désactivée par défaut : les trois autres verdicts désignent quelques décodages, celui-ci peut concerner la majorité d’une période sur un log bien rempli. En gris et non en couleur, car il dit l’inverse des autres.",
|
||||
"Watchlist contest (Réglages → DXHunter) : à côté du motif d’ajout automatique, une liste d’indicatifs, un par ligne. Un motif attrape une flotte qui partage une chaîne — TM29WWA, HB9WWA, F4WWA/P — mais pas la station engagée sous un indicatif qui ne dit rien de l’événement. Nommée dans la liste, elle rejoint la watchlist contest dès qu’elle est spottée."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.27.11",
|
||||
"date": "",
|
||||
"en": [
|
||||
"Country resolution with the ClubLog file enabled: retired prefixes are recognised again. cty.dat describes the world as it is TODAY — Niue moved to E6, so ZK2 reverted to New Zealand there, and every ZK2 contact ever made was silently relabelled New Zealand, taking a confirmed entity out of the operator’s DXCC with it. ZK1 lost the Cook Islands the same way. ClubLog’s prefix table still knows both and is now consulted whenever no per-callsign exception applies, instead of only for callsigns that happened to have one. It never overrules an exact “=CALLSIGN” entry in cty.dat, and where it has no answer cty.dat still decides. Reprocess an affected import with Update from ClubLog.",
|
||||
"CQ and ITU zones now come from the callbook when it has them. cty.dat carries ONE representative pair per entity, and OpsLog was stamping it over QRZ.com’s per-station answer — so every Asiatic Russia contact was logged CQ 17 / ITU 30, whatever the operator’s real zone (RU0LL is 19/34, UA0SDX 18/32). That is a WAZ credit for a zone never worked. The entity still comes from cty.dat, which is the authority on what a callsign IS; a zone says where the station SITS, and only the callbook knows that within a country eight CQ zones wide. Where the callbook is silent, cty.dat fills as before.",
|
||||
"Callsign cache: a lookup is now stored as the callbook returned it, and the country file is applied when it is read. A value OpsLog derived can no longer come back later looking like something the page said — which is how the wrong zones outlived their fix — and a country-file update now reaches rows already cached.",
|
||||
"“Send to Cloudlog / Wavelog” joins the right-click upload menu. It was the one configured service missing from it: Cloudlog keeps no per-QSO sent status — deliberately, since it dedupes server-side — and the menu had been built around that status. An explicit selection needs no status to be safe, which is exactly why the absence stops mattering here.",
|
||||
"HAMLOG.online uploads are closed. The site no longer issues API keys and its upload API takes nothing else, so the auto-upload switch and the “Send to” entry armed something that could only fail. Everything else stays: their confirmations still import from a file (which never needed a key), and the sent/received state already in your log remains readable, filterable and bulk-editable. The upload code is kept whole against the day keys come back.",
|
||||
"Yaesu console: the power slider no longer springs back to 100 W on a 200 W radio. The console already knew an FTDX101MP could do 200 — that is what it drew the slider to — but the command that sets it was clamped to 100, so the rig was politely given half of what was asked for and the next poll showed it. FTDX101MP, FT-DX5000 and FTDX9000 reach 200 W now, and a rig reporting more than expected is still believed.",
|
||||
"Chase new: clicking a row now does what clicking a cluster spot does — including telling WSJT-X, JTDX or MSHV to change mode, so picking an FT4 station while the decoder sits in FT8 actually moves it. It also brings across the mode and its RST preset, and any park or summit reference. It used to do a hand-picked half of that, which left the one thing the window exists for — jumping onto a station — decoding the wrong mode.",
|
||||
"FT decodes: JTDX on FT4 no longer reads as Q65. A decode carries a one-character mode marker, and the two programs disagree about “:” — Q65 in WSJT-X, FT4 in JTDX — so the character alone cannot answer, and the wrong answer poisoned every verdict behind it: new mode, new slot, the mode filter. The sending program’s own status names the mode in full and now settles it; the markers both forks agree on are untouched."
|
||||
],
|
||||
"fr": [
|
||||
"Résolution des entités avec le fichier ClubLog activé : les préfixes retirés sont de nouveau reconnus. cty.dat décrit le monde tel qu’il est AUJOURD’HUI — Niue est passée en E6, donc ZK2 y est revenu à la Nouvelle-Zélande, et tous les contacts ZK2 jamais faits étaient silencieusement réétiquetés Nouvelle-Zélande, emportant une entité confirmée hors du DXCC de l’opérateur. ZK1 perdait les Cook du Sud de la même façon. La table de préfixes ClubLog connaît toujours les deux : elle est désormais consultée dès qu’aucune exception par indicatif ne s’applique, et non plus seulement pour les indicatifs qui en avaient une. Elle ne prime jamais sur une entrée exacte « =INDICATIF » de cty.dat, et là où elle n’a pas de réponse c’est cty.dat qui tranche. Repassez un import concerné par « Mettre à jour depuis ClubLog ».",
|
||||
"Les zones CQ et ITU proviennent désormais du callbook quand il les connaît. cty.dat ne porte QU’UNE paire représentative par entité, et OpsLog l’imposait par-dessus la réponse par station de QRZ.com — tout contact avec la Russie asiatique était donc enregistré en CQ 17 / ITU 30, quelle que soit la zone réelle (RU0LL est en 19/34, UA0SDX en 18/32). C’est un crédit WAZ pour une zone jamais travaillée. L’entité vient toujours de cty.dat, qui fait autorité sur ce qu’un indicatif EST ; une zone dit où la station SE TROUVE, et seul le callbook le sait dans un pays large de huit zones CQ. Là où le callbook se tait, cty.dat comble comme avant.",
|
||||
"Cache des indicatifs : une recherche est désormais stockée telle que le callbook l’a rendue, le fichier pays étant appliqué à la lecture. Une valeur déduite par OpsLog ne peut plus revenir plus tard avec l’apparence de ce qu’a dit la page — c’est ainsi que les mauvaises zones survivaient à leur correctif — et une mise à jour du fichier pays atteint maintenant les fiches déjà en cache.",
|
||||
"« Envoyer vers Cloudlog / Wavelog » rejoint le menu d’envoi du clic droit. C’était le seul service configuré qui y manquait : Cloudlog ne conserve aucun statut d’envoi par QSO — volontairement, puisqu’il dédoublonne côté serveur — et le menu était construit autour de ce statut. Une sélection explicite n’a besoin d’aucun statut pour être sûre : c’est précisément pourquoi cette absence cesse de compter ici.",
|
||||
"Les envois vers HAMLOG.online sont fermés. Le site ne délivre plus de clé API et son interface d’envoi n’accepte rien d’autre : la case d’envoi automatique et l’entrée « Envoyer vers » armaient donc quelque chose qui ne pouvait qu’échouer. Tout le reste demeure : leurs confirmations s’importent toujours depuis un fichier (ce qui n’a jamais demandé de clé), et l’état envoyé/reçu déjà présent dans votre log reste lisible, filtrable et modifiable en masse. Le code d’envoi est conservé intact pour le jour où les clés reviendraient.",
|
||||
"Console Yaesu : le curseur de puissance ne revient plus à 100 W sur une radio de 200 W. La console savait déjà qu’un FTDX101MP peut sortir 200 — c’est à cela qu’elle dimensionnait son curseur — mais la commande d’envoi était bornée à 100 : le poste recevait donc poliment la moitié de ce qu’on lui demandait, et le sondage suivant l’affichait. FTDX101MP, FT-DX5000 et FTDX9000 atteignent désormais 200 W, et une radio qui annonce plus que prévu reste crue sur parole.",
|
||||
"Chase new : cliquer une ligne fait désormais ce que fait un clic sur un spot du cluster — y compris demander à WSJT-X, JTDX ou MSHV de changer de mode, si bien que choisir une station FT4 alors que le décodeur est en FT8 l’y amène vraiment. Le mode et son RST par défaut suivent aussi, de même que toute référence de parc ou de sommet. La fenêtre n’en faisait qu’une moitié choisie à la main, ce qui laissait la seule chose pour laquelle elle existe — sauter sur une station — décoder dans le mauvais mode.",
|
||||
"FT decodes : JTDX en FT4 ne s’affiche plus en Q65. Un décodage porte un marqueur de mode d’un seul caractère, et les deux logiciels ne s’accordent pas sur « : » — Q65 pour WSJT-X, FT4 pour JTDX : le caractère seul ne peut donc pas trancher, et sa mauvaise réponse contaminait tout ce qui en découle — nouveau mode, nouveau slot, filtre de mode. Le statut envoyé par le logiciel lui-même nomme le mode en entier et tranche désormais ; les marqueurs sur lesquels les deux s’accordent ne changent pas."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.27.10",
|
||||
"date": "",
|
||||
"en": [
|
||||
"Widget order (Settings → Appearance): the row to the right of the entry can be rearranged by dragging — the whole row is the handle, and a line shows where it will land. QSO entry and the F1-F5 panel head the list, locked — they are not part of that row and nothing should be allowed to push what you type into behind a rotator dial. A widget you have switched off keeps its place and comes back where you left it, and the main view follows as you drag.",
|
||||
"Rotator, GS-232 over a serial port: the port is opened once and kept, instead of being reopened for every command. An Arduino-based controller — K3NG’s firmware, the ERC family — RESETS when its serial port is opened, so OpsLog was rebooting it several times a second and every command landed in the bootloader: a controller that answered a terminal perfectly reported “no reply to C” here. A freshly opened port is now left to boot before the first command, stale bytes from a previous exchange are discarded, and a failed exchange releases the port so the next one starts clean."
|
||||
],
|
||||
"fr": [
|
||||
"Ordre des widgets (Réglages → Apparence) : la rangée à droite de la saisie se réorganise par glisser-déposer — toute la ligne se saisit, et un trait montre où elle atterrira. La saisie du QSO et le panneau F1-F5 ouvrent la liste, verrouillés — ils ne font pas partie de cette rangée, et rien ne doit pouvoir repousser ce dans quoi vous tapez derrière une boussole de rotor. Un widget désactivé garde sa place et revient là où vous l’aviez laissé, et la vue principale suit pendant que vous glissez.",
|
||||
"Rotor, GS-232 sur port série : le port est ouvert une fois et conservé, au lieu d’être rouvert à chaque commande. Un contrôleur à base d’Arduino — le firmware K3NG, la famille ERC — REDÉMARRE à l’ouverture de son port série : OpsLog le redémarrait donc plusieurs fois par seconde et chaque commande tombait dans le bootloader. Un contrôleur qui répondait parfaitement à un terminal annonçait ici « no reply to C ». Un port fraîchement ouvert a désormais le temps de démarrer avant la première commande, les octets résiduels d’un échange précédent sont écartés, et un échange en échec libère le port pour que le suivant reparte propre."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.27.9",
|
||||
"date": "",
|
||||
"en": [
|
||||
"FT decodes warn when the decoding application announces a band the radio is not on — the signature of a lost CAT link, where it repeats the last frequency it knew and every decode after that carries a stale band. Nothing downstream could tell, so NEW BAND was being judged against a band the operator had left. OpsLog says it rather than deciding: a second receiver on another band is a real setup, and it costs that one only a line to read past.",
|
||||
"Voice keyer with CAT keying: an option saying the keyer’s audio arrives on the radio’s DATA / USB input rather than the microphone socket. A Kenwood TS-590 has two transmit commands — TX opens the front mic, TX1 the rear ACC2/USB — so a keyer playing through the rig’s own sound card was transmitting dead air while the radio listened to a microphone nobody was speaking into. Shown on the Kenwood backend only — no other radio family draws the distinction — and the Test PTT button exercises the same path."
|
||||
],
|
||||
"fr": [
|
||||
"Les FT decodes signalent quand le logiciel de décodage annonce une bande sur laquelle la radio n’est pas — la signature d’une liaison CAT perdue, où il répète la dernière fréquence connue et où tous les décodages suivants portent une bande périmée. Rien en aval ne pouvait s’en apercevoir : NOUVELLE BANDE était donc jugé sur une bande quittée. OpsLog le dit sans décider à votre place : un second récepteur sur une autre bande est une configuration légitime, et il ne lui en coûte qu’une ligne à ignorer.",
|
||||
"Voice keyer avec PTT CAT : une option indiquant que l’audio du keyer arrive sur l’entrée DATA / USB de la radio et non sur la prise micro. Un Kenwood TS-590 a deux commandes d’émission — TX ouvre le micro de face avant, TX1 l’ACC2/USB — si bien qu’un keyer jouant par la carte son du poste émettait dans le vide pendant que la radio écoutait un micro devant lequel personne ne parlait. Affichée sur le backend Kenwood uniquement — aucune autre famille de postes ne fait cette distinction — et le bouton Test PTT emprunte le même chemin."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.27.8",
|
||||
"date": "",
|
||||
"en": [
|
||||
"The band matrix’s DIG row is now a rotation: click it and it answers for FT8, then FT4, then each digital mode your mode list holds — in YOUR order — then back to DIG. One row per digital mode would be the honest layout and there is no height for it beside the other widgets, so the row keeps its place and changes what it says. The label column is sized once for the longest mode it can show, so the matrix never shifts as the rotation comes round to RTTY.",
|
||||
"Icom console: LSB and USB are separate buttons and can finally be commanded by name — the single SSB button resolved the sideband from the band, so there was no way to ask an IC-7300 for USB on 40 m. A rig reporting the folded “SSB” still lights the side its frequency implies.",
|
||||
"Icom console: a 60 m band button, and the antenna and PSK controls only appear on radios that have them. An IC-7300 has one antenna socket and no native PSK mode, so ANT1/ANT2 could only ever disagree with its front panel and the PSK button was dead furniture.",
|
||||
"Icom console: the mic gain is no longer hidden outside phone modes — on USB-D it still sets what the radio transmits at, and an operator who lives in FT8 had none at all.",
|
||||
"Icom CI-V: address 0x00 can be chosen. It was silently refused and replaced by the IC-7610 default, with no way to say what was meant."
|
||||
],
|
||||
"fr": [
|
||||
"La ligne DIG de la matrice devient une rotation : un clic et elle répond pour FT8, puis FT4, puis chaque mode numérique de votre liste — dans VOTRE ordre — puis retour à DIG. Une ligne par mode numérique serait la mise en page honnête et la hauteur manque à côté des autres widgets : la ligne garde donc sa place et change ce qu’elle dit. La colonne des libellés est dimensionnée une fois pour le plus long mode qu’elle peut afficher : la matrice ne bouge donc plus quand la rotation arrive sur RTTY.",
|
||||
"Console Icom : LSB et USB sont deux boutons distincts et peuvent enfin être demandés par leur nom — le bouton SSB unique déduisait la bande latérale de la fréquence, impossible donc de demander l’USB à un IC-7300 sur 40 m. Une radio qui annonce le « SSB » générique allume malgré tout le côté que sa fréquence implique.",
|
||||
"Console Icom : un bouton de bande 60 m, et les commandes antenne et PSK n’apparaissent que sur les radios qui en disposent. Un IC-7300 n’a qu’une prise d’antenne et pas de mode PSK natif : ANT1/ANT2 ne pouvait que contredire sa face avant, et le bouton PSK était un meuble mort.",
|
||||
"Console Icom : le gain micro n’est plus masqué hors des modes phonie — en USB-D il règle toujours le niveau d’émission, et un opérateur qui vit en FT8 n’en avait aucun.",
|
||||
"CI-V Icom : l’adresse 0x00 peut être choisie. Elle était refusée en silence et remplacée par le défaut IC-7610, sans moyen de dire ce que l’on voulait."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.27.7",
|
||||
"date": "",
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"hamlog/internal/clublog"
|
||||
"hamlog/internal/dxcc"
|
||||
"hamlog/internal/qso"
|
||||
)
|
||||
|
||||
// Reported from a real import: every ZK2 contact came back as New Zealand and a
|
||||
// confirmed entity — Niue — disappeared from the operator's DXCC.
|
||||
//
|
||||
// cty.dat is not wrong, it is CURRENT: Niue moved to E6, so ZK2 reverted to New
|
||||
// Zealand there. ClubLog still knows ZK2 was Niue, and knowing that is the whole
|
||||
// reason for enabling its country file.
|
||||
func TestClublogPrefixRescuesRetiredPrefixes(t *testing.T) {
|
||||
dir := filepath.Join("build", "bin", "data")
|
||||
dm := dxcc.NewManager(dir)
|
||||
if err := dm.LoadFromDisk(); err != nil {
|
||||
t.Skipf("cty.dat not available here: %v", err)
|
||||
}
|
||||
cm := clublog.NewManager("", dir)
|
||||
if err := cm.EnsureLoaded(); err != nil {
|
||||
t.Skipf("ClubLog country file not available here: %v", err)
|
||||
}
|
||||
a := &App{ctx: context.Background(), dxcc: dm, clublog: cm}
|
||||
|
||||
when := time.Date(2005, 6, 1, 0, 0, 0, 0, time.UTC)
|
||||
cases := []struct {
|
||||
call string
|
||||
want int // ADIF entity
|
||||
why string
|
||||
}{
|
||||
{"ZK2KK", 188, "Niue — the reported case"},
|
||||
{"ZK1XYZ", 234, "South Cook Islands, lost the same way"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
q := qso.QSO{Callsign: c.call, QSODate: when}
|
||||
if !a.applyClublogException(&q, true) {
|
||||
t.Errorf("%s: ClubLog changed nothing (%s)", c.call, c.why)
|
||||
continue
|
||||
}
|
||||
if q.DXCC == nil || *q.DXCC != c.want {
|
||||
got := 0
|
||||
if q.DXCC != nil {
|
||||
got = *q.DXCC
|
||||
}
|
||||
t.Errorf("%s resolved to %d (%s), want %d — %s", c.call, got, q.Country, c.want, c.why)
|
||||
}
|
||||
}
|
||||
|
||||
// A callsign ClubLog's prefix table does not know must be left to cty.dat
|
||||
// rather than blanked: silence is not an answer.
|
||||
q := qso.QSO{Callsign: "E6AG", QSODate: when}
|
||||
if a.applyClublogException(&q, true) && q.DXCC != nil && *q.DXCC != 188 {
|
||||
t.Errorf("E6AG was moved off Niue, to %d", *q.DXCC)
|
||||
}
|
||||
}
|
||||
+197
-163
@@ -1,7 +1,7 @@
|
||||
import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import {
|
||||
Activity, AlertCircle, Antenna, Bell, Check, CheckCircle2, ChevronDown, Clock, CloudOff, Compass, Database, Ear, Eraser, Flame, Gauge, Hash, Loader2, Lock,
|
||||
ChevronUp, Maximize2, Minimize2, Mic, MessageSquare, Pencil, Radar, Radio, RadioTower, RefreshCw, Satellite, Send, SatelliteDish, Settings, SlidersHorizontal, SpellCheck, Square, Star, Terminal, Trash2, Unlock, X, Zap,
|
||||
ChevronLeft, ChevronUp, Maximize2, Minimize2, Mic, MessageSquare, Pencil, Radar, Radio, RadioTower, RefreshCw, Satellite, Send, SatelliteDish, Settings, SlidersHorizontal, SpellCheck, Square, Star, Terminal, Trash2, Unlock, X, Zap,
|
||||
} from 'lucide-react';
|
||||
|
||||
import {
|
||||
@@ -54,11 +54,13 @@ import {
|
||||
GetFlexState, FlexAmpOperate,
|
||||
GetPSKReporterStatus, GetLiveOpenings, GetChaseNew,
|
||||
QSLViaRepairStatus, RepairQSLVia, DismissQSLViaRepair,
|
||||
GetAutoCallStatus, SetAutoCall, SetAutoCallOnly, TakeAutoCallTarget, ResetAutoCall,
|
||||
} from '../wailsjs/go/main/App';
|
||||
import { Combobox } from '@/components/ui/combobox';
|
||||
import { applyAwardRefs, parseAwardRefs as parseManualRefs, spotRefList , withIOTARef, withRDARef } from '@/lib/awardRefs';
|
||||
import { ListRadios, SetActiveRadio } from '../wailsjs/go/main/App';
|
||||
import { formatDistance } from '@/lib/units';
|
||||
import { WIDGET_KEYS } from '@/components/AppearancePanel';
|
||||
import { bandForMHz } from '@/lib/bandplan';
|
||||
import { EventsOn, BrowserOpenURL, WindowMinimise, WindowToggleMaximise, WindowIsMaximised, Quit } from '../wailsjs/runtime/runtime';
|
||||
import type { adif as adifModels, lookup as lookupModels, cat as catModels } from '../wailsjs/go/models';
|
||||
@@ -118,9 +120,9 @@ import { SendSpotModal, type RecentSpotQSO } from '@/components/SendSpotModal';
|
||||
import { WinkeyerPanel, type WKStatus, type WKMacro } from '@/components/WinkeyerPanel';
|
||||
import { RotorCompass } from '@/components/RotorCompass';
|
||||
import { GridSquareMap } from '@/components/GridSquareMap';
|
||||
import { loadAutoCall, shouldAutoCall, autoCallKey, type AutoCallSettings } from '@/lib/autocall';
|
||||
import { loadClusterMacros, visibleClusterMacros } from '@/lib/clusterMacros';
|
||||
import { DecodesPanel, type Decode as DecodeRow, type TxMsg as TxMsgRow } from '@/components/DecodesPanel';
|
||||
import { PSKReporterPanel } from '@/components/PSKReporterPanel';
|
||||
import { subscribeRotorHeading, pokeRotorHeading } from '@/lib/rotorHeading';
|
||||
import { writeUiPref } from '@/lib/uiPref';
|
||||
import { formatDateTimeUTC } from '@/lib/dateFormat';
|
||||
@@ -761,6 +763,32 @@ export default function App() {
|
||||
// Several amps side by side make a wide widget, so an operator running two
|
||||
// picks the one he watches while transmitting. Declared here because the poll
|
||||
// below runs faster while the widget is open.
|
||||
// Widget order (Settings → Appearance). The row is a flex container, so the
|
||||
// ORDER property moves a widget without touching the tree: every condition,
|
||||
// every ref and every hook stays where it was, and a widget that is switched
|
||||
// off simply is not there to be ordered.
|
||||
//
|
||||
// QSO entry and the F1-F5 panel are not in this list on purpose — they are
|
||||
// not in this row at all, and an operator cannot be allowed to push the thing
|
||||
// they type into behind a rotator dial.
|
||||
const [widgetOrder, setWidgetOrder] = useState<string[]>(() => {
|
||||
try {
|
||||
const raw = localStorage.getItem('opslog.widgetOrder');
|
||||
const arr = raw ? JSON.parse(raw) : null;
|
||||
if (Array.isArray(arr) && arr.every((x) => typeof x === 'string')) return arr;
|
||||
} catch { /* corrupt pref → the default order */ }
|
||||
return [...WIDGET_KEYS];
|
||||
});
|
||||
useEffect(() => EventsOn('widgets:order', (keys: any) => {
|
||||
if (Array.isArray(keys)) setWidgetOrder(keys.filter((k: any) => typeof k === 'string'));
|
||||
}), []);
|
||||
// A key the saved order has never heard of (a widget added since) goes to the
|
||||
// end rather than to the front, where it would jump the queue on every
|
||||
// upgrade.
|
||||
const wOrder = (k: string) => {
|
||||
const i = widgetOrder.indexOf(k);
|
||||
return i < 0 ? WIDGET_KEYS.length + (WIDGET_KEYS as readonly string[]).indexOf(k) : i;
|
||||
};
|
||||
const [showAmpWidget, setShowAmpWidget] = useState(() => localStorage.getItem('opslog.showAmpWidget') !== '0');
|
||||
const [ampWidgetSel, setAmpWidgetSel] = useState(() => localStorage.getItem('opslog.ampSel.widget') || 'all');
|
||||
// Poll fast only while the amplifier widget is open: its meters must track TX
|
||||
@@ -2538,136 +2566,34 @@ export default function App() {
|
||||
|
||||
// ── Auto-call ──────────────────────────────────────────────────────
|
||||
//
|
||||
// Answers a decode without the operator clicking it. The DECISION lives in
|
||||
// lib/autocall (one pure function, so the dangerous part can be read and
|
||||
// argued with); this is only the plumbing that runs it and keys the radio.
|
||||
//
|
||||
// Re-read when Preferences closes, like every other setting edited there.
|
||||
// The DECISION is in the BACKEND (internal/autocall), because it keys a
|
||||
// transmitter: it has to behave the same whether this tab is open or the
|
||||
// window is minimised, and every rule it applies — seven calls, three missed
|
||||
// periods, the ladder — is a Go test rather than something only the air can
|
||||
// check. What is left here is the switch, the readout, and handing over the
|
||||
// station the operator clicks.
|
||||
|
||||
// The named command buttons, re-read when Preferences closes like every other
|
||||
// setting edited there.
|
||||
const [clusterMacros, setClusterMacros] = useState(loadClusterMacros);
|
||||
useEffect(() => { if (!showSettings) setClusterMacros(loadClusterMacros()); }, [showSettings]);
|
||||
const clusterMacrosShown = useMemo(() => visibleClusterMacros(clusterMacros), [clusterMacros]);
|
||||
// Auto-call is withdrawn — it duplicated DXHunter, which answers decodes from
|
||||
// the same shack. This flag is the single place that says so at runtime.
|
||||
const AUTO_CALL_ENABLED = false;
|
||||
const [autoCall, setAutoCall] = useState<AutoCallSettings>(loadAutoCall);
|
||||
useEffect(() => { if (!showSettings) setAutoCall(loadAutoCall()); }, [showSettings]);
|
||||
// When each callsign was last answered, so a station still calling CQ is not
|
||||
// re-answered every slot while the QSO it started is still running.
|
||||
const autoCalledRef = useRef<Map<string, number>>(new Map());
|
||||
// Decodes are scanned once. Without this the same decode is reconsidered on
|
||||
// every status refresh, and a cooldown that has just expired would fire again
|
||||
// on a decode minutes old.
|
||||
const autoSeenRef = useRef<Set<string>>(new Set());
|
||||
// Set when a call goes out, so nothing else fires until the receiver's own
|
||||
// status catches up and `busy` can be trusted again.
|
||||
const autoHoldUntilRef = useRef(0);
|
||||
// The station auto-call is currently working, and when it started.
|
||||
//
|
||||
// This is OpsLog's OWN record of "a QSO is running", and it exists because
|
||||
// deriving that from the sender's Status was not enough: the moment
|
||||
// WSJT-X/JTDX drops the DX call or the Enable-Tx flag between overs — which
|
||||
// they do — the exchange looks finished and the next CQ gets answered,
|
||||
// interleaving two and then three QSOs on one slice. A lock we set ourselves
|
||||
// cannot be cleared by a flag we do not control.
|
||||
//
|
||||
// Released when that station's QSO is logged, when the operator halts or
|
||||
// takes over by clicking a decode, and by the watchdog below.
|
||||
const autoTargetRef = useRef<{ call: string; at: number } | null>(null);
|
||||
// An exchange abandoned mid-way must not lock auto-call out for ever: four
|
||||
// minutes covers a repeated FT8 QSO and still frees the next period soon
|
||||
// enough to matter.
|
||||
const AUTO_TARGET_MAX_MS = 240_000;
|
||||
// Per receiver, when the carrier was last up. Feeds the stale-exchange
|
||||
// backstop below.
|
||||
const lastTxAtRef = useRef<Map<string, number>>(new Map());
|
||||
const [autoCallStatus, setAutoCallStatus] = useState<any>({ enabled: false, target: '', calls: 0, max: 0, misses: 0, max_miss: 0, stopped: false, reason: '' });
|
||||
useEffect(() => {
|
||||
// AUTO-CALL IS WITHDRAWN — DXHunter already answers decodes, and two
|
||||
// programs doing it from one shack key over each other. See lib/autocall.ts.
|
||||
//
|
||||
// Returning here rather than deleting the loop: the decision it implements
|
||||
// is the delicate part, argued over and tested, and worth keeping intact.
|
||||
// The guard is what matters — an operator whose stored preference still
|
||||
// says "enabled" must not have their transmitter keyed by a feature they
|
||||
// can no longer see, let alone switch off.
|
||||
if (!AUTO_CALL_ENABLED) return;
|
||||
if (!autoCall.enabled) return;
|
||||
const now = Date.now();
|
||||
// A QSO is in progress somewhere if ANY receiver is transmitting or still
|
||||
// holding a DX call it has not finished with. Both matter: between overs the
|
||||
// carrier is down but the exchange is not over, and calling someone else
|
||||
// then is exactly the "it never stops" behaviour.
|
||||
const busy = Object.values(txStates).some((tx) => {
|
||||
if (tx?.transmitting) return true;
|
||||
// A DX call still set means the exchange is not finished — but ONLY while
|
||||
// the sender still intends to transmit. The watchdog stops transmission
|
||||
// and leaves the DX call behind, and reading the call alone left auto-call
|
||||
// waiting for a QSO that had already been given up on, for ever.
|
||||
if (!tx?.dx_call?.trim()) return false;
|
||||
if (tx.tx_enabled === false) return false;
|
||||
// Backstop for a sender that never reports the toggle: an exchange with no
|
||||
// transmission for three minutes is over, whatever the DX call still says.
|
||||
// Measured from the last TIME THE CARRIER WAS UP — Status itself arrives
|
||||
// every second and so can never go stale.
|
||||
const last = lastTxAtRef.current.get(tx.instance ?? '');
|
||||
return last === undefined || now - last < 180_000;
|
||||
})
|
||||
// The hold closes the gap between sending a Reply and the receiver saying
|
||||
// it has acted on it — about a second. Without it the OTHER instance still
|
||||
// looks idle in that window and gets a call of its own.
|
||||
|| now < autoHoldUntilRef.current;
|
||||
// Our own lock, evaluated after the watchdog so an abandoned exchange does
|
||||
// not hold the transmitter shut.
|
||||
if (autoTargetRef.current && now - autoTargetRef.current.at > AUTO_TARGET_MAX_MS) {
|
||||
LogUIError('auto-call', `giving up on ${autoTargetRef.current.call} — nothing logged in four minutes`, '');
|
||||
autoTargetRef.current = null;
|
||||
}
|
||||
const locked = busy || autoTargetRef.current !== null;
|
||||
for (const d of decodes) {
|
||||
const seenKey = `${d.call}|${d.ms ?? d.at}|${d.instance ?? ''}`;
|
||||
if (autoSeenRef.current.has(seenKey)) continue;
|
||||
// A Replay's resent history is display-only: answering a line the far
|
||||
// end already dropped would fail anyway, and doing it at startup — the
|
||||
// moment replays arrive — would be a transmitter firing on old news.
|
||||
if ((d as any).is_new === false) { autoSeenRef.current.add(seenKey); continue; }
|
||||
// Only decodes from the CURRENT period are worth answering: replying to a
|
||||
// slot that has closed asks the far end to match a decode it has dropped.
|
||||
if (now - Date.parse(d.at) > 30_000) { autoSeenRef.current.add(seenKey); continue; }
|
||||
const e = spotStatus[`${d.call}|${d.band ?? ''}|${(d.mode ?? '').toUpperCase()}`];
|
||||
// NOT marked seen until its status has resolved. Statuses land a few
|
||||
// hundred milliseconds after the decode, so consuming it on first sight
|
||||
// would throw away almost every decode unjudged — the effect re-runs when
|
||||
// spotStatus changes, and this is what lets it look again.
|
||||
if (!e) continue;
|
||||
autoSeenRef.current.add(seenKey);
|
||||
const verdict = shouldAutoCall(autoCall, d, e as any, {
|
||||
busy: locked,
|
||||
calledAt: autoCalledRef.current,
|
||||
now,
|
||||
myCall: station.callsign,
|
||||
});
|
||||
if (!verdict.call) continue;
|
||||
autoCalledRef.current.set(d.call.toUpperCase(), now);
|
||||
autoHoldUntilRef.current = now + 12_000; // an FT8 slot, near enough
|
||||
autoTargetRef.current = { call: d.call.toUpperCase(), at: now };
|
||||
// Same reason as a manual click: put the transmitter on the decode's band
|
||||
// before answering, or a second slice answers on the wrong one.
|
||||
FlexTXOnBand(d.band ?? '').catch(() => {});
|
||||
// Logged, always: an automatic transmission with no record of WHY is the
|
||||
// one thing an operator cannot argue with after the fact.
|
||||
LogUIError('auto-call', `calling ${d.call} — ${verdict.reason}`, '');
|
||||
AnswerDecode(
|
||||
d.instance ?? '', d.ms ?? 0, d.snr, d.dt ?? 0,
|
||||
d.audio_hz ?? 0, d.mode_raw || d.mode || '', d.msg_raw ?? d.msg ?? '', !!d.low_conf,
|
||||
).catch((e2: any) => setError(String(e2?.message ?? e2)));
|
||||
onCallsignInput(d.call, { force: true });
|
||||
break; // one per pass: a period can hold several, and we work one station
|
||||
}
|
||||
// The seen-set is bounded by the same half hour the decode list keeps.
|
||||
if (autoSeenRef.current.size > 20000) autoSeenRef.current.clear();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [decodes, spotStatus, autoCall, txStates]);
|
||||
GetAutoCallStatus().then(setAutoCallStatus).catch(() => {});
|
||||
// Pushed by the engine on every decision, and polled as well: the push is
|
||||
// what makes the counter move the instant a call goes out, the poll is what
|
||||
// recovers a status missed while the window was asleep.
|
||||
const off = EventsOn('autocall:status', (s: any) => setAutoCallStatus(s));
|
||||
const id = window.setInterval(() => { GetAutoCallStatus().then(setAutoCallStatus).catch(() => {}); }, 3000);
|
||||
return () => { off(); window.clearInterval(id); };
|
||||
}, []);
|
||||
const toggleAutoCall = () => {
|
||||
const next = !autoCallStatus?.enabled;
|
||||
setAutoCallStatus((s: any) => ({ ...s, enabled: next }));
|
||||
SetAutoCall(next).catch((e: any) => setError(String(e?.message ?? e)));
|
||||
};
|
||||
|
||||
// Staged like the cluster's, so a period arriving as one burst of fifty
|
||||
// packets costs one status lookup and one render, not fifty of each.
|
||||
const pendingDecodesRef = useRef<DecodeRow[]>([]);
|
||||
@@ -2819,6 +2745,14 @@ export default function App() {
|
||||
const [showChaseNew, setShowChaseNew] = useState(() => localStorage.getItem('opslog.showChaseNew') !== '0');
|
||||
const refreshChaseNew = useCallback(() => { GetChaseNew().then(setChaseNewOn).catch(() => {}); }, []);
|
||||
useEffect(() => { refreshChaseNew(); }, [refreshChaseNew]);
|
||||
// The PSK Reporter panel beside the decodes. Open/closed is remembered; the
|
||||
// TARGET is whichever station is being worked, so it follows a click on a
|
||||
// decode and the DX call the digital application reports, and nothing has to
|
||||
// be selected twice.
|
||||
const [pskPanelOpen, setPskPanelOpen] = useState(() => localStorage.getItem('opslog.pskPanel') === '1');
|
||||
useEffect(() => { try { localStorage.setItem('opslog.pskPanel', pskPanelOpen ? '1' : '0'); } catch { /* private mode */ } }, [pskPanelOpen]);
|
||||
const [pskTarget, setPskTarget] = useState('');
|
||||
const [pskTargetMode, setPskTargetMode] = useState('');
|
||||
const [showBeamOnMap, setShowBeamOnMap] = useState(() => localStorage.getItem('opslog.showBeamOnMap') !== '0');
|
||||
// Compact rotor widget (Settings → Rotator): dial + SP/LP only. RotorCompass
|
||||
// already draws exactly that when it is given neither presets nor onStop —
|
||||
@@ -3809,11 +3743,6 @@ export default function App() {
|
||||
setTxState(m as TxMsgRow);
|
||||
if (m?.instance) {
|
||||
setTxStates((prev) => ({ ...prev, [m.instance]: m as TxMsgRow }));
|
||||
// When this receiver last actually TRANSMITTED, which is not the same as
|
||||
// when it last spoke: Status arrives about once a second whether the
|
||||
// carrier is up or not, so it can never say how long an exchange has
|
||||
// been stalled.
|
||||
if (m.transmitting) lastTxAtRef.current.set(m.instance, Date.now());
|
||||
}
|
||||
// The period history takes only real transmissions — Status repeats
|
||||
// itself once a second whether the carrier is up or not.
|
||||
@@ -3930,11 +3859,6 @@ export default function App() {
|
||||
try {
|
||||
await LogUDPLoggedADIF(text);
|
||||
await refresh();
|
||||
// The QSO auto-call started has finished — release the lock so the next
|
||||
// CQ can be answered. Matched on the callsign: a QSO logged from
|
||||
// somewhere else must not free a run that is still going.
|
||||
const logged = /<call:d+(?::[^>]*)?>([^<s]+)/i.exec(text)?.[1]?.toUpperCase();
|
||||
if (logged && autoTargetRef.current?.call === logged) autoTargetRef.current = null;
|
||||
} catch (e: any) {
|
||||
const msg = String(e?.message ?? e);
|
||||
// A re-broadcast of an already-logged QSO (Log4OM/WSJT-X) is benign —
|
||||
@@ -5155,6 +5079,8 @@ export default function App() {
|
||||
{ type: 'separator' },
|
||||
{ type: 'item', label: t('logview.title'), action: 'help.log' },
|
||||
{ type: 'separator' },
|
||||
{ type: 'item', label: t('help.discord'), action: 'help.discord' },
|
||||
{ type: 'separator' },
|
||||
{ type: 'item', label: t('help.donate'), action: 'help.donate', accent: true },
|
||||
{ type: 'separator' },
|
||||
{ type: 'item', label: t('help.about'), action: 'help.about' },
|
||||
@@ -5199,7 +5125,8 @@ export default function App() {
|
||||
case 'help.sendlog': sendLogToDeveloper(); break;
|
||||
// Opens in the system browser, NOT the app WebView: a payment page must show
|
||||
// the address bar and padlock the donor knows how to check.
|
||||
case 'help.donate': BrowserOpenURL('https://www.paypal.com/donate/?hosted_button_id=PDMY7KV99K38S'); break;
|
||||
case 'help.discord': BrowserOpenURL('https://discord.gg/8ZsPDmH9q2'); break;
|
||||
case 'help.donate': BrowserOpenURL('https://www.paypal.com/donate/?hosted_button_id=PDMY7KV99K38S'); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6321,26 +6248,108 @@ export default function App() {
|
||||
// The FT decodes panel, built in ONE place: it is offered both as a tab and as
|
||||
// a Main-view pane, and two copies of this call would be two sets of props to
|
||||
// keep in step.
|
||||
// The dial the decodes are being read against. It has to be the DECODER's,
|
||||
// not the rig's: a report at 14.074.850 is only "+850 Hz in his passband"
|
||||
// measured from the same dial the digital application is using, and on split
|
||||
// or with a transverter the rig's own frequency is a different number.
|
||||
const pskDialHz = useMemo(() => {
|
||||
for (const d of decodes) if (d.dial_hz && d.dial_hz > 0) return d.dial_hz;
|
||||
return txState?.freq_hz ?? 0;
|
||||
}, [decodes, txState?.freq_hz]);
|
||||
|
||||
// Stations WE are decoding that are calling the same DX — the competition at
|
||||
// this end, which PSK Reporter cannot see: it carries who was heard, never
|
||||
// who they were calling.
|
||||
const pskCallers = useMemo(() => {
|
||||
if (!pskTarget) return [] as string[];
|
||||
const want = pskTarget.toUpperCase() + ' ';
|
||||
const seen = new Set<string>();
|
||||
for (const d of decodes) {
|
||||
const msg = (d.msg ?? '').toUpperCase().trim();
|
||||
if (!msg.startsWith(want)) continue;
|
||||
const caller = msg.slice(want.length).trim().split(/\s+/)[0];
|
||||
// "CQ" cannot be a caller, and neither can our own transmission coming
|
||||
// back as a decode of ourselves.
|
||||
if (caller && caller !== 'CQ' && caller !== (station.callsign ?? '').toUpperCase()) seen.add(caller);
|
||||
}
|
||||
return [...seen];
|
||||
}, [decodes, pskTarget, station.callsign]);
|
||||
|
||||
// Follow the station the digital application says it is calling. A decode
|
||||
// clicked here sets the target directly (see onCall); this covers the QSO
|
||||
// started from the other side — WSJT-X's own double-click, or auto-call.
|
||||
useEffect(() => {
|
||||
const dx = (txState?.dx_call ?? '').toUpperCase().trim();
|
||||
if (dx && dx !== pskTarget) {
|
||||
setPskTarget(dx);
|
||||
setPskTargetMode(txState?.mode ?? '');
|
||||
}
|
||||
}, [txState?.dx_call, txState?.mode, pskTarget]);
|
||||
|
||||
const renderDecodesPanel = () => (
|
||||
<div className="flex h-full min-h-0">
|
||||
<div className="flex-1 min-w-0 flex flex-col min-h-0">
|
||||
{renderDecodesList()}
|
||||
</div>
|
||||
{pskPanelOpen ? (
|
||||
<PSKReporterPanel
|
||||
target={pskTarget}
|
||||
mode={pskTargetMode}
|
||||
dialHz={pskDialHz}
|
||||
callers={pskCallers.length}
|
||||
callerCalls={pskCallers}
|
||||
onCollapse={() => setPskPanelOpen(false)}
|
||||
/>
|
||||
) : (
|
||||
// Collapsed to a strip rather than removed: a panel with no way back is
|
||||
// one an operator loses, and the button has to say what it opens.
|
||||
<button type="button" onClick={() => setPskPanelOpen(true)} title={t('psk.show')}
|
||||
className="w-7 shrink-0 border-l border-border bg-card hover:bg-muted flex flex-col items-center gap-2 py-2 text-muted-foreground hover:text-foreground">
|
||||
<ChevronLeft className="size-4" />
|
||||
<span className="text-[10px] font-semibold uppercase tracking-wider [writing-mode:vertical-rl]">
|
||||
{t('psk.title')}
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
const renderDecodesList = () => (
|
||||
<DecodesPanel
|
||||
decodes={decodes}
|
||||
txMsgs={txMsgs}
|
||||
txState={txState}
|
||||
txStates={txStates}
|
||||
spotStatus={spotStatus as any}
|
||||
// Only while CAT is actually connected: an empty band means "nothing to
|
||||
// compare with", never "the rig is on no band".
|
||||
rigBand={catState.connected ? (catState.band || '') : ''}
|
||||
myCall={station.callsign}
|
||||
// A click ANSWERS the station: it hands the decode back to WSJT-X/MSHV as
|
||||
// a Reply, which is the same thing as double-clicking the line in their
|
||||
// own window.
|
||||
// A DOUBLE click answers the station: it hands the decode back to
|
||||
// WSJT-X/MSHV as a Reply, the same thing as double-clicking the line in
|
||||
// their own window. A single click only selects it — see onSelect below,
|
||||
// and the cluster, where the two gestures already mean this.
|
||||
//
|
||||
// Deliberately NOT a rig tune, unlike a cluster spot. On FT8 the whole
|
||||
// band is inside one passband, so moving the dial changes nothing about
|
||||
// who gets answered — and it would only fight the digital application
|
||||
// for the VFO. The entry is still filled, so the QSO can be logged here.
|
||||
// One click: take the station, transmit nothing. The entry is filled and
|
||||
// the panels follow it, exactly as clicking a cluster spot does — so a
|
||||
// row can be inspected, looked up and read about without keying up.
|
||||
onSelect={(d) => {
|
||||
setPskTarget((d.call ?? '').toUpperCase());
|
||||
setPskTargetMode(d.mode ?? '');
|
||||
onCallsignInput(d.call, { force: true });
|
||||
}}
|
||||
onCall={(d) => {
|
||||
// The operator has picked a station: that is now the QSO in progress, so
|
||||
// auto-call must not answer someone else over the top of it.
|
||||
autoTargetRef.current = { call: (d.call ?? '').toUpperCase(), at: Date.now() };
|
||||
// The station being answered is also the one worth analysing: the PSK
|
||||
// Reporter panel follows the click rather than asking for a second one.
|
||||
setPskTarget((d.call ?? '').toUpperCase());
|
||||
setPskTargetMode(d.mode ?? '');
|
||||
// Auto-call adopts the station: the click chooses WHO, the watchdogs
|
||||
// still decide how long it is called for.
|
||||
TakeAutoCallTarget(d.call ?? '', d.band ?? '', d.mode ?? '').catch(() => {});
|
||||
onCallsignInput(d.call, { force: true });
|
||||
// With two slices on two bands, the Reply reaches the right INSTANCE but
|
||||
// the radio still transmits on whichever slice holds the TX flag. Move
|
||||
@@ -6359,7 +6368,6 @@ export default function App() {
|
||||
// buffer goes too or the next flush would put back what was just cleared.
|
||||
onClear={(instance) => {
|
||||
if (!instance) {
|
||||
autoTargetRef.current = null;
|
||||
pendingDecodesRef.current = [];
|
||||
setDecodes([]);
|
||||
setTxMsgs([]);
|
||||
@@ -6377,10 +6385,20 @@ export default function App() {
|
||||
// An empty instance lets the backend fall back to whichever application
|
||||
// last reported its status — the normal single-receiver case.
|
||||
onHalt={(instance) => {
|
||||
// Halt means stop, including whatever auto-call had started.
|
||||
autoTargetRef.current = null;
|
||||
// Halt means stop, including whatever auto-call had started — and it
|
||||
// clears the engine's state, so a target it had given up on is not
|
||||
// still sitting there when the operator switches it back on.
|
||||
ResetAutoCall().catch(() => {});
|
||||
HaltDecodeTx(instance, false).catch((e: any) => setError(String(e?.message ?? e)));
|
||||
}}
|
||||
autoCallOn={!!autoCallStatus?.enabled}
|
||||
onToggleAutoCall={toggleAutoCall}
|
||||
autoCall={autoCallStatus}
|
||||
autoCallOnly={autoCallStatus?.only ?? ''}
|
||||
onSetAutoCallOnly={(list) => {
|
||||
setAutoCallStatus((st: any) => ({ ...st, only: list.toUpperCase() }));
|
||||
SetAutoCallOnly(list).catch((e: any) => setError(String(e?.message ?? e)));
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -7411,6 +7429,7 @@ export default function App() {
|
||||
band={band}
|
||||
mode={mode}
|
||||
bands={bands}
|
||||
modes={modes}
|
||||
satellites={satellites}
|
||||
onEditQso={openEdit}
|
||||
{...(!callsign.trim() && selQso ? {
|
||||
@@ -7436,7 +7455,7 @@ export default function App() {
|
||||
{/* Multi-op "who's on air" widget: every operator on the shared logbook,
|
||||
their freq/mode (colour-coded) and OpsLog version. */}
|
||||
{showLiveStations && dbConn?.backend === 'mysql' && (
|
||||
<div className="w-[248px] shrink-0 min-h-0 relative">
|
||||
<div className="w-[248px] shrink-0 min-h-0 relative" style={{ order: wOrder('livestations') }}>
|
||||
<div className="absolute inset-0 flex flex-col min-h-0 rounded-xl border border-border bg-card shadow-sm overflow-hidden">
|
||||
<div className="flex items-center gap-1.5 px-3 h-8 border-b border-border shrink-0">
|
||||
<Radio className="size-3.5 text-primary" />
|
||||
@@ -7480,7 +7499,7 @@ export default function App() {
|
||||
// relative + absolute inner: the chat takes the row height (set by the
|
||||
// entry strip) WITHOUT its message list growing the row, like the
|
||||
// Stats panel. The list scrolls inside this fixed height.
|
||||
<div className="w-[280px] shrink-0 min-h-0 relative">
|
||||
<div className="w-[280px] shrink-0 min-h-0 relative" style={{ order: wOrder('chat') }}>
|
||||
<div className="absolute inset-0 flex flex-col min-h-0">
|
||||
<ChatPanel msgs={chatMsgs} online={chatOnline} myCall={station.callsign}
|
||||
onSend={chatSend} onClose={() => setChatOpen(false)} />
|
||||
@@ -7492,7 +7511,7 @@ export default function App() {
|
||||
controls column, so the widget is just the dial and needs only its
|
||||
width. */}
|
||||
{showRotor && (rotatorHeading.enabled || dxPath) && (
|
||||
<div className={cn('shrink-0 min-h-0', rotorCompact ? 'w-[196px]' : 'w-[320px]')}>
|
||||
<div className={cn('shrink-0 min-h-0', rotorCompact ? 'w-[196px]' : 'w-[320px]')} style={{ order: wOrder('rotor') }}>
|
||||
<RotorCompass
|
||||
presets={rotorCompact ? undefined : rotorPresets}
|
||||
onStop={rotorCompact ? undefined : () => { RotatorStop().then(pokeRotorHeading).catch((err) => setError(String(err?.message ?? err))); }}
|
||||
@@ -7512,7 +7531,7 @@ export default function App() {
|
||||
</div>
|
||||
)}
|
||||
{showMotorAnt && ubStatus.enabled && (
|
||||
<div className="w-[230px] shrink-0 min-h-0">
|
||||
<div className="w-[230px] shrink-0 min-h-0" style={{ order: wOrder('motorant') }}>
|
||||
<MotorAntennaWidget
|
||||
ant={ubStatus}
|
||||
refetch={pokeUbStatus}
|
||||
@@ -7523,7 +7542,7 @@ export default function App() {
|
||||
</div>
|
||||
)}
|
||||
{showAntGenius && agEnabled && (
|
||||
<div className="w-[230px] shrink-0 min-h-0">
|
||||
<div className="w-[230px] shrink-0 min-h-0" style={{ order: wOrder('antgenius') }}>
|
||||
<AntGeniusPanel
|
||||
status={agStatus}
|
||||
onActivate={agActivate}
|
||||
@@ -7536,7 +7555,7 @@ export default function App() {
|
||||
// One column per amplifier shown, so two amps stand side by side
|
||||
// rather than making the widget twice as tall as the dock row.
|
||||
<div className="shrink-0 min-h-0"
|
||||
style={{ width: `${Math.min(ampWidgetSel === 'all' ? ampSts.length : 1, 3) * 250 + 20}px` }}>
|
||||
style={{ width: `${Math.min(ampWidgetSel === 'all' ? ampSts.length : 1, 3) * 250 + 20}px`, order: wOrder('amp') }}>
|
||||
<AmpWidget
|
||||
amps={ampSts}
|
||||
flex={flexAmp}
|
||||
@@ -7546,7 +7565,7 @@ export default function App() {
|
||||
</div>
|
||||
)}
|
||||
{showTuner && tgEnabled && (
|
||||
<div className="w-[230px] shrink-0 min-h-0">
|
||||
<div className="w-[230px] shrink-0 min-h-0" style={{ order: wOrder('tuner') }}>
|
||||
<TunerGeniusPanel
|
||||
status={tgStatus}
|
||||
onTune={tgTune}
|
||||
@@ -7558,7 +7577,7 @@ export default function App() {
|
||||
</div>
|
||||
)}
|
||||
{showScp && scpEnabled && (
|
||||
<div className="w-[240px] shrink-0 min-h-0">
|
||||
<div className="w-[240px] shrink-0 min-h-0" style={{ order: wOrder('scp') }}>
|
||||
<ScpPanel
|
||||
result={scpResult}
|
||||
currentCall={callsign}
|
||||
@@ -7569,20 +7588,35 @@ export default function App() {
|
||||
</div>
|
||||
)}
|
||||
{chaseNewOn && showChaseNew && (
|
||||
<div className="w-[420px] shrink-0 min-h-0">
|
||||
<div className="w-[420px] shrink-0 min-h-0" style={{ order: wOrder('chasenew') }}>
|
||||
{/* Same reflex as clicking a cluster spot: the callsign into the
|
||||
entry, and the rig onto the frequency it was decoded on. */}
|
||||
<ChaseNewPanel onPick={(sp) => {
|
||||
onCallsignInput(sp.call, { force: true });
|
||||
// And the panadapter width too — after the tune settles, for the
|
||||
// same SmartSDR pan-follow reason as handleSpotClick.
|
||||
if (sp.freq_hz) void tuneRigCAT(sp.freq_hz, sp.mode).then(() =>
|
||||
window.setTimeout(() => FlexZoomForSpot(sp.mode ?? '', sp.freq_hz ?? 0).catch(() => {}), 300));
|
||||
// A row here is a spot like any other, so it goes through the
|
||||
// SAME handler as one clicked in the cluster: the rig tunes, the
|
||||
// panadapter follows, the entry takes the mode and its RST
|
||||
// preset, the park and summit references come across — and the
|
||||
// decoding application is told to change mode, which is what an
|
||||
// operator clicking an FT4 row from an FT8 slot is asking for.
|
||||
//
|
||||
// It used to do a hand-picked half of that, so the one thing
|
||||
// Chase new exists for — jumping onto a station — left WSJT-X
|
||||
// decoding the wrong mode.
|
||||
handleSpotClick({
|
||||
dx_call: sp.call,
|
||||
freq_hz: sp.freq_hz ?? 0,
|
||||
band: sp.band,
|
||||
// handleSpotClick infers the mode from the comment the way a
|
||||
// cluster line carries it; the mode is what we have, so it is
|
||||
// what we hand over.
|
||||
comment: sp.mode ?? '',
|
||||
spotter: '',
|
||||
});
|
||||
}} onClose={() => { setShowChaseNew(false); writeUiPref('opslog.showChaseNew', '0'); }} />
|
||||
</div>
|
||||
)}
|
||||
{dvkEnabled && (
|
||||
<div className="w-[320px] shrink-0 min-h-0">
|
||||
<div className="w-[320px] shrink-0 min-h-0" style={{ order: wOrder('dvk') }}>
|
||||
<DvkPanel
|
||||
messages={dvkMsgs}
|
||||
status={dvkStat}
|
||||
@@ -7598,7 +7632,7 @@ export default function App() {
|
||||
</div>
|
||||
)}
|
||||
{wkEnabled && (
|
||||
<div className="w-[380px] shrink-0 min-h-0">
|
||||
<div className="w-[380px] shrink-0 min-h-0" style={{ order: wOrder('winkeyer') }}>
|
||||
<WinkeyerPanel
|
||||
// A rig keyer has no serial status of its own: it is connected
|
||||
// exactly when its CAT backend is. Yaesu was missing from this
|
||||
@@ -7642,7 +7676,7 @@ export default function App() {
|
||||
{/* QRZ photo: when the keyer is open it sits to its right at natural
|
||||
(capped) width, shrinking the keyer panel rather than hiding it. */}
|
||||
{lookupResult?.image_url && (
|
||||
<div className={cn('min-w-0 flex items-center', (wkEnabled || dvkEnabled) ? 'shrink-0' : 'flex-1')}>
|
||||
<div className={cn('min-w-0 flex items-center', (wkEnabled || dvkEnabled) ? 'shrink-0' : 'flex-1')} style={{ order: wOrder('photo') }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => lookupResult.image_url && setPhotoModal(lookupResult.image_url)}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { EventsEmit } from '../../wailsjs/runtime/runtime';
|
||||
import { GripVertical, Lock } from 'lucide-react';
|
||||
import { GetMatrixColors, GetRowColors, SaveMatrixColors, SaveRowColors } from '../../wailsjs/go/main/App';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
@@ -290,6 +292,116 @@ export function AppearancePanel() {
|
||||
)}
|
||||
|
||||
<MatrixColorsSection />
|
||||
<WidgetOrderSection />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// The row of widgets to the right of the entry, in the order they appear.
|
||||
//
|
||||
// Flexbox does the moving in the main view — this list only decides the order
|
||||
// property each one gets. That is why a widget switched OFF still holds its
|
||||
// place here: it comes back where the operator left it rather than at the end.
|
||||
export const WIDGET_KEYS = [
|
||||
'livestations', 'chat', 'rotor', 'motorant', 'antgenius',
|
||||
'amp', 'tuner', 'scp', 'chasenew', 'dvk', 'winkeyer', 'photo',
|
||||
] as const;
|
||||
|
||||
const WIDGET_LABELS: Record<string, string> = {
|
||||
livestations: 'wo.livestations', chat: 'wo.chat', rotor: 'wo.rotor',
|
||||
motorant: 'wo.motorant', antgenius: 'wo.antgenius', amp: 'wo.amp',
|
||||
tuner: 'wo.tuner', scp: 'wo.scp', chasenew: 'wo.chasenew',
|
||||
dvk: 'wo.dvk', winkeyer: 'wo.winkeyer', photo: 'wo.photo',
|
||||
};
|
||||
|
||||
function readWidgetOrder(): string[] {
|
||||
try {
|
||||
const raw = localStorage.getItem('opslog.widgetOrder');
|
||||
const arr = raw ? JSON.parse(raw) : null;
|
||||
if (Array.isArray(arr)) {
|
||||
// A key from an older build that no longer exists is dropped; a widget
|
||||
// added since joins the end. An old preference can never hide a new one.
|
||||
const known = arr.filter((k: any) => (WIDGET_KEYS as readonly string[]).includes(k));
|
||||
return [...known, ...WIDGET_KEYS.filter((k) => !known.includes(k))];
|
||||
}
|
||||
} catch { /* corrupt pref → the default order */ }
|
||||
return [...WIDGET_KEYS];
|
||||
}
|
||||
|
||||
function WidgetOrderSection() {
|
||||
const { t } = useI18n();
|
||||
const [order, setOrder] = useState<string[]>(readWidgetOrder);
|
||||
const dragKey = useRef<string | null>(null);
|
||||
const [dragging, setDragging] = useState<string | null>(null);
|
||||
// Where the row would land. Drawn as a line above the target rather than by
|
||||
// colouring it: the question a dragging hand asks is "between which two", and
|
||||
// a highlighted row answers a different one.
|
||||
const [over, setOver] = useState<string | null>(null);
|
||||
|
||||
const commit = (keys: string[]) => {
|
||||
setOrder(keys);
|
||||
try { localStorage.setItem('opslog.widgetOrder', JSON.stringify(keys)); } catch { /* private mode */ }
|
||||
// The main view listens: an order is meant to be watched as it is dragged,
|
||||
// not discovered after closing Preferences.
|
||||
EventsEmit('widgets:order', keys);
|
||||
};
|
||||
const moveTo = (from: string, to: string) => {
|
||||
if (from === to) return;
|
||||
const next = order.filter((k) => k !== from);
|
||||
const at = next.indexOf(to);
|
||||
next.splice(at < 0 ? next.length : at, 0, from);
|
||||
commit(next);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-sm font-semibold">{t('wo.title')}</h3>
|
||||
<p className="text-xs text-muted-foreground">{t('wo.hint')}</p>
|
||||
<div className="space-y-1 max-w-md">
|
||||
{/* The two that cannot move, shown so the order reads as the whole row
|
||||
rather than as a list that mysteriously starts at the third item. */}
|
||||
{['wo.entry', 'wo.details'].map((k) => (
|
||||
<div key={k}
|
||||
className="flex items-center gap-2 rounded-md border border-border/60 bg-muted/30 px-2 py-1.5 text-sm text-muted-foreground">
|
||||
<Lock className="size-3.5 shrink-0 opacity-60" />
|
||||
<span className="flex-1 min-w-0 truncate">{t(k)}</span>
|
||||
</div>
|
||||
))}
|
||||
{order.map((k) => (
|
||||
// The WHOLE row is the handle, not the grip alone: a list whose rows
|
||||
// can only be moved by a 16-pixel icon is a list most people conclude
|
||||
// cannot be moved. The grip stays as the sign that it can.
|
||||
<div key={k} draggable
|
||||
onDragStart={(e) => { dragKey.current = k; setDragging(k); e.dataTransfer.effectAllowed = 'move'; }}
|
||||
onDragEnd={() => { dragKey.current = null; setDragging(null); setOver(null); }}
|
||||
onDragOver={(e) => {
|
||||
if (!dragKey.current) return;
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
if (over !== k) setOver(k);
|
||||
}}
|
||||
onDragLeave={() => { if (over === k) setOver(null); }}
|
||||
onDrop={(e) => {
|
||||
if (!dragKey.current) return;
|
||||
e.preventDefault();
|
||||
moveTo(dragKey.current, k);
|
||||
setOver(null);
|
||||
}}
|
||||
title={t('wo.drag')}
|
||||
className={cn('flex items-center gap-2 rounded-md border bg-card px-2 py-1.5 text-sm select-none',
|
||||
'cursor-grab active:cursor-grabbing transition-shadow',
|
||||
dragging === k ? 'opacity-50 border-primary shadow-lg' : 'border-border hover:border-foreground/30',
|
||||
// The landing line, on the edge the row would take.
|
||||
over === k && dragging !== k && 'shadow-[inset_0_3px_0_0_var(--primary)]')}>
|
||||
<GripVertical className="size-4 shrink-0 text-muted-foreground/50" />
|
||||
<span className="flex-1 min-w-0 truncate">{t(WIDGET_LABELS[k] ?? k)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<button type="button" onClick={() => commit([...WIDGET_KEYS])}
|
||||
className="text-xs text-muted-foreground hover:text-foreground underline">
|
||||
{t('wo.reset')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@ interface Props {
|
||||
busy: boolean;
|
||||
currentBand: string;
|
||||
currentMode: string;
|
||||
bands?: string[]; // operator's configured bands; falls back to DEFAULT_BANDS
|
||||
bands?: string[];
|
||||
// The operator's configured mode list, in THEIR order: the digital row
|
||||
// rotates through it.
|
||||
modes?: string[]; // operator's configured bands; falls back to DEFAULT_BANDS
|
||||
hasCall?: boolean; // a callsign is being entered — only then highlight the "current entry" cell
|
||||
// DX station coordinates, for its sunrise/sunset. Optional: many spots resolve
|
||||
// to an entity with no position at all, and the block simply does not appear.
|
||||
@@ -121,10 +124,31 @@ function cellTitle(t: (k: string) => string, band: string, cls: string, status:
|
||||
return `${band} ${cls}: ${desc}${mine ? ' — ' + mine : ''}${current ? ' — ' + t('mx.current') : ''}`;
|
||||
}
|
||||
|
||||
export function BandSlotGrid({ wb, busy, currentBand, currentMode, bands, hasCall = true, lat, lon, forCall, onEditQso }: Props) {
|
||||
export function BandSlotGrid({ wb, busy, currentBand, currentMode, bands, modes, hasCall = true, lat, lon, forCall, onEditQso }: Props) {
|
||||
const { t } = useI18n();
|
||||
// Cell drill-down: which band+class the operator clicked, or null.
|
||||
const [slot, setSlot] = useState<{ band: string; cls: string } | null>(null);
|
||||
|
||||
// The DIGITAL row is a rotation, not a fixed row.
|
||||
//
|
||||
// One row for every digital mode would be the honest layout and there is no
|
||||
// height for it — the matrix sits in a fixed panel beside a dozen widgets.
|
||||
// So the row keeps its place and changes what it answers: DIG (all of them),
|
||||
// then each digital mode the operator actually uses, in the order their mode
|
||||
// list gives, then back to DIG. The backend publishes the same cells under
|
||||
// both the class name and the raw mode, so a rotation costs no round trip.
|
||||
const digModes = useMemo(
|
||||
() => (modes ?? [])
|
||||
.map((m) => (m || '').toUpperCase().trim())
|
||||
.filter((m) => m !== '' && m !== 'CW' && !PHONE_MODES.has(m)),
|
||||
[modes],
|
||||
);
|
||||
const [digIdx, setDigIdx] = useState(0); // 0 = the DIG group itself
|
||||
// A shorter mode list (the operator edited it) must not strand the rotation
|
||||
// on a row that no longer exists.
|
||||
const digPos = digModes.length ? digIdx % (digModes.length + 1) : 0;
|
||||
const digRow = digPos === 0 ? 'DIG' : digModes[digPos - 1];
|
||||
const cycleDig = () => setDigIdx((i) => (digModes.length ? (i + 1) % (digModes.length + 1) : 0));
|
||||
// Columns from the operator's configured bands (so the matrix shows only the
|
||||
// bands they actually use), falling back to the built-in default set.
|
||||
const cols = useMemo(
|
||||
@@ -310,7 +334,7 @@ export function BandSlotGrid({ wb, busy, currentBand, currentMode, bands, hasCal
|
||||
<table className="border-separate" style={{ borderSpacing: 3 }}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="w-[26px]" />
|
||||
<th className="w-[38px] min-w-[38px] max-w-[38px]" />
|
||||
{cols.map((b) => (
|
||||
<th
|
||||
key={b.tag}
|
||||
@@ -325,13 +349,29 @@ export function BandSlotGrid({ wb, busy, currentBand, currentMode, bands, hasCal
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{CLASSES.map((cls) => {
|
||||
const classCurrent = classMatchesMode(cls, currentMode);
|
||||
{CLASSES.map((clsBase) => {
|
||||
const cls = clsBase === 'DIG' ? digRow : clsBase;
|
||||
// On a specific digital mode the "you are here" mark has to be that
|
||||
// mode, not any digital one — otherwise every FT4 entry lights the
|
||||
// FT8 row it happens to be cycled to.
|
||||
const classCurrent = cls === clsBase
|
||||
? classMatchesMode(cls, currentMode)
|
||||
: (currentMode || '').toUpperCase() === cls;
|
||||
return (
|
||||
<tr key={cls}>
|
||||
<th
|
||||
onClick={clsBase === 'DIG' && digModes.length ? cycleDig : undefined}
|
||||
title={clsBase === 'DIG' && digModes.length ? t('bsg.digCycle') : undefined}
|
||||
className={cn(
|
||||
'font-mono text-[11px] font-semibold pr-1.5 text-right w-[26px]',
|
||||
// Sized once for the LONGEST label the rotation can show,
|
||||
// and pinned there: a column that grows when RTTY comes
|
||||
// round shifts every band beneath it, and the eye reads
|
||||
// that as the matrix moving rather than the row changing.
|
||||
'font-mono font-semibold pr-1.5 text-right w-[38px] min-w-[38px] max-w-[38px] overflow-hidden',
|
||||
// Beyond four characters (PSK31, MSK144) the type gives way
|
||||
// instead of the column.
|
||||
cls.length > 4 ? 'text-[9px]' : 'text-[11px]',
|
||||
clsBase === 'DIG' && digModes.length ? 'cursor-pointer hover:text-foreground' : '',
|
||||
classCurrent ? 'text-primary font-extrabold' : 'text-muted-foreground',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
// come from the same resolver the cluster uses, so a call means the same thing in
|
||||
// both panels rather than being judged twice by two rules.
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Radio, Search, X, Signal, ArrowUpRight, Timer, Trash2, Ban, Columns2, Bot } from 'lucide-react';
|
||||
import { AlertTriangle, Radio, Search, X, Signal, ArrowUpRight, Timer, Trash2, Ban, Columns2, Bot } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
import { chaseAllows } from '@/lib/spotDisplay';
|
||||
import { markerColour, type SpotMarkerKey } from '@/lib/spotMarkers';
|
||||
import { writeUiPref } from '@/lib/uiPref';
|
||||
import { decoderName } from '@/lib/decoderName';
|
||||
|
||||
export type Decode = {
|
||||
call: string;
|
||||
@@ -95,7 +96,13 @@ interface Props {
|
||||
// receiver reported last, which is a coin toss — each pane needs its own.
|
||||
txStates?: Record<string, TxMsg>;
|
||||
spotStatus: Record<string, StatusEntry>;
|
||||
// The band the RIG is on, when CAT is connected. Only ever compared with what
|
||||
// the decoder announces — see the drift warning.
|
||||
rigBand?: string;
|
||||
onCall: (d: Decode) => void;
|
||||
// A single click: take the station without transmitting — fill the entry, and
|
||||
// point the panels at it. Absent, a click falls back to onCall.
|
||||
onSelect?: (d: Decode) => void;
|
||||
myCall?: string;
|
||||
// Drop every decode and transmit message held for this panel. The list is a
|
||||
// live view, not data — clearing it costs nothing but the seconds until the
|
||||
@@ -112,6 +119,12 @@ interface Props {
|
||||
// machine off is not something to go hunting through a settings tree for.
|
||||
autoCallOn?: boolean;
|
||||
onToggleAutoCall?: () => void;
|
||||
// The engine's own account of what it is doing, straight from the backend.
|
||||
autoCall?: { target: string; calls: number; max: number; misses: number; max_miss: number; stopped: boolean; reason: string };
|
||||
// The chase list, here as well as in Preferences: naming the station you are
|
||||
// waiting for is done WHILE watching the band, not in a settings tree.
|
||||
autoCallOnly?: string;
|
||||
onSetAutoCallOnly?: (list: string) => void;
|
||||
}
|
||||
|
||||
// The "new" categories, as toggle badges — the same idea and the same colours as
|
||||
@@ -539,12 +552,21 @@ function buildPeriods(filtered: Decode[], txMsgs: TxMsg[]) {
|
||||
}));
|
||||
}
|
||||
|
||||
export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, onCall, myCall, onClear, onHalt, autoCallOn, onToggleAutoCall }: Props) {
|
||||
export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, rigBand, onCall, onSelect, myCall, onClear, onHalt, autoCallOn, onToggleAutoCall, autoCall, autoCallOnly, onSetAutoCallOnly }: Props) {
|
||||
const { t } = useI18n();
|
||||
// Column widths, dragged in the header and shared by every row. Persisted
|
||||
// through writeUiPref (not raw localStorage) so the layout travels with data/
|
||||
// like every other portable preference.
|
||||
const [colw, setColw] = useState<ColWidths>(loadWidths);
|
||||
// The chase list as TYPED. Re-seeded whenever the stored value changes —
|
||||
// from Preferences, or from another window — but never while the box has the
|
||||
// focus, or a status arriving mid-word would rewrite what is being typed.
|
||||
const [onlyText, setOnlyText] = useState(autoCallOnly ?? '');
|
||||
useEffect(() => {
|
||||
const el = document.activeElement as HTMLElement | null;
|
||||
if (el && el.tagName === 'INPUT' && el.getAttribute('placeholder') === t('dec.chasePh')) return;
|
||||
setOnlyText(autoCallOnly ?? '');
|
||||
}, [autoCallOnly, t]);
|
||||
const template = useMemo(() => COLS.map((c) => `${colw[c.key]}px`).join(' '), [colw]);
|
||||
const tableW = useMemo(() => COLS.reduce((s, c) => s + colw[c.key], 0), [colw]);
|
||||
const setColWidth = (key: ColKey, px: number) => {
|
||||
@@ -597,6 +619,21 @@ export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, o
|
||||
|
||||
// The mode currently on the air, for the slot clock. The newest decode knows
|
||||
// best; between overs the transmit state still does.
|
||||
// A decoder that has lost its CAT link keeps announcing the last dial
|
||||
// frequency it knew, and every decode after that carries a stale band. Nothing
|
||||
// downstream can tell: the entity verdicts, the band filter and the FT map all
|
||||
// believe what the decoder said, and an operator ends up reading NEW BAND for a
|
||||
// band they are not on. (Seen for real: MSHV lost CAT, kept saying 80 m, and
|
||||
// Korea showed as a new band because on 80 m it would have been.)
|
||||
//
|
||||
// Said, not decided. Using the rig's band instead would be wrong for anyone
|
||||
// decoding a second receiver on another band, and a warning costs that setup
|
||||
// nothing but a line it can read past.
|
||||
const decoderBand = decodes.length ? (decodes[decodes.length - 1].band ?? '') : '';
|
||||
const bandDrift = !!rigBand && !!decoderBand
|
||||
&& rigBand.toLowerCase() !== decoderBand.toLowerCase();
|
||||
const driftInstance = decodes.length ? (decodes[decodes.length - 1].instance ?? '') : '';
|
||||
|
||||
const liveMode = decodes.length ? decodes[decodes.length - 1].mode : txState?.mode;
|
||||
const liveTr = trSeconds(liveMode, decodes.length ? decodes[decodes.length - 1].tr_period : undefined);
|
||||
|
||||
@@ -692,7 +729,8 @@ export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, o
|
||||
}
|
||||
return instances.map((inst) => ({
|
||||
key: inst,
|
||||
label: inst,
|
||||
// What the program is called, not the id it announces — see decoderName.
|
||||
label: decoderName(inst),
|
||||
tx: txStates?.[inst],
|
||||
periods: buildPeriods(
|
||||
filtered.filter((d) => (d.instance ?? '') === inst),
|
||||
@@ -733,6 +771,18 @@ export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, o
|
||||
what the transmit state reports, so it is right the moment anything
|
||||
is heard and keeps running when the band goes quiet. */}
|
||||
<PeriodClock trSec={liveTr} mode={liveMode} />
|
||||
{bandDrift && (
|
||||
<span
|
||||
title={t('dec.bandDriftTip')}
|
||||
className="inline-flex items-center gap-1 rounded-full border border-warning px-2 py-0.5 text-[11px] font-semibold text-warning">
|
||||
<AlertTriangle className="size-3.5" />
|
||||
{t('dec.bandDrift', {
|
||||
app: decoderName(driftInstance) || t('dec.bandDriftApp'),
|
||||
dec: decoderBand.toUpperCase(),
|
||||
rig: (rigBand ?? '').toUpperCase(),
|
||||
})}
|
||||
</span>
|
||||
)}
|
||||
<span className="w-px h-5 bg-border/60 mx-1" />
|
||||
|
||||
<button type="button" className={chip(cqOnly, 'success')} onClick={() => setCqOnly(!cqOnly)}>
|
||||
@@ -859,6 +909,54 @@ export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, o
|
||||
filter. Halt goes LAST — it is the one that must be findable without
|
||||
reading, and the end of the row is the one position that never moves
|
||||
as filters come and go. */}
|
||||
{/* Auto-call. Deliberately next to Halt: the two belong together, and
|
||||
what it is doing right now — which station, how many calls of how
|
||||
many — is on the button itself, because a thing that keys the
|
||||
transmitter must never be a switch with no readout. */}
|
||||
{onToggleAutoCall && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggleAutoCall}
|
||||
title={autoCall?.stopped ? t('dec.autoStoppedTip') : t('dec.autoCallTip')}
|
||||
className={cn('h-8 px-2.5 rounded-lg text-sm inline-flex items-center gap-1.5 border font-medium',
|
||||
!autoCallOn
|
||||
? 'border-border text-muted-foreground hover:bg-muted hover:text-foreground'
|
||||
: autoCall?.stopped
|
||||
? 'border-warning bg-warning text-warning-foreground'
|
||||
: 'border-success bg-success text-success-foreground')}
|
||||
>
|
||||
<Bot className="size-3.5" />
|
||||
{t('dec.autoCall')}
|
||||
{autoCallOn && autoCall?.target && (
|
||||
<span className="font-mono text-xs">
|
||||
{autoCall.target} {autoCall.calls}/{autoCall.max}
|
||||
{autoCall.misses > 0 ? ` ·${autoCall.misses}/${autoCall.max_miss}` : ''}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
{/* The chase list. Raw text while typing, committed on blur or Enter:
|
||||
the stored value is upper-cased and trimmed, and binding the box to
|
||||
that makes the space bar look dead — in a field whose whole purpose
|
||||
is a list separated by spaces. */}
|
||||
{onSetAutoCallOnly && (
|
||||
<input
|
||||
type="text"
|
||||
value={onlyText}
|
||||
onChange={(e) => setOnlyText(e.target.value)}
|
||||
onBlur={() => { if (onlyText.toUpperCase() !== (autoCallOnly ?? '')) onSetAutoCallOnly(onlyText); }}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') (e.target as HTMLInputElement).blur();
|
||||
if (e.key === 'Escape') setOnlyText(autoCallOnly ?? '');
|
||||
}}
|
||||
placeholder={t('dec.chasePh')}
|
||||
title={t('dec.chaseTip')}
|
||||
className={cn('h-8 w-44 rounded-lg border px-2 text-sm font-mono uppercase bg-background',
|
||||
(autoCallOnly ?? '').trim()
|
||||
? 'border-primary text-foreground'
|
||||
: 'border-border text-muted-foreground')}
|
||||
/>
|
||||
)}
|
||||
{onHalt && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -925,7 +1023,7 @@ export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, o
|
||||
<span className="flex-1" />
|
||||
{txState.band && <span className="text-xs text-muted-foreground shrink-0">{txState.band}</span>}
|
||||
{txState.instance && instances.length > 1 && (
|
||||
<span className="text-xs text-muted-foreground shrink-0">{txState.instance}</span>
|
||||
<span className="text-xs text-muted-foreground shrink-0">{decoderName(txState.instance)}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
@@ -1065,7 +1163,12 @@ export function DecodesPanel({ decodes, txMsgs, txState, txStates, spotStatus, o
|
||||
<button
|
||||
key={`${d.call}-${d.freq_hz}-${i}`}
|
||||
type="button"
|
||||
onClick={() => onCall(d)}
|
||||
// ONE click selects, TWO transmit — the cluster's rule, and
|
||||
// the only safe one here: a single click used to hand the
|
||||
// decode straight to WSJT-X as a Reply, so brushing a row
|
||||
// while reading the band started calling a station.
|
||||
onClick={() => (onSelect ?? onCall)(d)}
|
||||
onDoubleClick={() => onCall(d)}
|
||||
title={t('dec.callTitle', { call: d.call })}
|
||||
style={{ gridTemplateColumns: template, width: tableW }}
|
||||
className={cn(ROW, 'text-left border-b border-border/20 transition-colors',
|
||||
|
||||
@@ -71,6 +71,7 @@ interface Props {
|
||||
band: string;
|
||||
mode: string;
|
||||
bands?: string[]; // configured bands for the worked-before matrix columns
|
||||
modes?: string[]; // configured modes, in order — the matrix cycles its digital row through them
|
||||
// The station's satellites, for the SAT_NAME dropdown. Passed in rather than
|
||||
// read here: the list lives in Preferences, and App already reloads it when
|
||||
// Preferences close — a panel reading it once at mount would need a restart.
|
||||
@@ -155,7 +156,7 @@ function Field({ label, span = 1, className, children }: { label: string; span?:
|
||||
);
|
||||
}
|
||||
|
||||
export function DetailsPanel({ callsign, prefix, operatorGrid, remoteGrid, qth, name, country, comment, note, details, onChange, wb, wbBusy, band, mode, bands, satellites = [], slotCall, slotBand, slotMode, slotWb, slotWbBusy, tab, onTab, keyerActive, onEditQso }: Props) {
|
||||
export function DetailsPanel({ callsign, prefix, operatorGrid, remoteGrid, qth, name, country, comment, note, details, onChange, wb, wbBusy, band, mode, bands, modes, satellites = [], slotCall, slotBand, slotMode, slotWb, slotWbBusy, tab, onTab, keyerActive, onEditQso }: Props) {
|
||||
const { t } = useI18n();
|
||||
const [internalOpen, setInternalOpen] = useState<TabName>('stats');
|
||||
const open = tab ?? internalOpen; // controlled when `tab` is provided
|
||||
@@ -294,6 +295,7 @@ export function DetailsPanel({ callsign, prefix, operatorGrid, remoteGrid, qth,
|
||||
currentBand={slotCall ? (slotBand ?? '') : band}
|
||||
currentMode={slotCall ? (slotMode ?? '') : mode}
|
||||
bands={bands}
|
||||
modes={modes}
|
||||
hasCall={slotCall ? true : callsign.trim() !== ''}
|
||||
forCall={slotCall}
|
||||
onEditQso={onEditQso}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import L from 'leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { gridToLatLon, greatCirclePoints } from '@/lib/maidenhead';
|
||||
import { gridToLatLon, greatCirclePoints, splitAtAntimeridian } from '@/lib/maidenhead';
|
||||
import { BASEMAPS, type BasemapKey } from '@/components/MainMap';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
@@ -124,8 +124,12 @@ export function FTMapPanel({ decodes, myGrid }: { decodes: FTMapDecode[]; myGrid
|
||||
const age = now - Date.parse(d.at);
|
||||
const fade = Math.max(0.15, 1 - age / MAX_AGE_MS);
|
||||
const colour = bandColour(d.band);
|
||||
const pts = greatCirclePoints(from.lat, from.lon, to.lat, to.lon, 48);
|
||||
L.polyline(pts as L.LatLngExpression[], {
|
||||
// Cut at the antimeridian: this map shows ONE world, so a path running
|
||||
// past ±180 has to leave one edge and come back at the other. Without it
|
||||
// every arc out of VK or ZL was drawn into the blank space off the side
|
||||
// of the map, its far end sitting alone on the opposite coast.
|
||||
const pts = splitAtAntimeridian(greatCirclePoints(from.lat, from.lon, to.lat, to.lon, 48));
|
||||
L.polyline(pts as L.LatLngExpression[][], {
|
||||
color: colour, weight: 1.3, opacity: 0.65 * fade, smoothFactor: 0,
|
||||
}).addTo(layer);
|
||||
L.circleMarker([to.lat, to.lon], {
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
IcomSetRIT, IcomSetRITOn, IcomSetXITOn,
|
||||
IcomSetAntenna, IcomSetPBTInner, IcomSetPBTOuter, IcomSetManualNotch, IcomSetNotchPos,
|
||||
IcomSetSquelch, IcomSetComp, IcomSetCompLevel, IcomSetMonitor, IcomSetMonLevel,
|
||||
IcomSetVOX, IcomSetVOXGain, IcomSetAntiVOX, IcomSetPower,
|
||||
IcomSetVOX, IcomSetVOXGain, IcomSetAntiVOX, IcomSetPower, IcomRecallBand,
|
||||
} from '../../wailsjs/go/main/App';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
@@ -53,7 +53,13 @@ const ZERO: IcomState = {
|
||||
type Band = { l: string; hz: number };
|
||||
|
||||
const HF_BANDS: Band[] = [
|
||||
{ l: '160', hz: 1_840_000 }, { l: '80', hz: 3_750_000 }, { l: '40', hz: 7_100_000 },
|
||||
{ l: '160', hz: 1_840_000 }, { l: '80', hz: 3_750_000 },
|
||||
// 60 m: the middle of the IARU Region 1 allocation (5351.5-5366.5 kHz), which
|
||||
// every 60 m-capable rig can display. Where the band is channelised (the US)
|
||||
// the operator moves to their channel from here — the button is a way onto
|
||||
// the band, not a claim about what may be transmitted on it.
|
||||
{ l: '60', hz: 5_354_000 },
|
||||
{ l: '40', hz: 7_100_000 },
|
||||
{ l: '30', hz: 10_130_000 }, { l: '20', hz: 14_150_000 }, { l: '17', hz: 18_130_000 },
|
||||
{ l: '15', hz: 21_250_000 }, { l: '12', hz: 24_950_000 }, { l: '10', hz: 28_400_000 },
|
||||
];
|
||||
@@ -62,8 +68,9 @@ const B2 = { l: '2', hz: 144_300_000 }; // SSB calling
|
||||
const B70 = { l: '70cm', hz: 432_200_000 }; // SSB calling
|
||||
const B23 = { l: '23cm', hz: 1_296_200_000 }; // SSB calling
|
||||
|
||||
// Band buttons jump the VFO to a sensible default frequency (SSB/CW mix) using
|
||||
// the plain SetFrequency command — no band-stacking codes needed.
|
||||
// These frequencies are the FALLBACK: with the band stacking registers switched
|
||||
// on the radio is asked where the operator last was instead, and one of these is
|
||||
// only sent for a band or a model whose register cannot be read.
|
||||
//
|
||||
// Which buttons to OFFER depends on the radio, exactly as the attenuator steps
|
||||
// do below. An IC-9700 has no HF at all, yet the console was showing it 160
|
||||
@@ -78,9 +85,36 @@ function bandsFor(model?: string): Band[] {
|
||||
return [...HF_BANDS, B6];
|
||||
}
|
||||
|
||||
// Mode buttons for the console (like RS-BA1's row). SetCATMode picks USB/LSB for
|
||||
// SSB by frequency and the rig's data variant for digital modes.
|
||||
const MODES = ['SSB', 'CW', 'RTTY', 'PSK', 'AM', 'FM', 'DATA'];
|
||||
// Mode buttons for the console (like RS-BA1's row).
|
||||
//
|
||||
// LSB and USB by NAME, not one "SSB" button that resolves by band: the band
|
||||
// convention is right for a logged mode and useless when the operator means
|
||||
// "put this radio in USB on 40 m", which the console could not express at all.
|
||||
//
|
||||
// PSK is native only on the 7610/7760/7851 class; every other rig NAKs 0x12, so
|
||||
// there the button is dead furniture — see modesFor. Soundcard PSK31 rides on
|
||||
// DATA, which every rig can do.
|
||||
const MODES_BASE = ['LSB', 'USB', 'CW', 'RTTY', 'AM', 'FM', 'DATA'];
|
||||
|
||||
function hasNativePSK(model?: string): boolean {
|
||||
const m = (model ?? '').toUpperCase();
|
||||
return m.includes('7610') || m.includes('7760') || m.includes('7851') ||
|
||||
m.includes('7800') || m.includes('7700');
|
||||
}
|
||||
|
||||
function modesFor(model?: string): string[] {
|
||||
if (!hasNativePSK(model)) return MODES_BASE;
|
||||
return [...MODES_BASE.slice(0, 4), 'PSK', ...MODES_BASE.slice(4)];
|
||||
}
|
||||
|
||||
// Which radios actually have an antenna selector on the CI-V command (0x12).
|
||||
// An IC-7300 has ONE socket: offering it ANT1/ANT2 was two buttons that could
|
||||
// only ever disagree with the front panel.
|
||||
function hasAntennaSelector(model?: string): boolean {
|
||||
const m = (model ?? '').toUpperCase();
|
||||
return m.includes('7610') || m.includes('7760') || m.includes('7851') ||
|
||||
m.includes('7800') || m.includes('7700') || m.includes('9700');
|
||||
}
|
||||
|
||||
// Attenuator steps are MODEL-dependent even though the CI-V command (0x11) is the
|
||||
// same: the value byte is the dB. The IC-7610 (and 7700/7800/7851) have a 6/12/18
|
||||
@@ -155,9 +189,21 @@ function icomWatts(pct: number): { w: number; defl: number } {
|
||||
return { w: Math.round(w), defl };
|
||||
}
|
||||
|
||||
function modeMatches(btn: string, cur?: string): boolean {
|
||||
// Which sideband a bare "SSB" means at this frequency — the same convention the
|
||||
// backend applies when it resolves the mode for the radio.
|
||||
function sideForHz(hz?: number): string | null {
|
||||
if (!hz || hz <= 0) return null;
|
||||
return hz < 10_000_000 ? 'LSB' : 'USB';
|
||||
}
|
||||
|
||||
function modeMatches(btn: string, cur?: string, hz?: number): boolean {
|
||||
if (!cur) return false;
|
||||
if (btn === 'SSB') return cur === 'SSB' || cur === 'USB' || cur === 'LSB';
|
||||
// A rig that reports the folded ADIF "SSB" still lights the side its
|
||||
// frequency implies, so the row is never blank on a phone contact.
|
||||
if (btn === 'USB' || btn === 'LSB') {
|
||||
if (cur === btn) return true;
|
||||
return cur === 'SSB' && btn === (sideForHz(hz) ?? '');
|
||||
}
|
||||
// The backend surfaces USB-D as the operator's digital default (FT8…), or as
|
||||
// plain DATA — either way it is the DATA button that should light.
|
||||
if (btn === 'DATA') return ['DATA', 'FT8', 'FT4', 'JS8', 'JT65', 'JT9', 'MFSK', 'OLIVIA'].includes(cur);
|
||||
@@ -347,6 +393,19 @@ export function IcomPanel({ onReportRST, isNetwork = false }: { onReportRST?: (r
|
||||
const [st, setSt] = useState<IcomState>(ZERO);
|
||||
const [cat, setCat] = useState<any>(null); // RigState (freq/mode/split) for the VFO display
|
||||
const [tuning, setTuning] = useState(false);
|
||||
// Band buttons: recall the radio's own band stacking register instead of
|
||||
// sending a frequency picked here. Remembered per operator, not per session —
|
||||
// it is a preference about how a button behaves, and having to set it again
|
||||
// at every launch would make it not worth having.
|
||||
const [bandStack, setBandStack] = useState(() => localStorage.getItem('opslog.icomBandStack') === '1');
|
||||
const toggleBandStack = () => setBandStack((v) => {
|
||||
const n = !v;
|
||||
try { localStorage.setItem('opslog.icomBandStack', n ? '1' : '0'); } catch { /* private mode */ }
|
||||
return n;
|
||||
});
|
||||
// Which register each band was last recalled from, so pressing the same band
|
||||
// again walks 1 → 2 → 3 → 1, exactly as the radio's own band key does.
|
||||
const bandRegRef = useRef<Record<string, number>>({});
|
||||
const txRef = useRef(false);
|
||||
const stRef = useRef<IcomState>(ZERO); stRef.current = st;
|
||||
|
||||
@@ -355,6 +414,18 @@ export function IcomPanel({ onReportRST, isNetwork = false }: { onReportRST?: (r
|
||||
GetCATState().then((c) => setCat(c ?? null)).catch(() => {});
|
||||
};
|
||||
const setMode = (m: string) => { setCat((c: any) => (c ? { ...c, mode: m } : c)); SetCATMode(m).catch(() => {}); };
|
||||
|
||||
// A band button. With the stacking registers on, ask the radio where the
|
||||
// operator last was on that band; pressing the band it is already on steps to
|
||||
// the next register, and the fixed frequency below is the fallback for a band
|
||||
// or a model whose register the backend will not read — never a dead button.
|
||||
const bandClick = (b: Band, here: boolean) => {
|
||||
if (!bandStack) { SetCATFrequency(b.hz).catch(() => {}); return; }
|
||||
const reg = here ? (bandRegRef.current[b.l] ?? 1) % 3 + 1 : 1;
|
||||
IcomRecallBand(b.l, reg)
|
||||
.then(() => { bandRegRef.current[b.l] = reg; load(); })
|
||||
.catch(() => SetCATFrequency(b.hz).catch(() => {}));
|
||||
};
|
||||
// Initial one-shot read of the rig's DSP snapshot on mount (the 500ms poll only
|
||||
// re-reads the cache; the backend also loads DSP on the first responsive read).
|
||||
const refresh = async () => {
|
||||
@@ -507,9 +578,10 @@ export function IcomPanel({ onReportRST, isNetwork = false }: { onReportRST?: (r
|
||||
</div>
|
||||
</div>
|
||||
{/* Mode selector row (RS-BA1's SSB/CW/RTTY/PSK/AM/FM). */}
|
||||
<div className="grid grid-cols-7 border-t border-border/60 divide-x divide-border/60">
|
||||
{MODES.map((m) => {
|
||||
const on = modeMatches(m, curMode);
|
||||
<div className="grid border-t border-border/60 divide-x divide-border/60"
|
||||
style={{ gridTemplateColumns: `repeat(${modesFor(st.model).length}, minmax(0, 1fr))` }}>
|
||||
{modesFor(st.model).map((m) => {
|
||||
const on = modeMatches(m, curMode, mainHz);
|
||||
return (
|
||||
<button key={m} type="button" onClick={() => setMode(m)}
|
||||
className={cn('py-1.5 text-[11px] font-bold tracking-wide transition-colors',
|
||||
@@ -546,11 +618,16 @@ export function IcomPanel({ onReportRST, isNetwork = false }: { onReportRST?: (r
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-3">
|
||||
{/* Band buttons + antenna selection. */}
|
||||
<Card icon={Antenna} title={t('icmp.bandsAntenna')} accent="#0891b2">
|
||||
<label className="flex items-center gap-1.5 mb-1.5 text-[11px] text-muted-foreground cursor-pointer select-none"
|
||||
title={t('icmp.bandStackHint')}>
|
||||
<input type="checkbox" checked={bandStack} onChange={toggleBandStack} className="accent-primary" />
|
||||
{t('icmp.bandStack')}
|
||||
</label>
|
||||
<div className="grid grid-cols-5 gap-1.5">
|
||||
{bandsFor(st.model).map((b) => {
|
||||
const here = bandOfHz(mainHz) === b.l;
|
||||
return (
|
||||
<button key={b.l} type="button" onClick={() => SetCATFrequency(b.hz).catch(() => {})}
|
||||
<button key={b.l} type="button" onClick={() => bandClick(b, here)}
|
||||
title={here ? t('icmp.bandCurrent', { b: b.l }) : undefined}
|
||||
className={cn('px-1 py-1.5 rounded-md text-[11px] font-bold border transition-colors',
|
||||
here
|
||||
@@ -561,10 +638,12 @@ export function IcomPanel({ onReportRST, isNetwork = false }: { onReportRST?: (r
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<Row label={t('icmp.antenna')}>
|
||||
<Segmented value={String(st.antenna)} options={[{ v: '1', l: 'ANT1' }, { v: '2', l: 'ANT2' }]}
|
||||
onChange={(v) => set({ antenna: parseInt(v) }, () => IcomSetAntenna(parseInt(v)))} />
|
||||
</Row>
|
||||
{hasAntennaSelector(st.model) && (
|
||||
<Row label={t('icmp.antenna')}>
|
||||
<Segmented value={String(st.antenna)} options={[{ v: '1', l: 'ANT1' }, { v: '2', l: 'ANT2' }]}
|
||||
onChange={(v) => set({ antenna: parseInt(v) }, () => IcomSetAntenna(parseInt(v)))} />
|
||||
</Row>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
{/* Clarifiers: RIT & ΔTX (XIT) — wheel or ± to shift, Ctrl+←/→ shifts RIT. */}
|
||||
@@ -588,7 +667,10 @@ export function IcomPanel({ onReportRST, isNetwork = false }: { onReportRST?: (r
|
||||
{(st.model ?? '').includes('7760') ? `${st.rf_power * 2} W` : st.rf_power}
|
||||
</span>
|
||||
</Row>
|
||||
{isPhone && (
|
||||
{/* Not phone-only: on USB-D the same control still sets what the radio
|
||||
transmits at, and hiding it left an operator who lives in FT8 with
|
||||
no mic gain at all. */}
|
||||
{(
|
||||
<Row label={t('icmp.mic')}>
|
||||
<Slider value={st.mic_gain} accent="#ef4444" onChange={(v) => set({ mic_gain: v }, () => IcomSetMicGain(v))} />
|
||||
<span className="w-8 text-right text-xs font-mono tabular-nums text-muted-foreground">{st.mic_gain}</span>
|
||||
|
||||
@@ -0,0 +1,329 @@
|
||||
// PSKReporterPanel — can the station I am about to call actually hear me?
|
||||
//
|
||||
// The decodes list to the left says who is transmitting. It cannot say anything
|
||||
// about the other direction, and on FT8 that is the whole question: the DX's
|
||||
// pileup is invisible from here, and a station whose region is not open to
|
||||
// yours will not hear you however many times you call.
|
||||
//
|
||||
// Every number here comes from PSK Reporter — reports uploaded by ordinary
|
||||
// stations saying "I decoded X" — over a five-minute window. Nothing is
|
||||
// inferred and nothing is remembered: when the window empties the panel says it
|
||||
// does not know, which is the honest answer and the reason each block also says
|
||||
// what it is measuring.
|
||||
//
|
||||
// The backend (internal/pskrtgt) does the analysis; this draws it and polls.
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Activity, ChevronRight } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
import { GetPSKAnalysis, SetPSKTarget } from '../../wailsjs/go/main/App';
|
||||
|
||||
export type PSKEntry = {
|
||||
call: string;
|
||||
grid?: string;
|
||||
snr: number;
|
||||
offset_hz: number;
|
||||
age_sec: number;
|
||||
};
|
||||
|
||||
export type PSKAnalysis = {
|
||||
target?: string;
|
||||
mode?: string;
|
||||
enabled: boolean;
|
||||
online: boolean;
|
||||
spots: number;
|
||||
he_me: boolean;
|
||||
he_me_seconds: number;
|
||||
he_me_snr: number;
|
||||
he_me_offset_hz: number;
|
||||
target_uploads: boolean;
|
||||
target_grid?: string;
|
||||
near_him_count: number;
|
||||
near_him_top?: PSKEntry[];
|
||||
from_my_area_count: number;
|
||||
from_my_area_top?: PSKEntry[];
|
||||
path_open: boolean;
|
||||
heard_by_count: number;
|
||||
heard_near_me: number;
|
||||
heard_near_me_top?: PSKEntry[];
|
||||
decoded_by_count: number;
|
||||
decoded_by_top?: PSKEntry[];
|
||||
decoded_by_calls?: string[];
|
||||
pileup_count: number;
|
||||
dial_hz: number;
|
||||
ceiling_hz: number;
|
||||
decodes_in_window: number;
|
||||
bins?: { offset_hz: number; count: number; avg_snr: number }[];
|
||||
suggested_offset: number;
|
||||
};
|
||||
|
||||
interface Props {
|
||||
// The station to analyse and the mode it was heard on. Set by clicking a
|
||||
// decode, or by whoever the digital application says it is calling.
|
||||
target: string;
|
||||
mode?: string;
|
||||
// The operator's own dial, which is what turns a report's frequency into an
|
||||
// audio offset. Without it the passband block has nothing to say.
|
||||
dialHz?: number;
|
||||
// The local decodes, for "callers you hear": stations WE are decoding that
|
||||
// are calling the same DX. That is the competition measured at this end,
|
||||
// which no amount of PSK Reporter data can show.
|
||||
callers: number;
|
||||
callerCalls?: string[];
|
||||
onCollapse: () => void;
|
||||
}
|
||||
|
||||
// The passband strip: 60 Hz bins, drawn from 200 Hz to 4000 Hz. The bin edges
|
||||
// have to match the backend's alignment exactly — it keys them on multiples of
|
||||
// 60 from zero, so a strip starting at 200 would ask for edges that never
|
||||
// exist and draw an empty histogram over a busy passband.
|
||||
const LO = 200, HI = 4000, STEP = 60;
|
||||
const FIRST_EDGE = Math.floor(LO / STEP) * STEP;
|
||||
const COLS = Math.floor((HI - FIRST_EDGE) / STEP);
|
||||
|
||||
export function PSKReporterPanel({ target, mode, dialHz, callers, callerCalls, onCollapse }: Props) {
|
||||
const { t } = useI18n();
|
||||
const [a, setA] = useState<PSKAnalysis | null>(null);
|
||||
|
||||
// One second, matching the panel's own claim about how fresh it is. The call
|
||||
// is a snapshot of an in-memory window — no query and no network of its own.
|
||||
useEffect(() => {
|
||||
let stop = false;
|
||||
const tick = () => {
|
||||
GetPSKAnalysis().then((r) => { if (!stop) setA(r as unknown as PSKAnalysis); }).catch(() => {});
|
||||
};
|
||||
tick();
|
||||
const id = window.setInterval(tick, 1000);
|
||||
return () => { stop = true; window.clearInterval(id); };
|
||||
}, []);
|
||||
|
||||
// The target is re-asserted rather than sent once. The backend treats an
|
||||
// unchanged callsign as a no-op, and this way a broker that dropped while
|
||||
// nobody was looking comes back on its own instead of leaving a panel that
|
||||
// is permanently, silently empty.
|
||||
useEffect(() => {
|
||||
SetPSKTarget(target ?? '', mode ?? '', dialHz ?? 0).catch(() => {});
|
||||
if (!target) return;
|
||||
const id = window.setInterval(() => {
|
||||
SetPSKTarget(target, mode ?? '', dialHz ?? 0).catch(() => {});
|
||||
}, 15000);
|
||||
return () => window.clearInterval(id);
|
||||
}, [target, mode, dialHz]);
|
||||
|
||||
const bins = a?.bins ?? [];
|
||||
const maxCount = useMemo(() => bins.reduce((m, b) => Math.max(m, b.count || 0), 0) || 1, [bins]);
|
||||
const byOffset = useMemo(() => {
|
||||
const m = new Map<number, { count: number; avg_snr: number }>();
|
||||
for (const b of bins) m.set(b.offset_hz, b);
|
||||
return m;
|
||||
}, [bins]);
|
||||
const columns = useMemo(() => {
|
||||
const out: { edge: number; count: number; snr: number | null }[] = [];
|
||||
for (let i = 0; i < COLS; i++) {
|
||||
const edge = FIRST_EDGE + i * STEP;
|
||||
const b = byOffset.get(edge);
|
||||
out.push({ edge, count: b?.count ?? 0, snr: b?.avg_snr ?? null });
|
||||
}
|
||||
return out;
|
||||
}, [byOffset]);
|
||||
|
||||
// Confirmed pileup: a station we hear calling this DX that the DX has also
|
||||
// decoded. Two independent pieces of evidence, so it is the one number here
|
||||
// that is not a proxy for anything.
|
||||
const confirmed = useMemo(() => {
|
||||
const heard = new Set((a?.decoded_by_calls ?? []).map((c) => c.toUpperCase()));
|
||||
return (callerCalls ?? []).filter((c) => heard.has(c.toUpperCase())).length;
|
||||
}, [a?.decoded_by_calls, callerCalls]);
|
||||
|
||||
const snr = (v: number) => `${v > 0 ? '+' : ''}${v}`;
|
||||
|
||||
const Tile = ({ label, value, foot, tone, title }: {
|
||||
label: string; value: number | string; foot: string; tone: string; title?: string;
|
||||
}) => (
|
||||
<div className="px-2 py-1.5 rounded-md bg-muted/40 border border-border/60" title={title}>
|
||||
<div className="text-[9px] uppercase tracking-wide text-muted-foreground">{label}</div>
|
||||
<div className={cn('text-lg font-bold leading-tight', tone)}>{value}</div>
|
||||
<div className="text-[10px] text-muted-foreground">{foot}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="w-[340px] shrink-0 flex flex-col min-h-0 border-l border-border bg-card">
|
||||
{/* Header: what is being watched, and whether the feed is actually up. A
|
||||
panel full of zeros means one of two very different things. */}
|
||||
<div className="flex items-center gap-2 px-2.5 py-2 border-b border-border shrink-0">
|
||||
<Activity className="size-4 text-primary shrink-0" />
|
||||
<span className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
||||
{t('psk.title')}
|
||||
</span>
|
||||
{target && <span className="text-xs font-mono text-foreground truncate">→ {target}</span>}
|
||||
<span className="ml-auto flex items-center gap-2 text-[10px] shrink-0">
|
||||
{a?.target && a.spots > 0 && (
|
||||
<span className="text-muted-foreground" title={t('psk.spotsTip')}>{t('psk.spots', { n: a.spots })}</span>
|
||||
)}
|
||||
{a?.enabled === false
|
||||
? <span className="text-muted-foreground">{t('psk.off')}</span>
|
||||
: a?.online
|
||||
? <span className="text-success">● {t('psk.online')}</span>
|
||||
: <span className="text-muted-foreground">○ {t('psk.offline')}</span>}
|
||||
<button type="button" onClick={onCollapse} title={t('psk.hide')}
|
||||
className="p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground">
|
||||
<ChevronRight className="size-4" />
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-h-0 overflow-y-auto px-2.5 py-2 space-y-3">
|
||||
{a?.enabled === false ? (
|
||||
<p className="text-xs text-muted-foreground italic">{t('psk.enableHint')}</p>
|
||||
) : !target ? (
|
||||
<p className="text-xs text-muted-foreground italic">{t('psk.pickHint')}</p>
|
||||
) : (
|
||||
<>
|
||||
{/* ── The answer ──────────────────────────────────────────── */}
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={cn('shrink-0 size-8 rounded-full border flex items-center justify-center text-base',
|
||||
a?.he_me ? 'bg-success/20 border-success/50 text-success'
|
||||
: a?.path_open ? 'bg-warning/20 border-warning/50 text-warning'
|
||||
: 'bg-muted border-border text-muted-foreground')}>
|
||||
{a?.he_me ? '✓' : a?.path_open ? '≈' : '·'}
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
{a?.he_me ? (
|
||||
<>
|
||||
<div className="text-sm font-semibold text-success">{t('psk.heardYou', { s: a.he_me_seconds })}</div>
|
||||
<div className="text-[11px] font-mono text-muted-foreground">
|
||||
{snr(a.he_me_snr)} dB{a.he_me_offset_hz > 0 ? ` @ +${a.he_me_offset_hz} Hz` : ''}
|
||||
</div>
|
||||
</>
|
||||
) : a?.path_open ? (
|
||||
<>
|
||||
<div className="text-sm font-semibold text-warning">{t('psk.pathOpen')}</div>
|
||||
<div className="text-[11px] text-muted-foreground">{t('psk.pathOpenSub', { n: a.from_my_area_count })}</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className="text-sm font-semibold text-muted-foreground">{t('psk.notYet')}</div>
|
||||
<div className="text-[11px] text-muted-foreground">{t('psk.notYetSub')}</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Your signal reported next to him. Only when he has not decoded
|
||||
you himself — that is strictly stronger evidence, and two
|
||||
banners saying the same thing differently is noise. */}
|
||||
{!a?.he_me && (a?.near_him_count ?? 0) > 0 && a?.target_grid && (
|
||||
<div className="px-2 py-1.5 rounded-md bg-info/10 border border-info/30">
|
||||
<div className="flex items-baseline justify-between gap-2 mb-0.5">
|
||||
<span className="text-[10px] uppercase tracking-wide font-semibold text-info">
|
||||
✓ {t('psk.nearHim', { g: a.target_grid })}
|
||||
</span>
|
||||
<span className="text-[10px] text-muted-foreground">{t('psk.nRx', { n: a.near_him_count })}</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-2 font-mono text-[11px]">
|
||||
{(a.near_him_top ?? []).map((h) => (
|
||||
<span key={h.call} className="text-info" title={`${h.call} ${h.grid ?? ''} · ${h.age_sec}s`}>
|
||||
{h.call} <span className="text-muted-foreground">{snr(h.snr)}</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── The four numbers ────────────────────────────────────── */}
|
||||
<div className="grid grid-cols-2 gap-1.5">
|
||||
<Tile label={t('psk.tFromArea')} value={a?.from_my_area_count ?? 0} foot={t('psk.tFromAreaFoot')}
|
||||
tone="text-success"
|
||||
title={(a?.from_my_area_top ?? []).map((h) => `${h.call} (${h.grid ?? '?'}) ${snr(h.snr)}`).join(' · ')} />
|
||||
<Tile label={t('psk.tPileup')} value={a?.pileup_count ?? 0} foot={t('psk.tPileupFoot')}
|
||||
tone="text-primary" title={t('psk.tPileupTip')} />
|
||||
<Tile label={t('psk.tHeardNear')} value={a?.heard_near_me ?? 0} foot={t('psk.tHeardNearFoot')}
|
||||
tone="text-info"
|
||||
title={t('psk.tHeardNearTip', { n: a?.heard_by_count ?? 0 })} />
|
||||
<Tile label={t('psk.tCallers')} value={confirmed > 0 ? `${callers} (${confirmed})` : callers}
|
||||
foot={confirmed > 0 ? t('psk.tCallersFootConf') : t('psk.tCallersFoot')}
|
||||
tone="text-warning" title={t('psk.tCallersTip')} />
|
||||
</div>
|
||||
|
||||
{/* The one thing that turns an empty panel from a verdict into a
|
||||
missing measurement. */}
|
||||
{a?.target_uploads ? (
|
||||
<div className="text-[11px] text-success">✓ {t('psk.uploads')}</div>
|
||||
) : (
|
||||
<div className="px-2 py-1.5 rounded-md bg-warning/10 border border-warning/30 text-[11px] text-warning">
|
||||
⚠ {t('psk.noUploads', { c: target })}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Who near you he is hearing ──────────────────────────── */}
|
||||
<div>
|
||||
<div className="text-[10px] uppercase tracking-wide text-muted-foreground mb-0.5">{t('psk.fromAreaList')}</div>
|
||||
{(a?.from_my_area_top ?? []).length > 0 ? (
|
||||
<div className="flex flex-col gap-0.5 font-mono text-[11px]">
|
||||
{(a?.from_my_area_top ?? []).slice(0, 4).map((h) => (
|
||||
<div key={h.call} className="flex items-baseline gap-2 truncate"
|
||||
title={t('psk.rowTip', { c: h.call, g: h.grid ?? '?', s: h.age_sec, d: snr(h.snr) })}>
|
||||
<span className="font-semibold text-foreground w-20 truncate">{h.call}</span>
|
||||
<span className="text-muted-foreground w-12">({(h.grid ?? '?').slice(0, 4)})</span>
|
||||
<span className="text-success w-14">{snr(h.snr)} dB</span>
|
||||
{h.offset_hz > 0 && h.offset_hz < 10000 && (
|
||||
<span className="ml-auto text-muted-foreground whitespace-nowrap">@ +{h.offset_hz} Hz</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-[11px] text-muted-foreground italic">{t('psk.fromAreaEmpty')}</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* ── His passband ────────────────────────────────────────── */}
|
||||
<div>
|
||||
<div className="flex items-baseline justify-between gap-2 mb-1">
|
||||
<span className="text-[10px] uppercase tracking-wide text-muted-foreground">{t('psk.passband')}</span>
|
||||
<span className="text-[10px] font-mono text-muted-foreground">
|
||||
{(a?.ceiling_hz ?? 0) > 0
|
||||
? t('psk.ceiling', { hz: a!.ceiling_hz, n: a!.decodes_in_window })
|
||||
: (a?.decodes_in_window ?? 0) > 0 ? t('psk.noDial') : t('psk.noDecodes')}
|
||||
</span>
|
||||
</div>
|
||||
<div className="relative flex items-end gap-px h-10 rounded bg-muted/40 px-1 py-0.5 overflow-hidden">
|
||||
{columns.map((c) => {
|
||||
const ratio = c.count / maxCount;
|
||||
return (
|
||||
<div key={c.edge}
|
||||
className={cn('flex-1 min-w-0 rounded-sm',
|
||||
c.count === 0 ? 'bg-border'
|
||||
: ratio > 0.66 ? 'bg-primary'
|
||||
: ratio > 0.33 ? 'bg-primary/70' : 'bg-primary/40')}
|
||||
style={{ height: `${Math.max(2, Math.round(ratio * 36))}px` }}
|
||||
title={`${c.edge}-${c.edge + STEP} Hz · ${c.count}${c.snr !== null ? ` @ ${c.snr.toFixed(0)} dB` : ''}`} />
|
||||
);
|
||||
})}
|
||||
{(a?.suggested_offset ?? 0) > 0 && (
|
||||
<div className="absolute top-0 bottom-0 w-0.5 bg-success pointer-events-none"
|
||||
style={{ left: `${((a!.suggested_offset - LO) / (HI - LO)) * 100}%`, boxShadow: '0 0 4px currentColor' }}
|
||||
title={t('psk.tryOffset', { hz: a!.suggested_offset })} />
|
||||
)}
|
||||
</div>
|
||||
<div className="relative h-3 mt-0.5 text-[9px] font-mono text-muted-foreground">
|
||||
{[1000, 2000, 3000, 4000].map((hz) => (
|
||||
<span key={hz} className="absolute whitespace-nowrap"
|
||||
style={{ left: `${((hz - LO) / (HI - LO)) * 100}%`, transform: `translateX(${hz === HI ? '-100%' : '-50%'})` }}>
|
||||
{hz}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
{(a?.suggested_offset ?? 0) > 0 && (
|
||||
<div className="text-center text-[11px] font-mono text-success mt-0.5">
|
||||
🎯 {t('psk.tryOffset', { hz: a!.suggested_offset })}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -34,8 +34,8 @@ const UPLOAD_TARGETS: { service: string; name: string }[] = [
|
||||
{ service: 'hrdlog', name: 'HRDLog.net' },
|
||||
{ service: 'eqsl', name: 'eQSL.cc' },
|
||||
{ service: 'lotw', name: 'LoTW' },
|
||||
{ service: 'hamlog', name: 'HAMLOG.online' },
|
||||
{ service: 'hamqth', name: 'HamQTH' },
|
||||
{ service: 'cloudlog', name: 'Cloudlog / Wavelog' },
|
||||
];
|
||||
|
||||
// Lightweight right-click menu for the QSO grids. AG Grid's native context
|
||||
|
||||
@@ -60,7 +60,7 @@ import {
|
||||
GetFolderSync, SaveFolderSync, PickFolderSyncFolder, GetFolderSyncStatus, SyncFolderNow,
|
||||
GetRelayAuto, SaveRelayAuto, GetStationDevices,
|
||||
GetAwardDefs, GetTrackedAwards, SaveTrackedAwards,
|
||||
GetBandOpenSettings, SaveBandOpenSettings, GetGridScopeSettings, SaveGridScopeSettings, GetPSKReporterStatus, GetChaseNewGrids, SetChaseNewGrids, GetChaseNew, SetChaseNew, GetGridCacheStatus, GetLinkedAmps, SetLinkedAmps, GetSpotTTLMinutes, SetSpotTTLMinutes, GetSpotMax, SetSpotMax,
|
||||
GetBandOpenSettings, SaveBandOpenSettings, GetGridScopeSettings, SaveGridScopeSettings, GetPSKReporterStatus, GetChaseNewGrids, SetChaseNewGrids, GetChaseNew, SetChaseNew, GetPSKTargetSettings, SavePSKTargetSettings, GetAutoCallSettings, SaveAutoCallSettings, GetWatchlistContestCalls, SetWatchlistContestCalls, GetWatchlistContestPattern, SetWatchlistContestPattern, GetGridCacheStatus, GetLinkedAmps, SetLinkedAmps, GetSpotTTLMinutes, SetSpotTTLMinutes, GetSpotMax, SetSpotMax,
|
||||
} from '../../wailsjs/go/main/App';
|
||||
import type { profile as profileModels } from '../../wailsjs/go/models';
|
||||
import type { LookupSettingsForm, StationSettingsForm, ListsSettingsForm, ModePresetForm } from '@/types';
|
||||
@@ -484,6 +484,8 @@ const THEME_SWATCH: Record<Exclude<ThemeChoice, 'auto'>, { bg: string; card: str
|
||||
'dark-indigo': { bg: '#0e0f1f', card: '#181a30', accent: '#7c6cff' },
|
||||
'dark-teal': { bg: '#061c21', card: '#0d2c33', accent: '#22d3ee' },
|
||||
'dark-plum': { bg: '#180f1e', card: '#251830', accent: '#f472b6' },
|
||||
'dxhunter': { bg: '#0f172a', card: '#1e293b', accent: '#3b82f6' },
|
||||
'dxhunter-orange': { bg: '#0f172a', card: '#1e293b', accent: '#f97316' },
|
||||
'high-contrast': { bg: '#000000', card: '#0d0d0d', accent: '#ff7a1a' },
|
||||
};
|
||||
|
||||
@@ -1702,13 +1704,13 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
type AudioSettings = {
|
||||
from_radio: string; to_radio: string; recording_device: string; listening_device: string;
|
||||
qso_record: boolean; qso_dir: string; preroll_seconds: number;
|
||||
ptt_method: 'none' | 'cat' | 'rts' | 'dtr'; ptt_port: string; format: 'wav' | 'mp3';
|
||||
ptt_method: 'none' | 'cat' | 'rts' | 'dtr'; ptt_port: string; ptt_data?: boolean; format: 'wav' | 'mp3';
|
||||
from_gain: number; mic_gain: number; tx_gain: number; qso_play_gain: number;
|
||||
};
|
||||
type AudioDev = { id: string; name: string; default: boolean };
|
||||
const [audioCfg, setAudioCfg] = useState<AudioSettings>({
|
||||
from_radio: '', to_radio: '', recording_device: '', listening_device: '',
|
||||
qso_record: false, qso_dir: '', preroll_seconds: 8, ptt_method: 'none', ptt_port: '', format: 'wav',
|
||||
qso_record: false, qso_dir: '', preroll_seconds: 8, ptt_method: 'none', ptt_port: '', ptt_data: false, format: 'wav',
|
||||
from_gain: 100, mic_gain: 100, tx_gain: 100, qso_play_gain: 100,
|
||||
});
|
||||
const [audioInputs, setAudioInputs] = useState<AudioDev[]>([]);
|
||||
@@ -2086,6 +2088,21 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
const [chaseStateOn, setChaseStateOn] = useState(() => localStorage.getItem('opslog.chaseState') !== '0');
|
||||
const [chaseSotaOn, setChaseSotaOn] = useState(() => localStorage.getItem('opslog.chaseSota') !== '0');
|
||||
const [chaseNew, setChaseNew] = useState(false);
|
||||
const [pskTgt, setPskTgt] = useState<any>({ enabled: false, scope: 'target' });
|
||||
const [ac, setAc] = useState<any>({ enabled: false, only: '', attempts: 7, watched_attempts: 15, misses: 3, max_rounds: 3, rest_min: 2 });
|
||||
// The named contest callsigns. Raw text in state, written on blur: it is a
|
||||
// multi-line list, and normalising it on every keystroke would fight the
|
||||
// Return key — the one key this box is built around.
|
||||
const [contestCalls, setContestCalls] = useState('');
|
||||
const [contestPattern, setContestPattern] = useState('');
|
||||
const saveAC = async (next: any) => {
|
||||
setAc(next);
|
||||
try { await SaveAutoCallSettings(next); } catch { /* the toolbar shows what the engine is doing */ }
|
||||
};
|
||||
const savePSKTgt = async (next: any) => {
|
||||
setPskTgt(next);
|
||||
try { await SavePSKTargetSettings(next); } catch { /* the panel itself reports what the feed is doing */ }
|
||||
};
|
||||
const [spotTTL, setSpotTTL] = useState(0);
|
||||
const [spotTTLText, setSpotTTLText] = useState('0');
|
||||
const [spotMaxText, setSpotMaxText] = useState('1000');
|
||||
@@ -2113,6 +2130,10 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
writeUiPref('opslog.chaseGrids', g ? '1' : '0');
|
||||
} catch { /* defaults stand */ }
|
||||
try { setChaseNew(await GetChaseNew()); } catch { /* defaults stand */ }
|
||||
try { setPskTgt(await GetPSKTargetSettings()); } catch { /* defaults stand */ }
|
||||
try { setAc(await GetAutoCallSettings()); } catch { /* defaults stand */ }
|
||||
try { setContestCalls(await GetWatchlistContestCalls()); } catch { /* defaults stand */ }
|
||||
try { setContestPattern(await GetWatchlistContestPattern()); } catch { /* defaults stand */ }
|
||||
try { setLinkedAmps((await GetLinkedAmps()) ?? []); } catch { /* defaults stand */ }
|
||||
try { const n = await GetSpotTTLMinutes(); setSpotTTL(n); setSpotTTLText(String(n)); } catch { /* defaults stand */ }
|
||||
try { const n = await GetSpotMax(); setSpotMaxText(String(n)); } catch { /* defaults stand */ }
|
||||
@@ -5357,6 +5378,135 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
onCheckedChange={(c) => { setChaseNew(!!c); SetChaseNew(!!c).catch(() => {}); }} />
|
||||
<span>{t('chn.option')} <span className="text-xs text-muted-foreground">{t('chn.optionHelp')}</span></span>
|
||||
</label>
|
||||
{/* The same radius the band-opening watch uses — one feed, one
|
||||
circle — but reachable from here, because an operator who only
|
||||
wants the chase list would otherwise have to find it inside a
|
||||
watch they never switched on. It is the setting that decides
|
||||
whether this list has anything in it at all: where stations are
|
||||
far apart, 300 km can hold no receivers whatsoever. */}
|
||||
{chaseNew && (
|
||||
<div className="flex items-center gap-2 flex-wrap pl-6">
|
||||
<span className="text-xs text-muted-foreground">{t('bo.nearKm')}</span>
|
||||
<Input
|
||||
type="number" min={25} max={3000} step={25}
|
||||
className="w-24 h-7 text-xs"
|
||||
defaultValue={bandOpen.near_km ?? 300}
|
||||
key={`cnk-${bandOpen.near_km ?? 300}`}
|
||||
onBlur={(e) => {
|
||||
const v = parseInt(e.target.value, 10);
|
||||
if (!isNaN(v) && v !== bandOpen.near_km) saveBandOpen({ ...bandOpen, near_km: v });
|
||||
}}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') (e.target as HTMLInputElement).blur(); }}
|
||||
/>
|
||||
<span className="text-xs text-muted-foreground">km</span>
|
||||
<span className="text-xs text-muted-foreground">{t('chn.nearKmHint')}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* PSK Reporter analysis of the station being called. Same service as
|
||||
the two options above, opposite question: those ask what is being
|
||||
heard around here, this asks whether ONE station can hear you. */}
|
||||
<div className="border-t border-border/60 pt-3 space-y-2">
|
||||
<label className="flex items-start gap-2 text-sm cursor-pointer">
|
||||
<Checkbox checked={pskTgt.enabled} className="mt-0.5"
|
||||
onCheckedChange={(c) => savePSKTgt({ ...pskTgt, enabled: !!c })} />
|
||||
<span>{t('psk.setEnable')} <span className="text-xs text-muted-foreground">{t('psk.setEnableHint')}</span></span>
|
||||
</label>
|
||||
{pskTgt.enabled && (
|
||||
<div className="pl-6 space-y-1">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-xs text-muted-foreground">{t('psk.setScope')}</span>
|
||||
<Select value={pskTgt.scope} onValueChange={(v) => savePSKTgt({ ...pskTgt, scope: v })}>
|
||||
<SelectTrigger className="h-7 w-64 text-xs"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="target">{t('psk.setScopeTarget')}</SelectItem>
|
||||
<SelectItem value="band">{t('psk.setScopeBand')}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{t('psk.setScopeHint')}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Contest — how a special-event fleet finds its way onto the watch
|
||||
list on its own. Two halves, because a fleet has two kinds of
|
||||
member. */}
|
||||
<div className="border-t border-border/60 pt-3 space-y-2">
|
||||
<div className="text-sm font-medium">{t('wlc.title')}</div>
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-xs text-muted-foreground">{t('wlc.pattern')}</span>
|
||||
<Input className="h-7 w-32 text-xs font-mono uppercase"
|
||||
defaultValue={contestPattern} key={`wlcp-${contestPattern}`}
|
||||
placeholder={t('wlc.patternPh')}
|
||||
onBlur={(e) => {
|
||||
const v = e.target.value.toUpperCase().trim();
|
||||
if (v !== contestPattern) { setContestPattern(v); void SetWatchlistContestPattern(v); }
|
||||
}}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') (e.target as HTMLInputElement).blur(); }} />
|
||||
<span className="text-xs text-muted-foreground">{t('wlc.patternHint')}</span>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<span className="text-xs text-muted-foreground">{t('wlc.calls')}</span>
|
||||
<textarea
|
||||
className="w-full h-24 rounded-md border border-border bg-background p-2 text-xs font-mono uppercase"
|
||||
value={contestCalls}
|
||||
placeholder={t('wlc.callsPh')}
|
||||
onChange={(e) => setContestCalls(e.target.value)}
|
||||
onBlur={(e) => void SetWatchlistContestCalls(e.target.value)}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">{t('wlc.callsHint')}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Auto-call. Last in this section, and behind a warning: it is the
|
||||
only setting in OpsLog that transmits without being asked to. */}
|
||||
<div className="border-t border-border/60 pt-3 space-y-2">
|
||||
<label className="flex items-start gap-2 text-sm cursor-pointer">
|
||||
<Checkbox checked={ac.enabled} className="mt-0.5"
|
||||
onCheckedChange={(c) => saveAC({ ...ac, enabled: !!c })} />
|
||||
<span>{t('ac.enable')} <span className="text-xs text-muted-foreground">{t('ac.enableHint')}</span></span>
|
||||
</label>
|
||||
<p className="text-xs text-warning">{t('ac.warn')}</p>
|
||||
{ac.enabled && (
|
||||
<div className="pl-6 space-y-2">
|
||||
<p className="text-xs text-muted-foreground">{t('ac.ladder')}</p>
|
||||
{/* A LIST: several callsigns, spaces or commas. Committed on
|
||||
blur or Enter and kept as raw text while typing — binding the
|
||||
box to the parsed value is what makes the space key look dead,
|
||||
and space is the one key this field needs. */}
|
||||
<div className="flex items-start gap-2 flex-wrap">
|
||||
<span className="text-xs text-muted-foreground mt-1.5">{t('ac.only')}</span>
|
||||
<Input className="h-7 w-72 text-xs font-mono uppercase"
|
||||
defaultValue={ac.only ?? ''} key={`aco-${ac.only ?? ''}`}
|
||||
placeholder={t('ac.onlyPh')}
|
||||
onBlur={(e) => saveAC({ ...ac, only: e.target.value.toUpperCase() })}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') (e.target as HTMLInputElement).blur(); }} />
|
||||
<span className="text-xs text-muted-foreground mt-1.5">{t('ac.onlyHint')}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
{([
|
||||
['attempts', t('ac.attempts'), 1, 30],
|
||||
['watched_attempts', t('ac.watchedAttempts'), 1, 60],
|
||||
['misses', t('ac.misses'), 1, 10],
|
||||
['max_rounds', t('ac.rounds'), 1, 10],
|
||||
['rest_min', t('ac.rest'), 1, 60],
|
||||
] as [string, string, number, number][]).map(([k, label, min, max]) => (
|
||||
<span key={k} className="inline-flex items-center gap-1.5">
|
||||
<span className="text-xs text-muted-foreground">{label}</span>
|
||||
<Input type="number" min={min} max={max} className="h-7 w-16 text-xs"
|
||||
defaultValue={(ac as any)[k]} key={`ac-${k}-${(ac as any)[k]}`}
|
||||
onBlur={(e) => {
|
||||
const v = parseInt(e.target.value, 10);
|
||||
if (!isNaN(v) && v >= min && v <= max && v !== (ac as any)[k]) saveAC({ ...ac, [k]: v });
|
||||
}}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') (e.target as HTMLInputElement).blur(); }} />
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -5601,7 +5751,7 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-xs text-muted-foreground">{t('bo.nearKm')}</span>
|
||||
<Input
|
||||
type="number" min={25} max={1000} step={25}
|
||||
type="number" min={25} max={3000} step={25}
|
||||
className="w-24 h-7 text-xs"
|
||||
defaultValue={bandOpen.near_km ?? 300}
|
||||
key={`nk-${bandOpen.near_km ?? 300}`}
|
||||
@@ -6422,11 +6572,15 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
</div>
|
||||
|
||||
<div className="border-t border-border/60 pt-3 space-y-3">
|
||||
<label className="flex items-center gap-2 text-sm cursor-pointer">
|
||||
<Checkbox
|
||||
checked={hamlog.auto_upload}
|
||||
onCheckedChange={(c) => setHamlog({ auto_upload: !!c })}
|
||||
/>
|
||||
{/* The site stopped issuing API keys and its upload API takes
|
||||
nothing else, so an auto-upload switch here would arm something
|
||||
that can only fail. Their confirmations still arrive as a file,
|
||||
which never needed a key. */}
|
||||
<p className="text-xs rounded-md border border-warning/40 bg-warning/10 px-2 py-1.5 text-warning-muted-foreground">
|
||||
{t('es.hamlogClosed')}
|
||||
</p>
|
||||
<label className="flex items-center gap-2 text-sm cursor-not-allowed opacity-50">
|
||||
<Checkbox checked={false} disabled />
|
||||
{t('es.autoUpload')}
|
||||
</label>
|
||||
|
||||
@@ -7251,6 +7405,21 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{/* Kenwood only, because only a Kenwood acts on it: TX1 is that
|
||||
family's second transmit command. Every other backend keys the
|
||||
one way it knows, so showing the box there would be a switch
|
||||
that changes nothing — the same dead furniture as ANT2 on a
|
||||
radio with one socket. */}
|
||||
{audioCfg.ptt_method === 'cat' && catCfg.backend === 'kenwood' && (
|
||||
<>
|
||||
<span />
|
||||
<label className="flex items-start gap-2 text-sm cursor-pointer" title={t('aud.pttDataHint')}>
|
||||
<Checkbox className="mt-0.5" checked={!!audioCfg.ptt_data}
|
||||
onCheckedChange={(c) => setAudioField({ ptt_data: !!c })} />
|
||||
<span>{t('aud.pttData')}</span>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{(audioCfg.ptt_method === 'rts' || audioCfg.ptt_method === 'dtr') && (
|
||||
<>
|
||||
<Label className="text-sm">{t('aud.pttPort')}</Label>
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { Plus, Trash2, Edit2, RefreshCcw, ArrowDownToLine, ArrowUpFromLine } from 'lucide-react';
|
||||
import {
|
||||
ListUDPIntegrations, SaveUDPIntegration, DeleteUDPIntegration, ReloadUDPIntegrations,
|
||||
GetWsjtHighlight, SetWsjtHighlight, GetWsjtFollowMode, SetWsjtFollowMode,
|
||||
GetWsjtHighlight, SetWsjtHighlight, GetWsjtHighlightWorked, SetWsjtHighlightWorked, GetWsjtFollowMode, SetWsjtFollowMode,
|
||||
} from '../../wailsjs/go/main/App';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -160,9 +160,12 @@ type Props = { onError: (msg: string) => void };
|
||||
|
||||
export function UDPIntegrationsPanel({ onError }: Props) {
|
||||
const [highlightOn, setHighlightOn] = useState(false);
|
||||
const [hlWorked, setHlWorked] = useState(false);
|
||||
const [followMode, setFollowMode] = useState(true);
|
||||
useEffect(() => {
|
||||
GetWsjtHighlight().then((v) => setHighlightOn(!!v)).catch(() => {});
|
||||
GetWsjtHighlightWorked().then((v) => setHlWorked(!!v)).catch(() => {});
|
||||
GetWsjtHighlightWorked().then((v) => setHlWorked(!!v)).catch(() => {});
|
||||
GetWsjtFollowMode().then((v) => setFollowMode(!!v)).catch(() => {});
|
||||
}, []);
|
||||
const { t } = useI18n();
|
||||
@@ -246,6 +249,18 @@ export function UDPIntegrationsPanel({ onError }: Props) {
|
||||
<span className="block text-[11px] text-muted-foreground">{t('udpp.highlightHint')}</span>
|
||||
</span>
|
||||
</label>
|
||||
{/* Nested under the switch above: the same feature, and meaningless
|
||||
while that one is off. */}
|
||||
{highlightOn && (
|
||||
<label className="flex items-start gap-2 text-sm cursor-pointer max-w-2xl pl-6">
|
||||
<Checkbox checked={hlWorked}
|
||||
onCheckedChange={(c) => { setHlWorked(!!c); void SetWsjtHighlightWorked(!!c); }} />
|
||||
<span>
|
||||
{t('udpp.hlWorked')}
|
||||
<span className="block text-[11px] text-muted-foreground">{t('udpp.hlWorkedHint')}</span>
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
<label className="flex items-start gap-2 text-sm cursor-pointer max-w-2xl">
|
||||
<Checkbox checked={followMode}
|
||||
onCheckedChange={(c) => { setFollowMode(!!c); void SetWsjtFollowMode(!!c); }} />
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// The design is DXHunter's — the layout, the badges, the wording — repainted in
|
||||
// the app's theme tokens rather than its hard-coded slate/pink.
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Eye, Plus, Trash2, Bell, BellOff, Trophy, Search } from 'lucide-react';
|
||||
import { Eye, Plus, Trash2, Bell, BellOff, Trophy, Search, Check, AlertTriangle } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
@@ -235,8 +235,16 @@ export function WatchlistTab({ spots, spotStatus, onSpotSelect, onSpotClick }: P
|
||||
}
|
||||
};
|
||||
|
||||
// Three decimals, and no trailing zeros beyond them: 7.056 rather than
|
||||
// 7.0560, 14.0745 rather than 14.074500. DXHunter's own rule, and the one an
|
||||
// operator reads a cluster line with.
|
||||
const fmtMHz = (hz: number) => {
|
||||
const [int, dec] = (hz / 1e6).toFixed(6).split('.');
|
||||
return int + '.' + dec.slice(0, 3) + dec.slice(3).replace(/0+$/, '');
|
||||
};
|
||||
|
||||
const chip = (color: string, text: string, extra?: string) => (
|
||||
<span className={cn('px-1.5 py-0.5 rounded text-[10px] font-bold border', extra)}
|
||||
<span className={cn('px-1.5 py-0.5 rounded text-[11px] font-semibold border', extra)}
|
||||
style={{ color, borderColor: `color-mix(in srgb, ${color} 40%, transparent)`, background: `color-mix(in srgb, ${color} 12%, transparent)` }}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -332,14 +340,18 @@ export function WatchlistTab({ spots, spotStatus, onSpotSelect, onSpotClick }: P
|
||||
const list = neededOnly ? all.filter((s) => !workedFor(e, s)) : all;
|
||||
return (
|
||||
<div key={e.callsign}
|
||||
className={cn('rounded-lg border bg-card/70 p-3 transition-colors hover:bg-accent/20',
|
||||
className={cn('rounded border bg-card/70 p-3 transition-colors hover:bg-accent/20',
|
||||
needed > 0 ? 'border-warning/40' : 'border-border/70',
|
||||
e.isContest && 'border-l-4 border-l-warning')}>
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-lg font-bold font-mono" style={{ color: '#f472b6' }}>{e.callsign}</span>
|
||||
{/* Proportional, not monospaced: DXHunter sets this one in the
|
||||
interface font and the difference is the first thing an
|
||||
operator notices with the two windows side by side. There is
|
||||
nothing to align here — it is a heading, not a column. */}
|
||||
<span className="text-lg font-bold" style={{ color: '#f472b6' }}>{e.callsign}</span>
|
||||
{isOnAir(e) && chip('var(--danger)', t('wl.onAir'), 'animate-pulse')}
|
||||
{e.isContest && (
|
||||
<span className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-bold bg-warning-muted text-warning-muted-foreground border border-warning-border"
|
||||
<span className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-semibold bg-warning-muted text-warning-muted-foreground border border-warning-border"
|
||||
title={t('wl.contestHint')}>
|
||||
<Trophy className="size-3" /> {t('wl.contest')}
|
||||
</span>
|
||||
@@ -349,16 +361,16 @@ export function WatchlistTab({ spots, spotStatus, onSpotSelect, onSpotClick }: P
|
||||
{e.clubLogHasOQRS && chip('var(--success)', 'OQRS')}
|
||||
{e.clubLogLiveStream && (
|
||||
<a href="#" onClick={(ev) => { ev.preventDefault(); void OpenExternalURL(`https://clublog.org/livestream/${e.callsign.replace('*', '')}`); }}
|
||||
className="px-1.5 py-0.5 rounded text-[10px] font-bold border text-info border-info/40 bg-info/10 hover:bg-info/20">Live</a>
|
||||
className="px-1.5 py-0.5 rounded text-[11px] font-semibold border text-info border-info/40 bg-info/10 hover:bg-info/20">Live</a>
|
||||
)}
|
||||
{list.length > 0 && (needed > 0
|
||||
? chip('var(--warning)', e.isContest ? t('wl.nToday', { n: needed }) : t('wl.nNeeded', { n: needed }))
|
||||
: chip('var(--success)', e.isContest ? t('wl.workedToday') : t('wl.allWorked')))}
|
||||
{e.lastSeenStr && e.lastSeenStr !== 'Never' && (
|
||||
<span className="text-[11px] text-muted-foreground">· {e.lastSeenStr}</span>
|
||||
<span className="text-[11px] text-muted-foreground">• {e.lastSeenStr}</span>
|
||||
)}
|
||||
{e.spotCount > 0 && (
|
||||
<span className="text-[11px] text-muted-foreground/70">· {t('wl.totalSpots', { n: e.spotCount })}</span>
|
||||
<span className="text-[11px] text-muted-foreground/70">• {t('wl.totalSpots', { n: e.spotCount })}</span>
|
||||
)}
|
||||
<div className="flex-1" />
|
||||
<button type="button" title={t('wl.toggleContest')}
|
||||
@@ -390,14 +402,20 @@ export function WatchlistTab({ spots, spotStatus, onSpotSelect, onSpotClick }: P
|
||||
onDoubleClick={() => onSpotClick?.(s)}
|
||||
title={t('wl.spotTip')}
|
||||
className={cn('w-full flex items-center gap-2 px-2 py-1.5 rounded text-[11px] bg-muted/25 hover:bg-muted/70 transition-colors text-left',
|
||||
!done && 'border-l-[3px] border-warning')}>
|
||||
{done && <span className='font-bold shrink-0 text-success'>✓</span>}
|
||||
!done && 'border-l-2 border-warning')}>
|
||||
{/* Worked or wanted, said with a symbol at the head of
|
||||
the line as well as with the stripe down its side —
|
||||
the same two marks DXHunter uses, and the one an eye
|
||||
finds first when a card holds ten rows. */}
|
||||
{done
|
||||
? <Check className="size-4 shrink-0 text-success" />
|
||||
: <AlertTriangle className="size-4 shrink-0 text-warning" />}
|
||||
{/* Fixed columns: an elastic country made band/mode/freq start wherever the name ended — every row its own ruler. */}
|
||||
<span className="font-mono font-bold text-info shrink-0 w-24 truncate">{s.dx_call}</span>
|
||||
<span className="font-bold text-info shrink-0 w-24 truncate">{s.dx_call}</span>
|
||||
<span className="text-muted-foreground truncate shrink-0 w-44">{(s as any).country ?? ''}</span>
|
||||
<span className="px-1.5 rounded bg-muted shrink-0 w-11 text-center">{s.band}</span>
|
||||
<span className="px-1.5 rounded shrink-0 w-11 text-center" style={mode ? { color: 'var(--chart-5)', background: 'color-mix(in srgb, var(--chart-5) 12%, transparent)' } : undefined}>{mode || ' '}</span>
|
||||
<span className="font-mono text-muted-foreground shrink-0 w-16 text-right">{(s.freq_hz / 1e6).toFixed(4)}</span>
|
||||
<span className="font-mono text-muted-foreground shrink-0 w-16 text-right">{fmtMHz(s.freq_hz)}</span>
|
||||
{badge && chip(badge.color, badge.label)}
|
||||
<div className="flex-1" />
|
||||
{done
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
// Auto-call: let OpsLog answer a decode without the operator clicking it.
|
||||
//
|
||||
// WITHDRAWN FROM THE INTERFACE, because DXHunter already does it.
|
||||
//
|
||||
// Two programs from the same shack deciding on their own to answer the same
|
||||
// decode is worse than either doing it alone: they cannot see each other, so
|
||||
// they key over one another, and afterwards there is no telling which of them
|
||||
// called. The duplicate is the one to remove, and DXHunter is where this lives.
|
||||
//
|
||||
// There is no switch in Preferences and no button on the decodes toolbar, and
|
||||
// App.tsx returns before the loop can run. The file is kept whole: the rules
|
||||
// below are the delicate part, argued over and tested, and rewriting them from
|
||||
// memory later would be worse than leaving them here. Reinstating the feature
|
||||
// means restoring all three — the settings page, the button, and the guard.
|
||||
//
|
||||
// This KEYS THE TRANSMITTER on its own, which is why the rules here are written
|
||||
// as a series of refusals rather than a search for a reason to call. Everything
|
||||
// below has to be true; anything unknown means no.
|
||||
//
|
||||
// The decision is made here, in one pure function, precisely because it is the
|
||||
// dangerous part: it can be read, argued with and tested without a radio.
|
||||
|
||||
export type AutoCallCriteria = {
|
||||
dxcc: boolean; // entity never worked
|
||||
bandmode: boolean; // entity worked, but neither this band nor this mode
|
||||
band: boolean; // entity never worked on this band
|
||||
mode: boolean; // entity never worked in this mode
|
||||
slot: boolean; // band and mode each worked, never together
|
||||
grid: boolean; // square wanted under the grid scope
|
||||
county: boolean; // US county never worked
|
||||
pota: boolean; // park never worked
|
||||
// No SOTA here, though the shape invites it: a decode carries no summit
|
||||
// reference and the backend publishes no "new summit" flag, so a criterion
|
||||
// for it could never be true. It WAS declared, translated and impossible to
|
||||
// tick — a field that lies about what the feature can do.
|
||||
pfx: boolean; // CQ WPX prefix never worked
|
||||
};
|
||||
|
||||
export type AutoCallSettings = {
|
||||
enabled: boolean;
|
||||
criteria: AutoCallCriteria;
|
||||
// Callsigns to answer on sight, wildcards allowed (4S7*, */P). Each is still
|
||||
// subject to `watchCriteria` — "call TM0HQ, but only if it is a new band" is
|
||||
// the request, not "call it every time it appears".
|
||||
watch: string[];
|
||||
// Empty means call a watched callsign whenever it is not already worked.
|
||||
watchCriteria: AutoCallCriteria;
|
||||
// Seconds to ignore a callsign after calling it, so a station that keeps
|
||||
// sending CQ is not re-answered every slot while the QSO is in progress.
|
||||
cooldownSec: number;
|
||||
};
|
||||
|
||||
export const emptyCriteria: AutoCallCriteria = {
|
||||
dxcc: false, bandmode: false, band: false, mode: false, slot: false,
|
||||
grid: false, county: false, pota: false, pfx: false,
|
||||
};
|
||||
|
||||
export const defaultAutoCall: AutoCallSettings = {
|
||||
// OFF, and it stays off until asked for. Unattended transmit is not something
|
||||
// to inherit from an upgrade.
|
||||
enabled: false,
|
||||
criteria: { ...emptyCriteria },
|
||||
watch: [],
|
||||
watchCriteria: { ...emptyCriteria },
|
||||
cooldownSec: 120,
|
||||
};
|
||||
|
||||
const AC_KEY = 'opslog.autoCall';
|
||||
|
||||
export function loadAutoCall(): AutoCallSettings {
|
||||
try {
|
||||
const raw = localStorage.getItem(AC_KEY);
|
||||
if (!raw) return { ...defaultAutoCall };
|
||||
const v = JSON.parse(raw);
|
||||
const out: AutoCallSettings = {
|
||||
...defaultAutoCall,
|
||||
...v,
|
||||
criteria: { ...emptyCriteria, ...(v?.criteria ?? {}) },
|
||||
watchCriteria: { ...emptyCriteria, ...(v?.watchCriteria ?? {}) },
|
||||
watch: Array.isArray(v?.watch) ? v.watch : [],
|
||||
};
|
||||
// DISARMED ON SIGHT, and written back disabled.
|
||||
//
|
||||
// The runtime guard in App.tsx stops this build from calling anyone, but it
|
||||
// leaves "enabled": true sitting in storage, where any build without the
|
||||
// guard — an older one an operator reinstalls, a machine that upgrades
|
||||
// later — reads it and keys the transmitter for a feature with no switch
|
||||
// left to turn off. A withdrawn feature that keys a radio has to be
|
||||
// disarmed where it is REMEMBERED, not only where it runs.
|
||||
if (out.enabled) {
|
||||
out.enabled = false;
|
||||
try { localStorage.setItem(AC_KEY, JSON.stringify(out)); } catch { /* private mode: the guard still holds */ }
|
||||
}
|
||||
return out;
|
||||
} catch { return { ...defaultAutoCall }; }
|
||||
}
|
||||
|
||||
export const autoCallKey = AC_KEY;
|
||||
|
||||
// A decode's resolved novelty, the same shape the panel already renders from.
|
||||
export type DecodeStatus = {
|
||||
status?: string;
|
||||
worked_call?: boolean;
|
||||
new_grid?: boolean;
|
||||
grid_state?: string;
|
||||
new_county?: boolean;
|
||||
new_pota?: boolean;
|
||||
new_pfx?: boolean;
|
||||
};
|
||||
|
||||
// matchesWildcard is the same rule the alert filters use: * is any run, ? is one.
|
||||
export function matchesWildcard(pattern: string, call: string): boolean {
|
||||
const p = pattern.trim().toUpperCase();
|
||||
const c = call.trim().toUpperCase();
|
||||
if (!p) return false;
|
||||
const re = new RegExp('^' + p.split('').map((ch) => (
|
||||
ch === '*' ? '.*' : ch === '?' ? '.' : ch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
)).join('') + '$');
|
||||
return re.test(c);
|
||||
}
|
||||
|
||||
// anyCriterion is false for an all-off set, which is what makes "watch this
|
||||
// callsign, no conditions" expressible.
|
||||
function anyCriterion(c: AutoCallCriteria): boolean {
|
||||
return Object.values(c).some(Boolean);
|
||||
}
|
||||
|
||||
// meets reports whether a decode satisfies at least one ticked criterion.
|
||||
function meets(c: AutoCallCriteria, e: DecodeStatus): boolean {
|
||||
if (c.dxcc && e.status === 'new') return true;
|
||||
// Each status is exclusive, so a station that is new on both counts matches
|
||||
// ONLY this criterion — ticking "new band" alone would not catch it, which is
|
||||
// the wrong way round: it is the better catch of the two.
|
||||
if (c.bandmode && e.status === 'new-band-mode') return true;
|
||||
if (c.band && e.status === 'new-band') return true;
|
||||
if (c.mode && e.status === 'new-mode') return true;
|
||||
if (c.slot && e.status === 'new-slot') return true;
|
||||
// A square that is merely UNCONFIRMED is not called: the QSO is already made,
|
||||
// and calling again would work a duplicate to chase a QSL.
|
||||
if (c.grid && e.new_grid && e.grid_state !== 'unconf') return true;
|
||||
if (c.county && e.new_county) return true;
|
||||
if (c.pota && e.new_pota) return true;
|
||||
if (c.pfx && e.new_pfx) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export type AutoCallDecode = {
|
||||
call: string;
|
||||
cq?: boolean;
|
||||
msg?: string;
|
||||
instance?: string;
|
||||
};
|
||||
|
||||
// shouldAutoCall decides whether to answer one decode. The reason is returned
|
||||
// for the log: an automatic transmission with no record of WHY is the thing an
|
||||
// operator cannot argue with after the fact.
|
||||
export function shouldAutoCall(
|
||||
s: AutoCallSettings,
|
||||
d: AutoCallDecode,
|
||||
e: DecodeStatus | undefined,
|
||||
opts: {
|
||||
// busy is "some receiver is mid-QSO", NOT "this one is transmitting".
|
||||
//
|
||||
// The distinction is the whole bug it fixes: with two instances the caller
|
||||
// used to test a single global transmit flag, which belonged to whichever
|
||||
// receiver reported last. So while slice A worked a station, slice B looked
|
||||
// idle and auto-call started another QSO on it — and the moment either
|
||||
// finished it chained straight into the next. One station at a time means
|
||||
// one across ALL receivers, not one per receiver.
|
||||
busy: boolean;
|
||||
calledAt: Map<string, number>;
|
||||
now: number;
|
||||
myCall?: string;
|
||||
},
|
||||
): { call: boolean; reason: string } {
|
||||
const no = (why: string) => ({ call: false, reason: why });
|
||||
if (!s.enabled) return no('off');
|
||||
if (!e) return no('status not resolved yet');
|
||||
const call = (d.call ?? '').trim().toUpperCase();
|
||||
if (!call) return no('no callsign');
|
||||
// Never answer ourselves, however the decode reached us.
|
||||
if (opts.myCall && call === opts.myCall.trim().toUpperCase()) return no('own callsign');
|
||||
// NOT limited to a CQ, deliberately.
|
||||
//
|
||||
// It used to be, on the reasoning that answering a station mid-QSO is calling
|
||||
// over somebody. That reasoning ignored the case the feature exists for: a
|
||||
// DXpedition running a pileup never sends CQ at all — it works caller after
|
||||
// caller — so the rule sat out the one contact auto-call was turned on for. A
|
||||
// new entity on 15 m FT8, decode after decode, and not a single transmission.
|
||||
//
|
||||
// WHEN to transmit is not ours to decide either: the Reply goes to the
|
||||
// decoder, and MSHV starts at once while JTDX waits for a CQ. Two correct
|
||||
// behaviours, both belonging to the program that owns the timing. Here the
|
||||
// question is only whether the station is one the operator wants — the
|
||||
// criteria below answer that, and the cooldown and the busy check keep it from
|
||||
// calling twice.
|
||||
// Not while ANY receiver is mid-QSO — transmitting, or holding a DX call it
|
||||
// has not finished with. Starting a second exchange before the first is done
|
||||
// is what turned this into a machine that called without stopping.
|
||||
if (opts.busy) return no('a QSO is already in progress');
|
||||
const last = opts.calledAt.get(call);
|
||||
if (last !== undefined && opts.now - last < s.cooldownSec * 1000) return no('called recently');
|
||||
|
||||
// The watch list first: an explicitly named station outranks the general
|
||||
// criteria, and may carry conditions of its own.
|
||||
const watched = s.watch.some((p) => matchesWildcard(p, call));
|
||||
if (watched) {
|
||||
if (!anyCriterion(s.watchCriteria)) {
|
||||
// No conditions attached: call it unless it is already worked.
|
||||
return e.worked_call ? no('watched, but already worked') : { call: true, reason: 'watch list' };
|
||||
}
|
||||
return meets(s.watchCriteria, e)
|
||||
? { call: true, reason: 'watch list + criteria' }
|
||||
: no('watched, but no criterion met');
|
||||
}
|
||||
|
||||
if (!anyCriterion(s.criteria)) return no('no criteria ticked');
|
||||
return meets(s.criteria, e)
|
||||
? { call: true, reason: 'criteria' }
|
||||
: no('no criterion met');
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// What a decoding program is CALLED, as against what it calls itself.
|
||||
//
|
||||
// Every WSJT-X-family packet carries an "id" naming the sending program, and
|
||||
// OpsLog shows it wherever a receiver has to be told apart from another. Most
|
||||
// of them send the name on the box: "WSJT-X", "JTDX", "MSHV".
|
||||
//
|
||||
// Nexus does not. It announces itself as "Tempo" — the name of the engine
|
||||
// inside it — so an operator running Nexus saw a program on their screen they
|
||||
// have never heard of, and had to work out that it was theirs.
|
||||
//
|
||||
// Only the LABEL is translated. The id stays the routing key everywhere else:
|
||||
// a Reply, a Halt and the auto-call's own bookkeeping are matched against what
|
||||
// the program sent, and renaming that would send them to nobody.
|
||||
const NAMES: Record<string, string> = {
|
||||
TEMPO: 'Nexus',
|
||||
};
|
||||
|
||||
export function decoderName(id?: string): string {
|
||||
const raw = (id ?? '').trim();
|
||||
if (!raw) return '';
|
||||
// Matched on the leading word: some programs append a version or an instance
|
||||
// number ("WSJT-X - 2", "Tempo 1.4"), and the name is the part before it.
|
||||
const head = raw.split(/[\s\-–—]+/)[0].toUpperCase();
|
||||
return NAMES[head] ?? raw;
|
||||
}
|
||||
+100
-26
File diff suppressed because one or more lines are too long
@@ -172,6 +172,50 @@ export function greatCirclePoints(
|
||||
return out;
|
||||
}
|
||||
|
||||
// splitAtAntimeridian cuts a continuous (unwrapped) path into the pieces that
|
||||
// fit on a map showing ONE world, each piece with longitudes back inside ±180.
|
||||
//
|
||||
// greatCirclePoints deliberately lets longitude run past ±180 so the polyline
|
||||
// stays smooth. That is right for a map with repeating world copies, and wrong
|
||||
// for one without: an arc from Australia to South America came out at 190°,
|
||||
// 210°, 250° — drawn into the empty space off the right-hand edge, ending
|
||||
// nowhere, while its own end marker sat correctly on the far left. From VK,
|
||||
// where most paths cross the antimeridian, that was most of the map's arcs.
|
||||
//
|
||||
// Each crossing ends one piece at exactly ±180 and starts the next at the
|
||||
// opposite edge, at the SAME latitude, so the line leaves one side of the map
|
||||
// and re-enters the other at the height it left. Leaflet takes the result as a
|
||||
// multi-polyline, so one path is still one layer.
|
||||
export function splitAtAntimeridian(pts: [number, number][]): [number, number][][] {
|
||||
if (pts.length === 0) return [];
|
||||
// Which copy of the world a longitude belongs to: 0 is the map's own.
|
||||
const world = (lon: number) => Math.floor((lon + 180) / 360);
|
||||
const norm = (lon: number) => lon - 360 * world(lon);
|
||||
const out: [number, number][][] = [];
|
||||
let cur: [number, number][] = [];
|
||||
for (let i = 0; i < pts.length; i++) {
|
||||
const [lat, lon] = pts[i];
|
||||
if (i > 0) {
|
||||
const [pLat, pLon] = pts[i - 1];
|
||||
const wPrev = world(pLon), wCur = world(lon);
|
||||
if (wPrev !== wCur) {
|
||||
const east = wCur > wPrev;
|
||||
// The meridian actually crossed, in unwrapped degrees.
|
||||
const edge = 180 + 360 * Math.min(wPrev, wCur);
|
||||
const f = (edge - pLon) / (lon - pLon);
|
||||
const edgeLat = pLat + f * (lat - pLat);
|
||||
cur.push([edgeLat, east ? 180 : -180]);
|
||||
out.push(cur);
|
||||
cur = [[edgeLat, east ? -180 : 180]];
|
||||
}
|
||||
}
|
||||
cur.push([lat, norm(lon)]);
|
||||
}
|
||||
if (cur.length > 1) out.push(cur);
|
||||
else if (cur.length === 1 && out.length === 0) out.push(cur);
|
||||
return out;
|
||||
}
|
||||
|
||||
function toRad(d: number): number { return (d * Math.PI) / 180; }
|
||||
function toDeg(r: number): number { return (r * 180) / Math.PI; }
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ import { GetUIPref } from '../../wailsjs/go/main/App';
|
||||
// preference. The choice is persisted (localStorage + portable UI pref, so it
|
||||
// travels with the data/ folder like the language).
|
||||
export type ThemeChoice = 'auto' | 'light-warm' | 'light-cool' | 'light-sage' | 'light-nordic' | 'sahara'
|
||||
| 'dim-slate' | 'dark-warm' | 'dark-graphite' | 'dark-indigo' | 'dark-teal' | 'dark-plum' | 'high-contrast';
|
||||
| 'dim-slate' | 'dark-warm' | 'dark-graphite' | 'dark-indigo' | 'dark-teal' | 'dark-plum' | 'dxhunter' | 'dxhunter-orange' | 'high-contrast';
|
||||
|
||||
// Selectable, concrete themes (excludes 'auto') in display order: lights first,
|
||||
// then darks, with high-contrast last — it is an accessibility choice, not a
|
||||
// taste one, and listing it among the moods buries it.
|
||||
export const CONCRETE_THEMES: Exclude<ThemeChoice, 'auto'>[] = [
|
||||
'light-warm', 'light-cool', 'light-sage', 'light-nordic', 'sahara',
|
||||
'dim-slate', 'dark-warm', 'dark-graphite', 'dark-indigo', 'dark-teal', 'dark-plum',
|
||||
'dim-slate', 'dark-warm', 'dark-graphite', 'dark-indigo', 'dark-teal', 'dark-plum', 'dxhunter', 'dxhunter-orange',
|
||||
'high-contrast',
|
||||
];
|
||||
|
||||
|
||||
+155
-3
@@ -574,8 +574,8 @@
|
||||
"entity confirmed" cell would read as a button. */
|
||||
--mx-call-conf: #22c55e;
|
||||
--mx-call-work: #2c7a52;
|
||||
--mx-dx-conf: #22d3ee;
|
||||
--mx-dx-work: #1b6b7c;
|
||||
--mx-dx-conf: #a78bfa;
|
||||
--mx-dx-work: #5b4a9e;
|
||||
--mx-none: #2c2f4d;
|
||||
|
||||
--scrollbar-thumb: #383c63;
|
||||
@@ -862,6 +862,156 @@
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
/* ---- Theme 13: DXHunter — its own slate and blue -----------------------
|
||||
Ported so an operator running both side by side does not switch between two
|
||||
colour worlds every time they look up. It is Tailwind's slate scale, which
|
||||
is what DXHunter is built on: page at slate-900, panels at slate-800, rules
|
||||
at slate-700, and blue-500 for the accent — counted across its sources, not
|
||||
guessed from one panel: blue is 132 uses to violet's 25, and the violet is
|
||||
the PSK Reporter panel alone. Active tab, focus border, primary button: all
|
||||
blue-500. The status colours are DXHunter's too — emerald for good, amber
|
||||
for attention, cyan for information, red for trouble — so a green number
|
||||
means the same thing in both windows. */
|
||||
[data-theme="dxhunter"] {
|
||||
--background: #0f172a; /* slate-900 — the page */
|
||||
--foreground: #e2e8f0; /* slate-200 */
|
||||
--card: #1e293b; /* slate-800 — panels lift off the page */
|
||||
--card-foreground: #e2e8f0;
|
||||
--popover: #1e293b;
|
||||
--popover-foreground: #e2e8f0;
|
||||
--primary: #3b82f6; /* blue-500 — active tabs, focus, buttons */
|
||||
--primary-foreground: #f8fafc;
|
||||
--secondary: #273449;
|
||||
--secondary-foreground: #e2e8f0;
|
||||
--muted: #1c2941; /* toolbars / table headers */
|
||||
--muted-foreground: #94a3b8; /* slate-400 — DXHunter's muted text */
|
||||
--accent: #2c3b54; /* hover / selection tint */
|
||||
--accent-foreground: #cbd5e1;
|
||||
--destructive: #ef4444;
|
||||
--destructive-foreground: #fef2f2;
|
||||
--destructive-muted: #3a1518;
|
||||
--destructive-muted-foreground: #fca5a5;
|
||||
--border: #334155; /* slate-700 — every rule in DXHunter */
|
||||
--input: #334155;
|
||||
--ring: #60a5fa; /* blue-400 — its focus border */
|
||||
|
||||
--success: #34d399; /* emerald-400 — "online", confirmed */
|
||||
--success-foreground: #04211a;
|
||||
--success-muted: #0e3029;
|
||||
--success-muted-foreground: #6ee7b7;
|
||||
--success-border: #17564a;
|
||||
|
||||
--warning: #fbbf24; /* amber-400 */
|
||||
--warning-foreground: #211803;
|
||||
--warning-muted: #33280f;
|
||||
--warning-muted-foreground: #fcd34d;
|
||||
--warning-border: #4f3e15;
|
||||
|
||||
--caution: #facc15;
|
||||
--caution-foreground: #211e04;
|
||||
--caution-muted: #322d0e;
|
||||
--caution-muted-foreground: #fde047;
|
||||
--caution-border: #4b4315;
|
||||
|
||||
--danger: #f87171; /* red-400 — rose is barely used there */
|
||||
--danger-foreground: #250912;
|
||||
--danger-muted: #3a1621;
|
||||
--danger-muted-foreground: #fda4af;
|
||||
--danger-border: #5a2735;
|
||||
|
||||
--info: #22d3ee; /* cyan-400 — "heard near you" */
|
||||
--info-foreground: #04212a;
|
||||
--info-muted: #0c2f3b;
|
||||
--info-muted-foreground: #67e8f9;
|
||||
--info-border: #155e6e;
|
||||
|
||||
/* Blue is the primary, so the entity ramp goes VIOLET rather than reading
|
||||
as a button — and violet is where DXHunter puts its own second accent. */
|
||||
--mx-call-conf: #22c55e;
|
||||
--mx-call-work: #2c7a52;
|
||||
--mx-dx-conf: #a78bfa;
|
||||
--mx-dx-work: #5b4a9e;
|
||||
--mx-none: #334155;
|
||||
|
||||
--scrollbar-thumb: #334155; /* DXHunter's own scrollbar */
|
||||
--scrollbar-thumb-hover: #475569;
|
||||
--card-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(226, 232, 240, 0.05);
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
/* ---- Theme 14: DXHunter orange — the same slate, OpsLog's own accent --
|
||||
DXHunter's slate, kept exactly — page, panels, rules, muted text, and its
|
||||
status colours — with OpsLog's orange in place of its blue. For an operator
|
||||
who wants the two windows to sit together without OpsLog losing the accent
|
||||
it is recognised by. The entity ramp goes VIOLET here for the same reason as
|
||||
in the blue version: it must not read as the accent. */
|
||||
[data-theme="dxhunter-orange"] {
|
||||
--background: #0f172a; /* slate-900 — the page */
|
||||
--foreground: #e2e8f0; /* slate-200 */
|
||||
--card: #1e293b; /* slate-800 — panels lift off the page */
|
||||
--card-foreground: #e2e8f0;
|
||||
--popover: #1e293b;
|
||||
--popover-foreground: #e2e8f0;
|
||||
--primary: #f97316; /* orange-500 — OpsLog's own accent */
|
||||
--primary-foreground: #1c0a02;
|
||||
--secondary: #273449;
|
||||
--secondary-foreground: #e2e8f0;
|
||||
--muted: #1c2941; /* toolbars / table headers */
|
||||
--muted-foreground: #94a3b8; /* slate-400 — DXHunter's muted text */
|
||||
--accent: #2c3b54; /* hover / selection tint */
|
||||
--accent-foreground: #cbd5e1;
|
||||
--destructive: #ef4444;
|
||||
--destructive-foreground: #fef2f2;
|
||||
--destructive-muted: #3a1518;
|
||||
--destructive-muted-foreground: #fca5a5;
|
||||
--border: #334155; /* slate-700 — every rule in DXHunter */
|
||||
--input: #334155;
|
||||
--ring: #fdba74; /* orange-300 focus ring */
|
||||
|
||||
--success: #34d399; /* emerald-400 — "online", confirmed */
|
||||
--success-foreground: #04211a;
|
||||
--success-muted: #0e3029;
|
||||
--success-muted-foreground: #6ee7b7;
|
||||
--success-border: #17564a;
|
||||
|
||||
--warning: #fbbf24; /* amber-400 */
|
||||
--warning-foreground: #211803;
|
||||
--warning-muted: #33280f;
|
||||
--warning-muted-foreground: #fcd34d;
|
||||
--warning-border: #4f3e15;
|
||||
|
||||
--caution: #facc15;
|
||||
--caution-foreground: #211e04;
|
||||
--caution-muted: #322d0e;
|
||||
--caution-muted-foreground: #fde047;
|
||||
--caution-border: #4b4315;
|
||||
|
||||
--danger: #f87171; /* red-400 — rose is barely used there */
|
||||
--danger-foreground: #250912;
|
||||
--danger-muted: #3a1621;
|
||||
--danger-muted-foreground: #fda4af;
|
||||
--danger-border: #5a2735;
|
||||
|
||||
--info: #22d3ee; /* cyan-400 — "heard near you" */
|
||||
--info-foreground: #04212a;
|
||||
--info-muted: #0c2f3b;
|
||||
--info-muted-foreground: #67e8f9;
|
||||
--info-border: #155e6e;
|
||||
|
||||
/* Blue is the primary, so the entity ramp goes VIOLET rather than reading
|
||||
as a button — and violet is where DXHunter puts its own second accent. */
|
||||
--mx-call-conf: #22c55e;
|
||||
--mx-call-work: #2c7a52;
|
||||
--mx-dx-conf: #a78bfa;
|
||||
--mx-dx-work: #5b4a9e;
|
||||
--mx-none: #334155;
|
||||
|
||||
--scrollbar-thumb: #334155; /* DXHunter's own scrollbar */
|
||||
--scrollbar-thumb-hover: #475569;
|
||||
--card-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(226, 232, 240, 0.05);
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
/* ── Data-viz palette (Statistics dashboard) ────────────────────────────────
|
||||
A VALIDATED categorical palette, not hand-picked: the slot ORDER is what makes
|
||||
it colour-blind-safe (worst adjacent ΔE 24.2 light / 10.3 dark), so never
|
||||
@@ -905,7 +1055,9 @@
|
||||
[data-theme="high-contrast"],
|
||||
[data-theme="dark-indigo"],
|
||||
[data-theme="dark-teal"],
|
||||
[data-theme="dark-plum"] {
|
||||
[data-theme="dark-plum"],
|
||||
[data-theme="dxhunter"],
|
||||
[data-theme="dxhunter-orange"] {
|
||||
--chart-1: #3987e5;
|
||||
--chart-2: #199e70;
|
||||
--chart-3: #c98500;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Single source of truth for the app version shown in the UI (header + About).
|
||||
// Bump this on a release (the release script updates it alongside telemetry.go).
|
||||
export const APP_VERSION = '0.27.7';
|
||||
export const APP_VERSION = '0.27.12';
|
||||
|
||||
// Author / credits, shown in Help -> About.
|
||||
export const APP_AUTHOR = 'F4BPO';
|
||||
|
||||
Vendored
+33
@@ -15,6 +15,7 @@ import {cluster} from '../models';
|
||||
import {dxped} from '../models';
|
||||
import {extsvc} from '../models';
|
||||
import {powergenius} from '../models';
|
||||
import {pskrtgt} from '../models';
|
||||
import {pskr} from '../models';
|
||||
import {psu} from '../models';
|
||||
import {spe} from '../models';
|
||||
@@ -415,6 +416,10 @@ export function GetAudioMonitorPref():Promise<boolean>;
|
||||
|
||||
export function GetAudioSettings():Promise<main.AudioSettings>;
|
||||
|
||||
export function GetAutoCallSettings():Promise<main.AutoCallSettings>;
|
||||
|
||||
export function GetAutoCallStatus():Promise<main.AutoCallStatus>;
|
||||
|
||||
export function GetAutostartPrograms():Promise<Array<main.AutostartProgram>>;
|
||||
|
||||
export function GetAward(arg1:string,arg2:string):Promise<award.Result>;
|
||||
@@ -549,8 +554,12 @@ export function GetPGXLStatus():Promise<powergenius.Status>;
|
||||
|
||||
export function GetPOTAToken():Promise<string>;
|
||||
|
||||
export function GetPSKAnalysis():Promise<pskrtgt.Analysis>;
|
||||
|
||||
export function GetPSKReporterStatus():Promise<pskr.Status>;
|
||||
|
||||
export function GetPSKTargetSettings():Promise<main.PSKTargetSettings>;
|
||||
|
||||
export function GetPSUSettings():Promise<main.PSUSettings>;
|
||||
|
||||
export function GetPSUStatus():Promise<psu.Status>;
|
||||
@@ -617,6 +626,8 @@ export function GetUltrabeamSettings():Promise<main.UltrabeamSettings>;
|
||||
|
||||
export function GetUltrabeamStatus():Promise<main.UltrabeamStatusInfo>;
|
||||
|
||||
export function GetWatchlistContestCalls():Promise<string>;
|
||||
|
||||
export function GetWatchlistContestPattern():Promise<string>;
|
||||
|
||||
export function GetWebPublishConfig():Promise<webpub.Config>;
|
||||
@@ -635,6 +646,8 @@ export function GetWsjtFollowMode():Promise<boolean>;
|
||||
|
||||
export function GetWsjtHighlight():Promise<boolean>;
|
||||
|
||||
export function GetWsjtHighlightWorked():Promise<boolean>;
|
||||
|
||||
export function GetYaesuBandAntennas():Promise<Record<string, number>>;
|
||||
|
||||
export function GetYaesuState():Promise<cat.YaesuTXState>;
|
||||
@@ -647,6 +660,8 @@ export function HasBuiltinReferences(arg1:string):Promise<boolean>;
|
||||
|
||||
export function IcomConsolePTT(arg1:boolean):Promise<void>;
|
||||
|
||||
export function IcomRecallBand(arg1:string,arg2:number):Promise<number>;
|
||||
|
||||
export function IcomRefresh():Promise<void>;
|
||||
|
||||
export function IcomScopeData():Promise<cat.ScopeSweep>;
|
||||
@@ -977,6 +992,8 @@ export function ReportLiveActivity(arg1:number,arg2:string,arg3:string):Promise<
|
||||
|
||||
export function RescanAwards():Promise<void>;
|
||||
|
||||
export function ResetAutoCall():Promise<void>;
|
||||
|
||||
export function ResetAwardDefs():Promise<Array<award.Def>>;
|
||||
|
||||
export function ResetDatabaseToDefault():Promise<void>;
|
||||
@@ -1023,6 +1040,8 @@ export function SaveAntGeniusSettings(arg1:main.AntGeniusSettings):Promise<void>
|
||||
|
||||
export function SaveAudioSettings(arg1:main.AudioSettings):Promise<void>;
|
||||
|
||||
export function SaveAutoCallSettings(arg1:main.AutoCallSettings):Promise<void>;
|
||||
|
||||
export function SaveAutostartPrograms(arg1:Array<main.AutostartProgram>):Promise<void>;
|
||||
|
||||
export function SaveAwardDefs(arg1:Array<award.Def>):Promise<void>;
|
||||
@@ -1073,6 +1092,8 @@ export function SavePGXLSettings(arg1:main.PGXLSettings):Promise<void>;
|
||||
|
||||
export function SavePOTAToken(arg1:string):Promise<void>;
|
||||
|
||||
export function SavePSKTargetSettings(arg1:main.PSKTargetSettings):Promise<void>;
|
||||
|
||||
export function SavePSUSettings(arg1:main.PSUSettings):Promise<void>;
|
||||
|
||||
export function SaveProfile(arg1:profile.Profile):Promise<profile.Profile>;
|
||||
@@ -1133,6 +1154,10 @@ export function SetActiveRotor(arg1:number):Promise<void>;
|
||||
|
||||
export function SetAlertEmailTo(arg1:string):Promise<void>;
|
||||
|
||||
export function SetAutoCall(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetAutoCallOnly(arg1:string):Promise<void>;
|
||||
|
||||
export function SetCATFrequency(arg1:number):Promise<void>;
|
||||
|
||||
export function SetCATMode(arg1:string):Promise<void>;
|
||||
@@ -1205,6 +1230,8 @@ export function SetMotorFollow(arg1:boolean,arg2:number,arg3:string):Promise<voi
|
||||
|
||||
export function SetOpsLogQSLReceived(arg1:number,arg2:boolean):Promise<void>;
|
||||
|
||||
export function SetPSKTarget(arg1:string,arg2:string,arg3:number):Promise<void>;
|
||||
|
||||
export function SetPSUOutput(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetPassphrase(arg1:string):Promise<void>;
|
||||
@@ -1261,6 +1288,8 @@ export function SetUIPref(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetUltrabeamDirection(arg1:number):Promise<void>;
|
||||
|
||||
export function SetWatchlistContestCalls(arg1:string):Promise<void>;
|
||||
|
||||
export function SetWatchlistContestPattern(arg1:string):Promise<void>;
|
||||
|
||||
export function SetWinkeyerTrace(arg1:boolean):Promise<void>;
|
||||
@@ -1271,6 +1300,8 @@ export function SetWsjtFollowMode(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetWsjtHighlight(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetWsjtHighlightWorked(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetYaesuAFGain(arg1:number):Promise<void>;
|
||||
|
||||
export function SetYaesuAGC(arg1:string):Promise<void>;
|
||||
@@ -1331,6 +1362,8 @@ export function TCIStopCW():Promise<void>;
|
||||
|
||||
export function TailLogFile(arg1:number):Promise<string>;
|
||||
|
||||
export function TakeAutoCallTarget(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function TestCloudlogUpload():Promise<string>;
|
||||
|
||||
export function TestClublogUpload():Promise<string>;
|
||||
|
||||
@@ -766,6 +766,14 @@ export function GetAudioSettings() {
|
||||
return window['go']['main']['App']['GetAudioSettings']();
|
||||
}
|
||||
|
||||
export function GetAutoCallSettings() {
|
||||
return window['go']['main']['App']['GetAutoCallSettings']();
|
||||
}
|
||||
|
||||
export function GetAutoCallStatus() {
|
||||
return window['go']['main']['App']['GetAutoCallStatus']();
|
||||
}
|
||||
|
||||
export function GetAutostartPrograms() {
|
||||
return window['go']['main']['App']['GetAutostartPrograms']();
|
||||
}
|
||||
@@ -1034,10 +1042,18 @@ export function GetPOTAToken() {
|
||||
return window['go']['main']['App']['GetPOTAToken']();
|
||||
}
|
||||
|
||||
export function GetPSKAnalysis() {
|
||||
return window['go']['main']['App']['GetPSKAnalysis']();
|
||||
}
|
||||
|
||||
export function GetPSKReporterStatus() {
|
||||
return window['go']['main']['App']['GetPSKReporterStatus']();
|
||||
}
|
||||
|
||||
export function GetPSKTargetSettings() {
|
||||
return window['go']['main']['App']['GetPSKTargetSettings']();
|
||||
}
|
||||
|
||||
export function GetPSUSettings() {
|
||||
return window['go']['main']['App']['GetPSUSettings']();
|
||||
}
|
||||
@@ -1170,6 +1186,10 @@ export function GetUltrabeamStatus() {
|
||||
return window['go']['main']['App']['GetUltrabeamStatus']();
|
||||
}
|
||||
|
||||
export function GetWatchlistContestCalls() {
|
||||
return window['go']['main']['App']['GetWatchlistContestCalls']();
|
||||
}
|
||||
|
||||
export function GetWatchlistContestPattern() {
|
||||
return window['go']['main']['App']['GetWatchlistContestPattern']();
|
||||
}
|
||||
@@ -1206,6 +1226,10 @@ export function GetWsjtHighlight() {
|
||||
return window['go']['main']['App']['GetWsjtHighlight']();
|
||||
}
|
||||
|
||||
export function GetWsjtHighlightWorked() {
|
||||
return window['go']['main']['App']['GetWsjtHighlightWorked']();
|
||||
}
|
||||
|
||||
export function GetYaesuBandAntennas() {
|
||||
return window['go']['main']['App']['GetYaesuBandAntennas']();
|
||||
}
|
||||
@@ -1230,6 +1254,10 @@ export function IcomConsolePTT(arg1) {
|
||||
return window['go']['main']['App']['IcomConsolePTT'](arg1);
|
||||
}
|
||||
|
||||
export function IcomRecallBand(arg1, arg2) {
|
||||
return window['go']['main']['App']['IcomRecallBand'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function IcomRefresh() {
|
||||
return window['go']['main']['App']['IcomRefresh']();
|
||||
}
|
||||
@@ -1890,6 +1918,10 @@ export function RescanAwards() {
|
||||
return window['go']['main']['App']['RescanAwards']();
|
||||
}
|
||||
|
||||
export function ResetAutoCall() {
|
||||
return window['go']['main']['App']['ResetAutoCall']();
|
||||
}
|
||||
|
||||
export function ResetAwardDefs() {
|
||||
return window['go']['main']['App']['ResetAwardDefs']();
|
||||
}
|
||||
@@ -1982,6 +2014,10 @@ export function SaveAudioSettings(arg1) {
|
||||
return window['go']['main']['App']['SaveAudioSettings'](arg1);
|
||||
}
|
||||
|
||||
export function SaveAutoCallSettings(arg1) {
|
||||
return window['go']['main']['App']['SaveAutoCallSettings'](arg1);
|
||||
}
|
||||
|
||||
export function SaveAutostartPrograms(arg1) {
|
||||
return window['go']['main']['App']['SaveAutostartPrograms'](arg1);
|
||||
}
|
||||
@@ -2082,6 +2118,10 @@ export function SavePOTAToken(arg1) {
|
||||
return window['go']['main']['App']['SavePOTAToken'](arg1);
|
||||
}
|
||||
|
||||
export function SavePSKTargetSettings(arg1) {
|
||||
return window['go']['main']['App']['SavePSKTargetSettings'](arg1);
|
||||
}
|
||||
|
||||
export function SavePSUSettings(arg1) {
|
||||
return window['go']['main']['App']['SavePSUSettings'](arg1);
|
||||
}
|
||||
@@ -2202,6 +2242,14 @@ export function SetAlertEmailTo(arg1) {
|
||||
return window['go']['main']['App']['SetAlertEmailTo'](arg1);
|
||||
}
|
||||
|
||||
export function SetAutoCall(arg1) {
|
||||
return window['go']['main']['App']['SetAutoCall'](arg1);
|
||||
}
|
||||
|
||||
export function SetAutoCallOnly(arg1) {
|
||||
return window['go']['main']['App']['SetAutoCallOnly'](arg1);
|
||||
}
|
||||
|
||||
export function SetCATFrequency(arg1) {
|
||||
return window['go']['main']['App']['SetCATFrequency'](arg1);
|
||||
}
|
||||
@@ -2346,6 +2394,10 @@ export function SetOpsLogQSLReceived(arg1, arg2) {
|
||||
return window['go']['main']['App']['SetOpsLogQSLReceived'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetPSKTarget(arg1, arg2, arg3) {
|
||||
return window['go']['main']['App']['SetPSKTarget'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetPSUOutput(arg1) {
|
||||
return window['go']['main']['App']['SetPSUOutput'](arg1);
|
||||
}
|
||||
@@ -2458,6 +2510,10 @@ export function SetUltrabeamDirection(arg1) {
|
||||
return window['go']['main']['App']['SetUltrabeamDirection'](arg1);
|
||||
}
|
||||
|
||||
export function SetWatchlistContestCalls(arg1) {
|
||||
return window['go']['main']['App']['SetWatchlistContestCalls'](arg1);
|
||||
}
|
||||
|
||||
export function SetWatchlistContestPattern(arg1) {
|
||||
return window['go']['main']['App']['SetWatchlistContestPattern'](arg1);
|
||||
}
|
||||
@@ -2478,6 +2534,10 @@ export function SetWsjtHighlight(arg1) {
|
||||
return window['go']['main']['App']['SetWsjtHighlight'](arg1);
|
||||
}
|
||||
|
||||
export function SetWsjtHighlightWorked(arg1) {
|
||||
return window['go']['main']['App']['SetWsjtHighlightWorked'](arg1);
|
||||
}
|
||||
|
||||
export function SetYaesuAFGain(arg1) {
|
||||
return window['go']['main']['App']['SetYaesuAFGain'](arg1);
|
||||
}
|
||||
@@ -2598,6 +2658,10 @@ export function TailLogFile(arg1) {
|
||||
return window['go']['main']['App']['TailLogFile'](arg1);
|
||||
}
|
||||
|
||||
export function TakeAutoCallTarget(arg1, arg2, arg3) {
|
||||
return window['go']['main']['App']['TakeAutoCallTarget'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function TestCloudlogUpload() {
|
||||
return window['go']['main']['App']['TestCloudlogUpload']();
|
||||
}
|
||||
|
||||
@@ -1924,6 +1924,7 @@ export namespace main {
|
||||
preroll_seconds: number;
|
||||
ptt_method: string;
|
||||
ptt_port: string;
|
||||
ptt_data: boolean;
|
||||
format: string;
|
||||
from_gain: number;
|
||||
mic_gain: number;
|
||||
@@ -1945,6 +1946,7 @@ export namespace main {
|
||||
this.preroll_seconds = source["preroll_seconds"];
|
||||
this.ptt_method = source["ptt_method"];
|
||||
this.ptt_port = source["ptt_port"];
|
||||
this.ptt_data = source["ptt_data"];
|
||||
this.format = source["format"];
|
||||
this.from_gain = source["from_gain"];
|
||||
this.mic_gain = source["mic_gain"];
|
||||
@@ -1952,6 +1954,58 @@ export namespace main {
|
||||
this.qso_play_gain = source["qso_play_gain"];
|
||||
}
|
||||
}
|
||||
export class AutoCallSettings {
|
||||
enabled: boolean;
|
||||
only: string;
|
||||
attempts: number;
|
||||
watched_attempts: number;
|
||||
misses: number;
|
||||
max_rounds: number;
|
||||
rest_min: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new AutoCallSettings(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.enabled = source["enabled"];
|
||||
this.only = source["only"];
|
||||
this.attempts = source["attempts"];
|
||||
this.watched_attempts = source["watched_attempts"];
|
||||
this.misses = source["misses"];
|
||||
this.max_rounds = source["max_rounds"];
|
||||
this.rest_min = source["rest_min"];
|
||||
}
|
||||
}
|
||||
export class AutoCallStatus {
|
||||
enabled: boolean;
|
||||
only: string;
|
||||
target: string;
|
||||
calls: number;
|
||||
max: number;
|
||||
misses: number;
|
||||
max_miss: number;
|
||||
stopped: boolean;
|
||||
reason: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new AutoCallStatus(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.enabled = source["enabled"];
|
||||
this.only = source["only"];
|
||||
this.target = source["target"];
|
||||
this.calls = source["calls"];
|
||||
this.max = source["max"];
|
||||
this.misses = source["misses"];
|
||||
this.max_miss = source["max_miss"];
|
||||
this.stopped = source["stopped"];
|
||||
this.reason = source["reason"];
|
||||
}
|
||||
}
|
||||
export class AutostartLaunchResult {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -3315,6 +3369,20 @@ export namespace main {
|
||||
}
|
||||
}
|
||||
|
||||
export class PSKTargetSettings {
|
||||
enabled: boolean;
|
||||
scope: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new PSKTargetSettings(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.enabled = source["enabled"];
|
||||
this.scope = source["scope"];
|
||||
}
|
||||
}
|
||||
export class PSUSettings {
|
||||
enabled: boolean;
|
||||
com_port: string;
|
||||
@@ -4930,6 +4998,132 @@ export namespace pskr {
|
||||
|
||||
}
|
||||
|
||||
export namespace pskrtgt {
|
||||
|
||||
export class Bin {
|
||||
offset_hz: number;
|
||||
count: number;
|
||||
avg_snr: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Bin(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.offset_hz = source["offset_hz"];
|
||||
this.count = source["count"];
|
||||
this.avg_snr = source["avg_snr"];
|
||||
}
|
||||
}
|
||||
export class Entry {
|
||||
call: string;
|
||||
grid: string;
|
||||
snr: number;
|
||||
offset_hz: number;
|
||||
age_sec: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Entry(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.call = source["call"];
|
||||
this.grid = source["grid"];
|
||||
this.snr = source["snr"];
|
||||
this.offset_hz = source["offset_hz"];
|
||||
this.age_sec = source["age_sec"];
|
||||
}
|
||||
}
|
||||
export class Analysis {
|
||||
target: string;
|
||||
mode?: string;
|
||||
enabled: boolean;
|
||||
online: boolean;
|
||||
spots: number;
|
||||
he_me: boolean;
|
||||
he_me_seconds: number;
|
||||
he_me_snr: number;
|
||||
he_me_offset_hz: number;
|
||||
target_uploads: boolean;
|
||||
target_grid?: string;
|
||||
near_him_count: number;
|
||||
near_him_top: Entry[];
|
||||
from_my_area_count: number;
|
||||
from_my_area_top: Entry[];
|
||||
path_open: boolean;
|
||||
heard_by_count: number;
|
||||
heard_near_me: number;
|
||||
heard_near_me_top: Entry[];
|
||||
decoded_by_count: number;
|
||||
decoded_by_top: Entry[];
|
||||
decoded_by_calls: string[];
|
||||
pileup_count: number;
|
||||
dial_hz: number;
|
||||
ceiling_hz: number;
|
||||
decodes_in_window: number;
|
||||
bins: Bin[];
|
||||
suggested_offset: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Analysis(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.target = source["target"];
|
||||
this.mode = source["mode"];
|
||||
this.enabled = source["enabled"];
|
||||
this.online = source["online"];
|
||||
this.spots = source["spots"];
|
||||
this.he_me = source["he_me"];
|
||||
this.he_me_seconds = source["he_me_seconds"];
|
||||
this.he_me_snr = source["he_me_snr"];
|
||||
this.he_me_offset_hz = source["he_me_offset_hz"];
|
||||
this.target_uploads = source["target_uploads"];
|
||||
this.target_grid = source["target_grid"];
|
||||
this.near_him_count = source["near_him_count"];
|
||||
this.near_him_top = this.convertValues(source["near_him_top"], Entry);
|
||||
this.from_my_area_count = source["from_my_area_count"];
|
||||
this.from_my_area_top = this.convertValues(source["from_my_area_top"], Entry);
|
||||
this.path_open = source["path_open"];
|
||||
this.heard_by_count = source["heard_by_count"];
|
||||
this.heard_near_me = source["heard_near_me"];
|
||||
this.heard_near_me_top = this.convertValues(source["heard_near_me_top"], Entry);
|
||||
this.decoded_by_count = source["decoded_by_count"];
|
||||
this.decoded_by_top = this.convertValues(source["decoded_by_top"], Entry);
|
||||
this.decoded_by_calls = source["decoded_by_calls"];
|
||||
this.pileup_count = source["pileup_count"];
|
||||
this.dial_hz = source["dial_hz"];
|
||||
this.ceiling_hz = source["ceiling_hz"];
|
||||
this.decodes_in_window = source["decodes_in_window"];
|
||||
this.bins = this.convertValues(source["bins"], Bin);
|
||||
this.suggested_offset = source["suggested_offset"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export namespace psu {
|
||||
|
||||
export class Status {
|
||||
|
||||
@@ -0,0 +1,770 @@
|
||||
// Package autocall answers FT8/FT4 decodes without the operator clicking them.
|
||||
//
|
||||
// THIS KEYS THE TRANSMITTER ON ITS OWN, which is why the decision lives here,
|
||||
// in one place, as a function of state that can be read, argued with and
|
||||
// tested — rather than spread through a panel that only runs while its tab is
|
||||
// open. Everything below is written as a series of refusals: a call goes out
|
||||
// only when nothing says it should not.
|
||||
//
|
||||
// ── What it is for ────────────────────────────────────────────────────────
|
||||
// On a busy band the operator cannot read twenty decodes, judge each against
|
||||
// the log and click the right one inside a fifteen-second slot. This does that
|
||||
// part: it ranks what is on the air by what the log still needs, calls the best
|
||||
// one, and — the harder half — knows when to STOP calling it.
|
||||
//
|
||||
// ── The ladder ────────────────────────────────────────────────────────────
|
||||
// A watched callsign outranks the same need from anybody else, at every level:
|
||||
//
|
||||
// WL new DXCC > new DXCC > WL new band > new band > WL new mode > new mode
|
||||
// > WL new slot > new slot > watched with nothing needed
|
||||
//
|
||||
// Watching a callsign is the operator saying "this one matters more than the
|
||||
// rule", so it lifts a station by one rung rather than jumping the whole
|
||||
// ladder: a watched new-slot must not outrank a new entity that will not come
|
||||
// back.
|
||||
//
|
||||
// ── Why it stops ──────────────────────────────────────────────────────────
|
||||
// The failure that matters is not calling the wrong station, it is calling one
|
||||
// station for ever. Four independent brakes, any of which releases the target:
|
||||
//
|
||||
// - attempts: 7 calls, or 15 for a watched callsign
|
||||
// - misses: 3 periods IN WHICH IT TRANSMITS with no decode of it
|
||||
// - the clock: a target held longer than MaxHold is dropped whatever the
|
||||
// counters say, because a counter that never advances never trips
|
||||
// - rounds: a callsign released this way is rested, and after MaxRounds
|
||||
// series it is parked for the session
|
||||
//
|
||||
// A released station is not banned. It can be picked again once rested, but
|
||||
// only while nothing of HIGHER rank is callable — which is what keeps "seven
|
||||
// calls, then straight back to the same station" from being fifty calls.
|
||||
//
|
||||
// ── Who is callable ───────────────────────────────────────────────────────
|
||||
// A station in the middle of an exchange with somebody else is never targeted.
|
||||
// It cannot answer, and WSJT-X and JTDX ignore a reply to it anyway; only the
|
||||
// station calling CQ, calling US, or sending its last frame is worth a slot.
|
||||
package autocall
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// Need is what the log still wants from a station, worst to best.
|
||||
type Need int
|
||||
|
||||
const (
|
||||
NeedNone Need = iota
|
||||
NeedSlot // entity worked on this band and in this mode, never together
|
||||
NeedMode // entity never worked in this mode
|
||||
NeedBand // entity never worked on this band
|
||||
NeedDXCC // entity never worked at all
|
||||
)
|
||||
|
||||
func (n Need) String() string {
|
||||
switch n {
|
||||
case NeedDXCC:
|
||||
return "DXCC"
|
||||
case NeedBand:
|
||||
return "band"
|
||||
case NeedMode:
|
||||
return "mode"
|
||||
case NeedSlot:
|
||||
return "slot"
|
||||
}
|
||||
return "-"
|
||||
}
|
||||
|
||||
// Decode is one line from the decoder, carrying both what the decision needs
|
||||
// and what a reply has to send back untouched.
|
||||
type Decode struct {
|
||||
Call string
|
||||
Band string
|
||||
Mode string
|
||||
Msg string
|
||||
SNR int
|
||||
At time.Time
|
||||
TRPeriod int // slot length in seconds; 0 means "work it out from the mode"
|
||||
Instance string
|
||||
CQ bool
|
||||
|
||||
// Replay of the decoder's own line. WSJT-X matches a Reply against its
|
||||
// decode list field for field, so these are passed through unread.
|
||||
Ms uint32
|
||||
DT float64
|
||||
AudioHz int64
|
||||
ModeRaw string
|
||||
MsgRaw string
|
||||
LowConf bool
|
||||
|
||||
// IsNew is false for a decode the sender replayed from its history. Shown
|
||||
// in the panel, never answered: the station may have gone hours ago.
|
||||
IsNew bool
|
||||
}
|
||||
|
||||
// Candidate is a decode with the log's verdict on it attached.
|
||||
type Candidate struct {
|
||||
Decode
|
||||
Need Need
|
||||
Watched bool
|
||||
// Worked is "already in the log on this band AND mode". Nothing is gained
|
||||
// by calling it again — and while chasing confirmations it is the trap that
|
||||
// makes the same station be called all evening, because an unconfirmed QSO
|
||||
// leaves the entity flagged as still wanted.
|
||||
Worked bool
|
||||
}
|
||||
|
||||
// TXState is what the decoding application says it is doing.
|
||||
type TXState struct {
|
||||
Transmitting bool
|
||||
Enabled bool // its own Enable Tx: nothing we send transmits while false
|
||||
DXCall string
|
||||
Msg string
|
||||
Instance string
|
||||
}
|
||||
|
||||
// Settings are the operator's.
|
||||
type Settings struct {
|
||||
Enabled bool
|
||||
// Only is the "chase these callsigns" field: one or more, separated by
|
||||
// spaces or commas. Filled, nothing else is ever called — the ladder still
|
||||
// orders the ones listed, so "VP6D 3Y0J" calls whichever of the two is on
|
||||
// the air and takes the better catch when both are. Wildcards are the watch
|
||||
// list's job; this is a hunt list for right now.
|
||||
//
|
||||
// The brakes are unchanged, and hitting one stops the feature rather than
|
||||
// moving on to somebody else — an explicit request deserves an explicit
|
||||
// restart.
|
||||
Only string
|
||||
// Attempts before a target is released, and the larger allowance for a
|
||||
// watched callsign.
|
||||
Attempts int
|
||||
WatchedAttempts int
|
||||
// Misses is how many of the station's OWN transmit periods may pass with no
|
||||
// decode of it before it is given up on.
|
||||
Misses int
|
||||
// Rest is how long a released callsign waits before it can be picked again,
|
||||
// and MaxRounds how many such series it gets before being parked for the
|
||||
// session.
|
||||
Rest time.Duration
|
||||
MaxRounds int
|
||||
// MaxHold is the wall-clock backstop on one target.
|
||||
MaxHold time.Duration
|
||||
}
|
||||
|
||||
// Defaults are what the operator gets before touching anything.
|
||||
func Defaults() Settings {
|
||||
return Settings{
|
||||
Attempts: 7, WatchedAttempts: 15, Misses: 3,
|
||||
Rest: 2 * time.Minute, MaxRounds: 3, MaxHold: 4 * time.Minute,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Settings) withDefaults() Settings {
|
||||
d := Defaults()
|
||||
if s.Attempts <= 0 {
|
||||
s.Attempts = d.Attempts
|
||||
}
|
||||
if s.WatchedAttempts <= 0 {
|
||||
s.WatchedAttempts = d.WatchedAttempts
|
||||
}
|
||||
if s.Misses <= 0 {
|
||||
s.Misses = d.Misses
|
||||
}
|
||||
if s.Rest <= 0 {
|
||||
s.Rest = d.Rest
|
||||
}
|
||||
if s.MaxRounds <= 0 {
|
||||
s.MaxRounds = d.MaxRounds
|
||||
}
|
||||
if s.MaxHold <= 0 {
|
||||
s.MaxHold = d.MaxHold
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// ActionKind is what the caller must do about the decision.
|
||||
type ActionKind int
|
||||
|
||||
const (
|
||||
DoNothing ActionKind = iota
|
||||
DoReply // answer this decode
|
||||
DoHalt // stop the decoder transmitting
|
||||
)
|
||||
|
||||
// Action is the decision, with the reason in plain words. The reason is not
|
||||
// decoration: it is the only way an operator can tell an auto-call that is
|
||||
// working from one that is stuck, and it goes to the log line by line.
|
||||
type Action struct {
|
||||
Kind ActionKind
|
||||
Decode Decode
|
||||
Reason string
|
||||
}
|
||||
|
||||
// Engine holds the state between periods. Not safe for concurrent use; the
|
||||
// caller owns the serialisation, which in OpsLog is the UDP event loop.
|
||||
type Engine struct {
|
||||
set Settings
|
||||
|
||||
// target is the station being called, held as the decode last seen of it so
|
||||
// a reply always carries a fresh timestamp.
|
||||
target *Candidate
|
||||
// targetInst is the receiver the target was picked on, so the brakes are
|
||||
// counted against ITS periods and its transmissions.
|
||||
targetInst string
|
||||
// heldSince is when this station BECAME the target, and is never refreshed
|
||||
// while it stays one. It was, and that quietly disabled the clock backstop:
|
||||
// a station decoded every period for ever kept pushing its own deadline
|
||||
// forward, which is exactly the case the backstop exists for.
|
||||
heldSince time.Time
|
||||
attempts int
|
||||
misses int
|
||||
lastMiss string // period already counted, so one period counts once
|
||||
txSlot int // which of the two slots the target transmits in; -1 unknown
|
||||
stopped bool // an explicit "Only" target gave up: needs a restart
|
||||
stoppedOn string
|
||||
|
||||
// rested says when a released callsign may be considered again, and rounds
|
||||
// how many series it has already had this session.
|
||||
rested map[string]time.Time
|
||||
rounds map[string]int
|
||||
// done is every station the exchange was completed with this session.
|
||||
//
|
||||
// The log is the authority on what is worked, and it is SLOW: the QSO is
|
||||
// logged when the operator (or the watcher) gets to it, several periods
|
||||
// later. In between, the station we have just worked is still flagged as a
|
||||
// new entity and is still on the air sending its 73 — which read as a
|
||||
// perfectly good station to call, and the engine called it straight back.
|
||||
done map[string]bool
|
||||
}
|
||||
|
||||
func New(s Settings) *Engine {
|
||||
return &Engine{set: s.withDefaults(), txSlot: -1,
|
||||
rested: map[string]time.Time{}, rounds: map[string]int{}, done: map[string]bool{}}
|
||||
}
|
||||
|
||||
// SetSettings swaps the settings in place. A target already being called is
|
||||
// kept: the operator adjusting a limit is not asking to abandon the QSO in
|
||||
// flight, and switching the feature off is a separate call.
|
||||
func (e *Engine) SetSettings(s Settings) { e.set = s.withDefaults() }
|
||||
|
||||
// Target is the callsign being called, for the panel. Empty when idle.
|
||||
func (e *Engine) Target() string {
|
||||
if e.target == nil {
|
||||
return ""
|
||||
}
|
||||
return e.target.Call
|
||||
}
|
||||
|
||||
// Status is what the panel shows: who, how far into the brakes, and whether
|
||||
// the engine has given up and is waiting for the operator.
|
||||
type Status struct {
|
||||
Target string `json:"target"`
|
||||
Attempts int `json:"attempts"`
|
||||
Max int `json:"max"`
|
||||
Misses int `json:"misses"`
|
||||
MaxMiss int `json:"max_miss"`
|
||||
Stopped bool `json:"stopped"`
|
||||
StoppedOn string `json:"stopped_on"`
|
||||
}
|
||||
|
||||
func (e *Engine) Status() Status {
|
||||
st := Status{Misses: e.misses, MaxMiss: e.set.Misses, Stopped: e.stopped, StoppedOn: e.stoppedOn}
|
||||
if e.target != nil {
|
||||
st.Target = e.target.Call
|
||||
st.Attempts = e.attempts
|
||||
st.Max = e.maxAttempts(*e.target)
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
// Reset clears everything except the settings — the operator's Halt, a profile
|
||||
// change, or switching the feature off and on again.
|
||||
func (e *Engine) Reset() {
|
||||
e.target, e.attempts, e.misses, e.txSlot = nil, 0, 0, -1
|
||||
e.targetInst = ""
|
||||
e.lastMiss, e.stopped, e.stoppedOn = "", false, ""
|
||||
e.rested, e.rounds = map[string]time.Time{}, map[string]int{}
|
||||
e.done = map[string]bool{}
|
||||
}
|
||||
|
||||
// Take hands the operator's own click to the engine: the station they picked
|
||||
// becomes the target, with the counters restarted. Everything after it — the
|
||||
// brakes, the hand-off at the end of the QSO — then applies as usual.
|
||||
func (e *Engine) Take(c Candidate) {
|
||||
e.target, e.targetInst = &c, c.Instance
|
||||
e.heldSince = c.At
|
||||
e.attempts, e.misses, e.txSlot, e.lastMiss = 0, 0, -1, ""
|
||||
e.stopped, e.stoppedOn = false, ""
|
||||
}
|
||||
|
||||
// maxAttempts is the allowance for one target: larger for a watched callsign,
|
||||
// because that is the operator saying this one is worth the extra slots.
|
||||
func (e *Engine) maxAttempts(c Candidate) int {
|
||||
if c.Watched {
|
||||
return e.set.WatchedAttempts
|
||||
}
|
||||
return e.set.Attempts
|
||||
}
|
||||
|
||||
// rank is the ladder, as one number. Watched lifts a station by one rung, and
|
||||
// a watched station with nothing needed sits at the bottom rather than being
|
||||
// ineligible: the operator asked for that callsign.
|
||||
//
|
||||
// 9 WL DXCC 8 DXCC 7 WL band 6 band
|
||||
// 5 WL mode 4 mode 3 WL slot 2 slot 1 watched, nothing needed
|
||||
// 0 nothing to call for
|
||||
func rank(c Candidate) int {
|
||||
if c.Need == NeedNone {
|
||||
if c.Watched {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
r := int(c.Need) * 2 // slot 2, mode 4, band 6, DXCC 8
|
||||
if c.Watched {
|
||||
r++
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// onlyList splits the chase field. Space or comma, either way: an operator
|
||||
// typing a list types it the way they think of it, and a field that silently
|
||||
// ignores half of what was entered is worse than one that refuses it.
|
||||
func onlyList(field string) []string {
|
||||
out := []string{}
|
||||
for _, tok := range strings.FieldsFunc(strings.ToUpper(field), func(r rune) bool {
|
||||
return r == ',' || r == ';' || unicode.IsSpace(r)
|
||||
}) {
|
||||
if tok = strings.TrimSpace(tok); tok != "" {
|
||||
out = append(out, tok)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func inList(list []string, call string) bool {
|
||||
for _, c := range list {
|
||||
if c == call {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var gridRe = regexp.MustCompile(`^[A-R]{2}[0-9]{2}([A-X]{2})?$`)
|
||||
|
||||
// isGrid is the grid test with the exchange tokens taken out first.
|
||||
//
|
||||
// "RR73" IS a valid Maidenhead square by the pattern — two letters in A-R, two
|
||||
// digits — and it is also the second most common thing to find in that position
|
||||
// of a message. Counting it as a fresh call spent an attempt on every QSO the
|
||||
// engine actually completed, which is precisely backwards: a station that
|
||||
// answers should cost nothing.
|
||||
func isGrid(tok string) bool {
|
||||
switch tok {
|
||||
case "RR73", "RRR", "73", "RR", "R":
|
||||
return false
|
||||
}
|
||||
return gridRe.MatchString(tok)
|
||||
}
|
||||
|
||||
// callable reports whether a station can be answered RIGHT NOW.
|
||||
//
|
||||
// A station in mid-exchange is committed to somebody else: it will not answer,
|
||||
// and WSJT-X and JTDX refuse to act on a reply to it at all — so calling it is
|
||||
// at best a wasted slot and at worst the operator watching an auto-call that
|
||||
// appears to do nothing. CQ, a message addressed to us, and the final frame of
|
||||
// somebody else's QSO (the station is free from the next period) are the three
|
||||
// states worth a call.
|
||||
func callable(c Candidate, myCall string) bool {
|
||||
if c.CQ {
|
||||
return true
|
||||
}
|
||||
toks := strings.Fields(strings.ToUpper(strings.TrimSpace(c.Msg)))
|
||||
if len(toks) == 0 {
|
||||
return false // nothing to read: assume it is busy rather than call blind
|
||||
}
|
||||
if myCall != "" && toks[0] == strings.ToUpper(myCall) {
|
||||
return true // it is calling us
|
||||
}
|
||||
switch toks[len(toks)-1] {
|
||||
case "RR73", "RRR", "73":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// callingUs is the stronger half of callable: the station has our callsign in
|
||||
// its message, so it has heard us and is waiting for an answer.
|
||||
func callingUs(c Candidate, myCall string) bool {
|
||||
if myCall == "" || c.CQ {
|
||||
return false
|
||||
}
|
||||
toks := strings.Fields(strings.ToUpper(strings.TrimSpace(c.Msg)))
|
||||
return len(toks) > 0 && toks[0] == strings.ToUpper(myCall)
|
||||
}
|
||||
|
||||
// finished reports that the exchange with this station is over: it sent us the
|
||||
// last frame. Read from ITS message rather than from our own transmit state,
|
||||
// which says only what we did.
|
||||
func finished(decodes []Candidate, call, myCall string) bool {
|
||||
if myCall == "" {
|
||||
return false
|
||||
}
|
||||
me := strings.ToUpper(myCall)
|
||||
call = strings.ToUpper(call)
|
||||
for _, c := range decodes {
|
||||
if strings.ToUpper(c.Call) != call {
|
||||
continue
|
||||
}
|
||||
toks := strings.Fields(strings.ToUpper(strings.TrimSpace(c.Msg)))
|
||||
if len(toks) < 2 || toks[0] != me {
|
||||
continue
|
||||
}
|
||||
switch toks[len(toks)-1] {
|
||||
case "RR73", "RRR", "73":
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// slotOf is which of the two alternating slots a moment falls in. FT8 stations
|
||||
// transmit in one and listen in the other, so a station is legitimately absent
|
||||
// half the time — counting that as a miss dropped a perfectly workable station
|
||||
// after two unlucky periods.
|
||||
func slotOf(at time.Time, trSec int) int {
|
||||
if trSec <= 0 {
|
||||
trSec = 15
|
||||
}
|
||||
return int((at.UTC().Unix() / int64(trSec)) % 2)
|
||||
}
|
||||
|
||||
// Period is one slot's worth of decodes, with the state of the world around it.
|
||||
type Period struct {
|
||||
// Instance is the receiver this period came from. With two decoders running
|
||||
// — the split view, two bands — their slots are separate: a station absent
|
||||
// from the OTHER receiver's period says nothing about the one being called
|
||||
// on this one, and counting it as a miss dropped a target that was being
|
||||
// decoded perfectly well.
|
||||
Instance string
|
||||
// Key identifies the period, so a handler that runs twice for one slot
|
||||
// cannot count the same miss twice.
|
||||
Key string
|
||||
At time.Time
|
||||
TRPeriod int
|
||||
Decodes []Candidate
|
||||
TX TXState
|
||||
MyCall string
|
||||
}
|
||||
|
||||
// OnPeriod is the decision, taken once per receive period.
|
||||
func (e *Engine) OnPeriod(p Period) Action {
|
||||
if !e.set.Enabled {
|
||||
return Action{}
|
||||
}
|
||||
// ONE station at a time, on the receiver it is being called on.
|
||||
//
|
||||
// This is the guarantee with two decoders running: while a target is held,
|
||||
// a period from any OTHER receiver is not even looked at. It cannot start a
|
||||
// second QSO over the top of the one in progress, however much better the
|
||||
// station it hears is, and its periods count no missed periods against a
|
||||
// target that was never on its band.
|
||||
if e.target != nil && e.targetInst != "" && p.Instance != "" && p.Instance != e.targetInst {
|
||||
return Action{}
|
||||
}
|
||||
|
||||
// ── An existing target ────────────────────────────────────────────────
|
||||
if e.target != nil {
|
||||
t := *e.target
|
||||
tc := strings.ToUpper(t.Call)
|
||||
|
||||
// The exchange is over — either the station sent us its last frame, or
|
||||
// the log now holds it. Hand straight on to the next station in the same
|
||||
// period rather than waiting for the next one: the slot is the resource.
|
||||
if finished(p.Decodes, tc, p.MyCall) || workedNow(p.Decodes, tc) {
|
||||
e.release(tc, false)
|
||||
// Straight on to the next station, list or no list: pick() is what
|
||||
// knows the chase list, and with one on it the answer is simply the
|
||||
// next callsign there — a list of two DXpeditions must not stop
|
||||
// after the first.
|
||||
return e.pick(p, fmt.Sprintf("QSO with %s finished", tc))
|
||||
}
|
||||
|
||||
// The clock backstop. Every counter below depends on decodes arriving in
|
||||
// a particular shape; this one does not depend on anything.
|
||||
if !e.heldSince.IsZero() && p.At.Sub(e.heldSince) > e.set.MaxHold {
|
||||
e.giveUp(tc, t)
|
||||
return Action{Kind: DoHalt, Reason: fmt.Sprintf("%s held for %s with nothing to show for it", tc, e.set.MaxHold)}
|
||||
}
|
||||
|
||||
if seen := bestOf(p.Decodes, tc); seen != nil {
|
||||
// The decode is refreshed so a reply carries a current timestamp; the
|
||||
// hold clock is NOT — see heldSince.
|
||||
e.target = seen
|
||||
e.misses, e.lastMiss = 0, ""
|
||||
e.txSlot = slotOf(p.At, periodSecs(p, *seen))
|
||||
// In QSO: the decoder is sequencing the exchange on its own and the
|
||||
// attempt counter has done its job. Interrupting it with another
|
||||
// reply is how two transmissions land in one slot.
|
||||
if callingUs(*seen, p.MyCall) {
|
||||
e.attempts = 0
|
||||
}
|
||||
return Action{}
|
||||
}
|
||||
|
||||
// Absent. Only its OWN transmit periods count against it.
|
||||
if e.txSlot >= 0 && slotOf(p.At, periodSecs(p, t)) != e.txSlot {
|
||||
return Action{}
|
||||
}
|
||||
if e.lastMiss == p.Key {
|
||||
return Action{}
|
||||
}
|
||||
e.lastMiss = p.Key
|
||||
e.misses++
|
||||
if e.misses >= e.set.Misses {
|
||||
e.giveUp(tc, t)
|
||||
return Action{Kind: DoHalt, Reason: fmt.Sprintf("%s not decoded for %d of its own periods", tc, e.set.Misses)}
|
||||
}
|
||||
return Action{}
|
||||
}
|
||||
|
||||
// ── No target ─────────────────────────────────────────────────────────
|
||||
if e.stopped {
|
||||
return Action{} // an explicit target gave up; the operator restarts it
|
||||
}
|
||||
// Never start a call over a transmission in progress: the reply would land
|
||||
// in a slot the decoder is already using.
|
||||
if p.TX.Transmitting {
|
||||
return Action{}
|
||||
}
|
||||
return e.pick(p, "")
|
||||
}
|
||||
|
||||
// pick chooses the best station on the air and answers it.
|
||||
func (e *Engine) pick(p Period, why string) Action {
|
||||
only := onlyList(e.set.Only)
|
||||
var best *Candidate
|
||||
var bestRank int
|
||||
// bestRank of everything eligible, rested or not: a station that is resting
|
||||
// may only be re-picked while nothing better is on the air, and that is the
|
||||
// comparison.
|
||||
topRank := 0
|
||||
for i := range p.Decodes {
|
||||
c := p.Decodes[i]
|
||||
if !e.eligible(c, p, only) {
|
||||
continue
|
||||
}
|
||||
if r := rank(c); r > topRank {
|
||||
topRank = r
|
||||
}
|
||||
}
|
||||
for i := range p.Decodes {
|
||||
c := p.Decodes[i]
|
||||
if !e.eligible(c, p, only) {
|
||||
continue
|
||||
}
|
||||
r := rank(c)
|
||||
if resting, ok := e.rested[strings.ToUpper(c.Call)]; ok && p.At.Before(resting) {
|
||||
// Rested: allowed back only when it is the best thing there is.
|
||||
// Anything of higher rank takes the slot instead.
|
||||
if r < topRank {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if best == nil || better(c, r, *best, bestRank, p.MyCall) {
|
||||
cc := c
|
||||
best, bestRank = &cc, r
|
||||
}
|
||||
}
|
||||
if best == nil {
|
||||
if why != "" {
|
||||
return Action{Kind: DoNothing, Reason: why + " — nothing else worth calling"}
|
||||
}
|
||||
return Action{}
|
||||
}
|
||||
e.target, e.heldSince, e.targetInst = best, p.At, best.Instance
|
||||
e.attempts, e.misses, e.txSlot, e.lastMiss = 0, 0, -1, ""
|
||||
reason := fmt.Sprintf("calling %s (%s%s)", best.Call, watchedTag(*best), best.Need)
|
||||
if why != "" {
|
||||
reason = why + " — " + reason
|
||||
}
|
||||
return Action{Kind: DoReply, Decode: best.Decode, Reason: reason}
|
||||
}
|
||||
|
||||
func watchedTag(c Candidate) string {
|
||||
if c.Watched {
|
||||
return "watched "
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// eligible is every refusal that applies before a station is even ranked.
|
||||
func (e *Engine) eligible(c Candidate, p Period, only []string) bool {
|
||||
call := strings.ToUpper(strings.TrimSpace(c.Call))
|
||||
if call == "" || call == strings.ToUpper(p.MyCall) {
|
||||
return false
|
||||
}
|
||||
if !c.IsNew {
|
||||
return false // replayed history: the station may be hours gone
|
||||
}
|
||||
if len(only) > 0 {
|
||||
// The named stations, and each only until the QSO with it is made: an
|
||||
// explicit request is not a standing order to work the same station all
|
||||
// evening. The others on the list stay callable.
|
||||
return inList(only, call) && !e.done[call] && !c.Worked
|
||||
}
|
||||
if c.Worked || e.done[call] {
|
||||
return false
|
||||
}
|
||||
if rank(c) == 0 {
|
||||
return false
|
||||
}
|
||||
if e.rounds[call] >= e.set.MaxRounds {
|
||||
return false // parked for the session
|
||||
}
|
||||
// Mid-exchange with somebody else: it cannot answer us — see callable.
|
||||
return callable(c, p.MyCall)
|
||||
}
|
||||
|
||||
// better orders two eligible stations: the need first, then the one already
|
||||
// calling us, then a CQ over a station about to be free, then the strongest.
|
||||
func better(a Candidate, ra int, b Candidate, rb int, myCall string) bool {
|
||||
if ra != rb {
|
||||
return ra > rb
|
||||
}
|
||||
if x, y := callingUs(a, myCall), callingUs(b, myCall); x != y {
|
||||
return x
|
||||
}
|
||||
if a.CQ != b.CQ {
|
||||
return a.CQ
|
||||
}
|
||||
return a.SNR > b.SNR
|
||||
}
|
||||
|
||||
// release clears the target. gaveUp marks it as a series that ended in a brake
|
||||
// rather than in a QSO.
|
||||
func (e *Engine) release(call string, gaveUp bool) {
|
||||
e.target, e.attempts, e.misses, e.txSlot, e.lastMiss = nil, 0, 0, -1, ""
|
||||
e.targetInst = ""
|
||||
if !gaveUp {
|
||||
// A finished QSO is not a failed series — the callsign keeps its rounds —
|
||||
// but it IS finished: nothing more is wanted from this station today,
|
||||
// whatever the log still says while it catches up.
|
||||
delete(e.rounds, call)
|
||||
e.done[call] = true
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Engine) giveUp(call string, t Candidate) {
|
||||
e.release(call, true)
|
||||
e.rounds[call]++
|
||||
e.rested[call] = time.Now().Add(e.set.Rest)
|
||||
// An explicit "call this station" that runs out of attempts stops the
|
||||
// feature instead of moving on. There is nothing else it was asked to do.
|
||||
if strings.TrimSpace(e.set.Only) != "" {
|
||||
e.stopped, e.stoppedOn = true, call
|
||||
}
|
||||
}
|
||||
|
||||
// NoteTX counts what actually goes on the air, and is the ONLY place attempts
|
||||
// are counted or capped.
|
||||
//
|
||||
// Counted here rather than where the reply is sent, because those are different
|
||||
// things: a reply may be refused by the decoder, and the decoder transmits
|
||||
// several times per QSO on its own. Capped here too — the period handler used
|
||||
// to cap as well, and a target could sit at twenty-four calls while none of its
|
||||
// conditions were met. One place that counts and stops cannot overshoot.
|
||||
//
|
||||
// A FRESH call only: the third token of an FT8 call is a grid, where the rest
|
||||
// of the exchange carries a report, R-report or 73. Without that, the answer to
|
||||
// "how many times have we called this station" counted the whole QSO.
|
||||
func (e *Engine) NoteTX(tx TXState) Action {
|
||||
if !e.set.Enabled || e.target == nil || !tx.Transmitting {
|
||||
return Action{}
|
||||
}
|
||||
// The OTHER decoder transmitting is not us calling this station: in a split
|
||||
// view both are on the air, and counting both spent the seven calls in half
|
||||
// the time — on a target the other receiver had never heard of.
|
||||
if e.targetInst != "" && tx.Instance != "" && tx.Instance != e.targetInst {
|
||||
return Action{}
|
||||
}
|
||||
t := *e.target
|
||||
tc := strings.ToUpper(t.Call)
|
||||
msg := strings.ToUpper(strings.TrimSpace(tx.Msg))
|
||||
switch {
|
||||
case msg != "":
|
||||
toks := strings.Fields(msg)
|
||||
if len(toks) < 3 || toks[0] != tc || !isGrid(toks[2]) {
|
||||
return Action{}
|
||||
}
|
||||
default:
|
||||
// JTDX reports no transmit message. The DX call is all there is, so
|
||||
// every transmit period aimed at the target counts — more generous, and
|
||||
// far better than a counter frozen at zero for ever.
|
||||
if strings.ToUpper(strings.TrimSpace(tx.DXCall)) != tc {
|
||||
return Action{}
|
||||
}
|
||||
}
|
||||
e.attempts++
|
||||
if e.attempts < e.maxAttempts(t) {
|
||||
return Action{}
|
||||
}
|
||||
max := e.maxAttempts(t)
|
||||
e.giveUp(tc, t)
|
||||
return Action{Kind: DoHalt, Reason: fmt.Sprintf("%s called %d times without an answer", tc, max)}
|
||||
}
|
||||
|
||||
// bestOf returns the most callable decode of one station in a period.
|
||||
//
|
||||
// A station running several streams at once — a DXpedition answering four
|
||||
// callers — appears several times in one period: a report to one, RR73 to
|
||||
// another, a CQ to the band. Judging it on whichever line came first reads a
|
||||
// station that is free right now as busy.
|
||||
func bestOf(decodes []Candidate, call string) *Candidate {
|
||||
var best *Candidate
|
||||
for i := range decodes {
|
||||
c := decodes[i]
|
||||
if strings.ToUpper(c.Call) != call {
|
||||
continue
|
||||
}
|
||||
if best == nil || (c.CQ && !best.CQ) || (c.CQ == best.CQ && c.SNR > best.SNR) {
|
||||
cc := c
|
||||
best = &cc
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
// workedNow reports that the log has caught up with a station mid-series — the
|
||||
// QSO was logged, by this or by another hand.
|
||||
func workedNow(decodes []Candidate, call string) bool {
|
||||
for _, c := range decodes {
|
||||
if strings.ToUpper(c.Call) == call && c.Worked {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func periodSecs(p Period, c Candidate) int {
|
||||
if c.TRPeriod > 0 {
|
||||
return c.TRPeriod
|
||||
}
|
||||
if p.TRPeriod > 0 {
|
||||
return p.TRPeriod
|
||||
}
|
||||
return 15
|
||||
}
|
||||
|
||||
// TargetInstance names the receiver the current target is being called on, and
|
||||
// the callsign. Both empty when idle.
|
||||
func (e *Engine) TargetInstance() (instance, call string) {
|
||||
if e.target == nil {
|
||||
return "", ""
|
||||
}
|
||||
return e.targetInst, e.target.Call
|
||||
}
|
||||
@@ -0,0 +1,462 @@
|
||||
package autocall
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
const me = "F4BPO"
|
||||
|
||||
// base is a slot boundary, so slot parity in the tests is the real arithmetic.
|
||||
var base = time.Date(2026, 9, 6, 12, 0, 0, 0, time.UTC)
|
||||
|
||||
func at(period int) time.Time { return base.Add(time.Duration(period) * 15 * time.Second) }
|
||||
|
||||
func cq(call string, need Need, snr int, opts ...func(*Candidate)) Candidate {
|
||||
c := Candidate{
|
||||
Decode: Decode{Call: call, Band: "20m", Mode: "FT8", SNR: snr, CQ: true,
|
||||
Msg: "CQ " + call + " JN36", TRPeriod: 15, IsNew: true},
|
||||
Need: need,
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(&c)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func watched(c *Candidate) { c.Watched = true }
|
||||
func worked(c *Candidate) { c.Worked = true }
|
||||
|
||||
// busy is a station in the middle of an exchange with somebody else.
|
||||
func busy(call string, need Need, snr int) Candidate {
|
||||
c := cq(call, need, snr)
|
||||
c.CQ = false
|
||||
c.Msg = "VP6D " + call + " JN36"
|
||||
return c
|
||||
}
|
||||
|
||||
// callsMe is a station answering us.
|
||||
func callsMe(call string, need Need, snr int) Candidate {
|
||||
c := cq(call, need, snr)
|
||||
c.CQ = false
|
||||
c.Msg = me + " " + call + " -12"
|
||||
return c
|
||||
}
|
||||
|
||||
func period(n int, decodes ...Candidate) Period {
|
||||
for i := range decodes {
|
||||
decodes[i].At = at(n)
|
||||
}
|
||||
return Period{Key: fmt.Sprintf("p%d", n), At: at(n), TRPeriod: 15, Decodes: decodes, MyCall: me}
|
||||
}
|
||||
|
||||
func on() *Engine { return New(Settings{Enabled: true}) }
|
||||
|
||||
// ── The ladder ────────────────────────────────────────────────────────────
|
||||
|
||||
func TestLadderOrder(t *testing.T) {
|
||||
// Every rung, in the order the operator asked for.
|
||||
order := []Candidate{
|
||||
cq("A", NeedDXCC, 0, watched), cq("B", NeedDXCC, 0),
|
||||
cq("C", NeedBand, 0, watched), cq("D", NeedBand, 0),
|
||||
cq("E", NeedMode, 0, watched), cq("F", NeedMode, 0),
|
||||
cq("G", NeedSlot, 0, watched), cq("H", NeedSlot, 0),
|
||||
cq("I", NeedNone, 0, watched),
|
||||
}
|
||||
for i := 1; i < len(order); i++ {
|
||||
if rank(order[i-1]) <= rank(order[i]) {
|
||||
t.Errorf("%s (%d) does not outrank %s (%d)",
|
||||
order[i-1].Call, rank(order[i-1]), order[i].Call, rank(order[i]))
|
||||
}
|
||||
}
|
||||
// A station with nothing needed and not watched is not called at all.
|
||||
if rank(cq("Z", NeedNone, 0)) != 0 {
|
||||
t.Error("a station with nothing to gain from it ranks above zero")
|
||||
}
|
||||
// And the pick agrees with the ladder, whatever order the period lists them.
|
||||
e := on()
|
||||
a := e.OnPeriod(period(0, order[7], order[3], order[0], order[5]))
|
||||
if a.Kind != DoReply || a.Decode.Call != "A" {
|
||||
t.Fatalf("picked %+v, want the watched new entity", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStrongestWinsBetweenEquals(t *testing.T) {
|
||||
e := on()
|
||||
a := e.OnPeriod(period(0, cq("WEAK", NeedBand, -20), cq("LOUD", NeedBand, -5)))
|
||||
if a.Decode.Call != "LOUD" {
|
||||
t.Errorf("picked %q, want the strongest of two equal needs", a.Decode.Call)
|
||||
}
|
||||
}
|
||||
|
||||
// ── The busy station ──────────────────────────────────────────────────────
|
||||
|
||||
func TestBusyStationIsNeverCalled(t *testing.T) {
|
||||
e := on()
|
||||
// The new entity is answering a DXpedition; the new band is calling CQ.
|
||||
a := e.OnPeriod(period(0, busy("RARE", NeedDXCC, -3), cq("DL1XX", NeedBand, -15)))
|
||||
if a.Kind != DoReply || a.Decode.Call != "DL1XX" {
|
||||
t.Fatalf("called %+v — a station in mid-QSO cannot answer and must not be called", a)
|
||||
}
|
||||
// It is not banned: the moment it calls CQ it takes the slot back, once the
|
||||
// QSO in hand is over.
|
||||
e2 := on()
|
||||
if a := e2.OnPeriod(period(0, cq("RARE", NeedDXCC, -3))); a.Decode.Call != "RARE" {
|
||||
t.Errorf("the same station calling CQ was not called: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinalFrameIsCallable(t *testing.T) {
|
||||
e := on()
|
||||
c := busy("RARE", NeedDXCC, -3)
|
||||
c.Msg = "IK2AAA RARE RR73" // one frame from being free
|
||||
if a := e.OnPeriod(period(0, c)); a.Kind != DoReply {
|
||||
t.Errorf("a station sending its last frame is free next period: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
// ── The brakes ────────────────────────────────────────────────────────────
|
||||
|
||||
func TestAttemptsCapAtSevenAndFifteen(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
opt func(*Candidate)
|
||||
want int
|
||||
}{{"plain", func(*Candidate) {}, 7}, {"watched", watched, 15}} {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5, tc.opt)))
|
||||
tx := TXState{Transmitting: true, Msg: "DX " + me + " JN36"}
|
||||
for i := 1; i < tc.want; i++ {
|
||||
if a := e.NoteTX(tx); a.Kind != DoNothing {
|
||||
t.Fatalf("%s: gave up at call %d of %d", tc.name, i, tc.want)
|
||||
}
|
||||
}
|
||||
a := e.NoteTX(tx)
|
||||
if a.Kind != DoHalt {
|
||||
t.Errorf("%s: still calling after %d attempts", tc.name, tc.want)
|
||||
}
|
||||
if e.Target() != "" {
|
||||
t.Errorf("%s: target still held after giving up", tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOnlyFreshCallsCount(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5)))
|
||||
// The rest of the exchange is not a call: without this the seven were spent
|
||||
// on one QSO in progress.
|
||||
for _, msg := range []string{"DX " + me + " -12", "DX " + me + " R-12", "DX " + me + " RR73"} {
|
||||
if a := e.NoteTX(TXState{Transmitting: true, Msg: msg}); a.Kind != DoNothing {
|
||||
t.Fatalf("%q ended the series", msg)
|
||||
}
|
||||
}
|
||||
if e.Status().Attempts != 0 {
|
||||
t.Errorf("attempts = %d after three QSO frames, want 0", e.Status().Attempts)
|
||||
}
|
||||
// A transmission aimed at somebody else counts for nothing either.
|
||||
e.NoteTX(TXState{Transmitting: true, Msg: "OTHER " + me + " JN36"})
|
||||
if e.Status().Attempts != 0 {
|
||||
t.Errorf("a call to another station was counted against the target")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMissesOnlyCountTheStationsOwnPeriods(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5))) // learns nothing yet
|
||||
e.OnPeriod(period(2, cq("DX", NeedDXCC, -5))) // seen: it transmits on even periods
|
||||
// Its listening periods say nothing about it. Ten of them must not add up
|
||||
// to a give-up.
|
||||
for _, p := range []int{3, 5, 7, 9, 11} {
|
||||
if a := e.OnPeriod(period(p)); a.Kind != DoNothing {
|
||||
t.Fatalf("gave up during the station's own listening period %d", p)
|
||||
}
|
||||
}
|
||||
if e.Status().Misses != 0 {
|
||||
t.Errorf("misses = %d over five listening periods, want 0", e.Status().Misses)
|
||||
}
|
||||
// Absent from two of its transmit periods: still holding.
|
||||
e.OnPeriod(period(4))
|
||||
e.OnPeriod(period(6))
|
||||
if e.Target() == "" {
|
||||
t.Fatal("gave up after two misses, the limit is three")
|
||||
}
|
||||
if a := e.OnPeriod(period(8)); a.Kind != DoHalt {
|
||||
t.Errorf("still holding after three missed transmit periods: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOneMissPerPeriodEvenIfTheHandlerRunsTwice(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5)))
|
||||
e.OnPeriod(period(2, cq("DX", NeedDXCC, -5)))
|
||||
p := period(4)
|
||||
e.OnPeriod(p)
|
||||
e.OnPeriod(p)
|
||||
e.OnPeriod(p)
|
||||
if e.Status().Misses != 1 {
|
||||
t.Errorf("misses = %d after one period handled three times, want 1", e.Status().Misses)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClockBackstopReleasesAStuckTarget(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5)))
|
||||
// Decoded every one of its periods and never answering, with the decoder
|
||||
// never reporting a transmission: no counter can advance.
|
||||
for p := 2; p <= 16; p += 2 {
|
||||
e.OnPeriod(period(p, cq("DX", NeedDXCC, -5)))
|
||||
}
|
||||
if a := e.OnPeriod(period(18, cq("DX", NeedDXCC, -5))); a.Kind != DoHalt {
|
||||
t.Errorf("a target held past MaxHold with no counter moving was never released: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
// ── After a series ────────────────────────────────────────────────────────
|
||||
|
||||
func TestAReleasedStationYieldsToAnythingBetter(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedBand, -5)))
|
||||
tx := TXState{Transmitting: true, Msg: "DX " + me + " JN36"}
|
||||
for i := 0; i < 7; i++ {
|
||||
e.NoteTX(tx)
|
||||
}
|
||||
if e.Target() != "" {
|
||||
t.Fatal("still holding after seven calls")
|
||||
}
|
||||
// It is still there, and so is a new entity: the entity takes the slot.
|
||||
a := e.OnPeriod(period(2, cq("DX", NeedBand, -5), cq("RARE", NeedDXCC, -20)))
|
||||
if a.Decode.Call != "RARE" {
|
||||
t.Errorf("picked %q, want the higher priority over the station just released", a.Decode.Call)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAReleasedStationIsCalledAgainWhenNothingBetterIsOnTheAir(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedBand, -5)))
|
||||
tx := TXState{Transmitting: true, Msg: "DX " + me + " JN36"}
|
||||
for i := 0; i < 7; i++ {
|
||||
e.NoteTX(tx)
|
||||
}
|
||||
a := e.OnPeriod(period(2, cq("DX", NeedBand, -5)))
|
||||
if a.Kind != DoReply || a.Decode.Call != "DX" {
|
||||
t.Errorf("nothing better on the air and the station was not called again: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAStationIsParkedAfterItsRounds(t *testing.T) {
|
||||
e := on()
|
||||
tx := TXState{Transmitting: true, Msg: "DX " + me + " JN36"}
|
||||
for round := 1; round <= 3; round++ {
|
||||
a := e.OnPeriod(period(round*2, cq("DX", NeedBand, -5)))
|
||||
if a.Kind != DoReply {
|
||||
t.Fatalf("round %d: not called (%+v)", round, a)
|
||||
}
|
||||
for i := 0; i < 7; i++ {
|
||||
e.NoteTX(tx)
|
||||
}
|
||||
}
|
||||
// Three series of seven is twenty-one calls. That is the end of it for this
|
||||
// session — the whole point of the exercise is that it cannot reach fifty.
|
||||
if a := e.OnPeriod(period(20, cq("DX", NeedBand, -5))); a.Kind != DoNothing {
|
||||
t.Errorf("a fourth series was started: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Handing over ──────────────────────────────────────────────────────────
|
||||
|
||||
func TestFinishedQSOMovesToTheNextPriority(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5)))
|
||||
done := callsMe("DX", NeedDXCC, -5)
|
||||
done.Msg = me + " DX RR73"
|
||||
a := e.OnPeriod(period(2, done, cq("NEXT", NeedBand, -10)))
|
||||
if a.Kind != DoReply || a.Decode.Call != "NEXT" {
|
||||
t.Errorf("after the QSO ended: %+v, want the next priority in the same period", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinishedQSOWithNoPriorityAnswersWhoeverIsCallingUs(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5)))
|
||||
done := callsMe("DX", NeedDXCC, -5)
|
||||
done.Msg = me + " DX RR73"
|
||||
// Two stations calling us, nothing needed from either: the strongest wins.
|
||||
weak := callsMe("WEAK", NeedNone, -18)
|
||||
weak.Watched = true
|
||||
loud := callsMe("LOUD", NeedNone, -4)
|
||||
loud.Watched = true
|
||||
a := e.OnPeriod(period(2, done, weak, loud))
|
||||
if a.Kind != DoReply || a.Decode.Call != "LOUD" {
|
||||
t.Errorf("answered %+v, want the strongest of the stations calling us", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAlreadyWorkedIsNeverCalled(t *testing.T) {
|
||||
e := on()
|
||||
a := e.OnPeriod(period(0, cq("DX", NeedDXCC, -5, worked)))
|
||||
if a.Kind != DoNothing {
|
||||
t.Errorf("called a station already in the log on this band and mode: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayedHistoryIsNeverCalled(t *testing.T) {
|
||||
e := on()
|
||||
old := cq("DX", NeedDXCC, -5)
|
||||
old.IsNew = false
|
||||
if a := e.OnPeriod(period(0, old)); a.Kind != DoNothing {
|
||||
t.Errorf("answered a replayed decode: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoCallStartsOverATransmissionInProgress(t *testing.T) {
|
||||
e := on()
|
||||
p := period(0, cq("DX", NeedDXCC, -5))
|
||||
p.TX = TXState{Transmitting: true}
|
||||
if a := e.OnPeriod(p); a.Kind != DoNothing {
|
||||
t.Errorf("started a call while the decoder was transmitting: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
// ── The "call this station" field ─────────────────────────────────────────
|
||||
|
||||
func TestOnlyCallsThatStation(t *testing.T) {
|
||||
e := New(Settings{Enabled: true, Only: "VP6D"})
|
||||
a := e.OnPeriod(period(0, cq("RARE", NeedDXCC, -5), cq("VP6D", NeedSlot, -20)))
|
||||
if a.Kind != DoReply || a.Decode.Call != "VP6D" {
|
||||
t.Fatalf("picked %+v, want the station named in the field", a)
|
||||
}
|
||||
// Same brakes, then a hard stop: there is nothing else it was asked to do.
|
||||
tx := TXState{Transmitting: true, Msg: "VP6D " + me + " JN36"}
|
||||
for i := 0; i < 7; i++ {
|
||||
e.NoteTX(tx)
|
||||
}
|
||||
if !e.Status().Stopped {
|
||||
t.Error("an explicit target ran out of attempts and the feature did not stop")
|
||||
}
|
||||
if a := e.OnPeriod(period(2, cq("VP6D", NeedSlot, -20))); a.Kind != DoNothing {
|
||||
t.Errorf("kept calling after the stop: %+v", a)
|
||||
}
|
||||
e.Reset()
|
||||
if a := e.OnPeriod(period(4, cq("VP6D", NeedSlot, -20))); a.Kind != DoReply {
|
||||
t.Errorf("the operator restarted it and nothing happened: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisabledDoesNothingAtAll(t *testing.T) {
|
||||
e := New(Settings{})
|
||||
if a := e.OnPeriod(period(0, cq("DX", NeedDXCC, 0))); a.Kind != DoNothing {
|
||||
t.Errorf("switched off and still calling: %+v", a)
|
||||
}
|
||||
if a := e.NoteTX(TXState{Transmitting: true, Msg: "DX " + me + " JN36"}); a.Kind != DoNothing {
|
||||
t.Errorf("switched off and still counting: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOnlyStopsOnceThatStationIsWorked(t *testing.T) {
|
||||
e := New(Settings{Enabled: true, Only: "VP6D"})
|
||||
e.OnPeriod(period(0, cq("VP6D", NeedDXCC, -10)))
|
||||
done := callsMe("VP6D", NeedDXCC, -10)
|
||||
done.Msg = me + " VP6D RR73"
|
||||
e.OnPeriod(period(2, done))
|
||||
// The station is still on the air calling CQ. It has been worked: an
|
||||
// explicit request is for one QSO, not for the whole evening.
|
||||
if a := e.OnPeriod(period(4, cq("VP6D", NeedDXCC, -10))); a.Kind != DoNothing {
|
||||
t.Errorf("called the named station again after working it: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAStationJustWorkedIsNotCalledBackWhileTheLogCatchesUp(t *testing.T) {
|
||||
e := on()
|
||||
e.OnPeriod(period(0, cq("DX", NeedDXCC, -5)))
|
||||
done := callsMe("DX", NeedDXCC, -5)
|
||||
done.Msg = me + " DX RR73"
|
||||
e.OnPeriod(period(2, done))
|
||||
// Still flagged as a new entity — the QSO is not in the log yet — and still
|
||||
// calling CQ. It must not be answered again.
|
||||
if a := e.OnPeriod(period(4, cq("DX", NeedDXCC, -5))); a.Kind != DoNothing {
|
||||
t.Errorf("called back a station worked two periods ago: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChaseListTakesSeveralCallsigns(t *testing.T) {
|
||||
// Typed the way an operator types a list: commas, spaces, or both.
|
||||
for _, field := range []string{"VP6D 3Y0J", "vp6d,3y0j", "VP6D, 3Y0J", " VP6D ;3Y0J "} {
|
||||
if got := onlyList(field); len(got) != 2 || got[0] != "VP6D" || got[1] != "3Y0J" {
|
||||
t.Errorf("%q parsed as %v, want [VP6D 3Y0J]", field, got)
|
||||
}
|
||||
}
|
||||
|
||||
e := New(Settings{Enabled: true, Only: "VP6D, 3Y0J"})
|
||||
// Nothing off the list is called, however rare it is.
|
||||
if a := e.OnPeriod(period(0, cq("RARE", NeedDXCC, -1))); a.Kind != DoNothing {
|
||||
t.Errorf("called a station that is not on the chase list: %+v", a)
|
||||
}
|
||||
// Between two listed stations the ladder still decides: the new entity over
|
||||
// the new slot, whatever their order in the period.
|
||||
a := e.OnPeriod(period(2, cq("3Y0J", NeedSlot, -1), cq("VP6D", NeedDXCC, -22)))
|
||||
if a.Kind != DoReply || a.Decode.Call != "VP6D" {
|
||||
t.Fatalf("picked %+v, want the new entity of the two listed", a)
|
||||
}
|
||||
// Working one of them leaves the other callable — the list is a hunt, not a
|
||||
// single request.
|
||||
done := callsMe("VP6D", NeedDXCC, -22)
|
||||
done.Msg = me + " VP6D RR73"
|
||||
a = e.OnPeriod(period(4, done, cq("3Y0J", NeedSlot, -1)))
|
||||
if a.Kind != DoReply || a.Decode.Call != "3Y0J" {
|
||||
t.Errorf("after working VP6D: %+v, want the other station on the list", a)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Two decoders at once (the split view) ─────────────────────────────────
|
||||
|
||||
func onInst(inst string, p Period) Period {
|
||||
p.Instance = inst
|
||||
for i := range p.Decodes {
|
||||
p.Decodes[i].Instance = inst
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func TestTheOtherReceiverCannotBreakTheQSOInProgress(t *testing.T) {
|
||||
e := on()
|
||||
// Calling a new band on receiver A.
|
||||
if a := e.OnPeriod(onInst("A", period(0, cq("DL1XX", NeedBand, -10)))); a.Decode.Call != "DL1XX" {
|
||||
t.Fatalf("first call went to %+v", a)
|
||||
}
|
||||
// Receiver B now hears a new ENTITY — a better catch by every rule. It must
|
||||
// still not be called: one station at a time, and the QSO in hand is the
|
||||
// one already under way.
|
||||
if a := e.OnPeriod(onInst("B", period(1, cq("RARE", NeedDXCC, -1)))); a.Kind != DoNothing {
|
||||
t.Errorf("the other receiver started a second QSO: %+v", a)
|
||||
}
|
||||
// And B's periods count no misses against A's target: the station is not
|
||||
// absent from B, it was never on that band.
|
||||
e.OnPeriod(onInst("B", period(3, cq("RARE", NeedDXCC, -1))))
|
||||
e.OnPeriod(onInst("B", period(5, cq("RARE", NeedDXCC, -1))))
|
||||
e.OnPeriod(onInst("B", period(7, cq("RARE", NeedDXCC, -1))))
|
||||
if e.Status().Misses != 0 || e.Target() != "DL1XX" {
|
||||
t.Errorf("misses = %d, target = %q — the other receiver's periods were counted",
|
||||
e.Status().Misses, e.Target())
|
||||
}
|
||||
// B transmitting its own QSO is not us calling DL1XX either.
|
||||
for i := 0; i < 9; i++ {
|
||||
e.NoteTX(TXState{Transmitting: true, Instance: "B", Msg: "DL1XX " + me + " JN36"})
|
||||
}
|
||||
if e.Status().Attempts != 0 {
|
||||
t.Errorf("attempts = %d from the other receiver's transmissions, want 0", e.Status().Attempts)
|
||||
}
|
||||
// A's own transmissions do count.
|
||||
e.NoteTX(TXState{Transmitting: true, Instance: "A", Msg: "DL1XX " + me + " JN36"})
|
||||
if e.Status().Attempts != 1 {
|
||||
t.Errorf("attempts = %d after one call from the calling receiver, want 1", e.Status().Attempts)
|
||||
}
|
||||
// Once the QSO is over, the other receiver's station is free to be taken.
|
||||
done := callsMe("DL1XX", NeedBand, -10)
|
||||
done.Msg = me + " DL1XX RR73"
|
||||
e.OnPeriod(onInst("A", period(9, done)))
|
||||
if a := e.OnPeriod(onInst("B", period(11, cq("RARE", NeedDXCC, -1)))); a.Decode.Call != "RARE" {
|
||||
t.Errorf("after the QSO ended, the other receiver was still locked out: %+v", a)
|
||||
}
|
||||
}
|
||||
+100
-2
@@ -9,6 +9,7 @@ package cat
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -240,15 +241,81 @@ func (m *Manager) freqOffsetHz() int64 {
|
||||
// display trick: the readout would say 144 and every spot click, band change and
|
||||
// memory recall would send the rig somewhere 116 MHz away.
|
||||
func (m *Manager) SetFrequency(hz int64) error {
|
||||
real := hz
|
||||
if off := m.freqOffsetHz(); off != 0 && hz > off {
|
||||
hz -= off
|
||||
}
|
||||
return m.exec(func(b Backend) error { return b.SetFrequency(hz) })
|
||||
err := m.exec(func(b Backend) error { return b.SetFrequency(hz) })
|
||||
if err == nil {
|
||||
m.noteCommandedFreq(real)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// noteCommandedFreq publishes a frequency the radio has just acknowledged,
|
||||
// without waiting for the next poll to come round and read it back.
|
||||
//
|
||||
// The wait is what this is about. A rigctl client — WSJT-X above all — sets a
|
||||
// frequency and then READS it back before it believes it is there, and until
|
||||
// then it will not decode, transmit or even update its own dial. Everything
|
||||
// answering "f" here comes from the last poll, so the answer was the OLD
|
||||
// frequency for as long as a poll cycle takes; on a rig reached over the
|
||||
// internet, where one cycle is many round trips, a band change from WSJT-X took
|
||||
// ten seconds to be believed while the radio itself had moved instantly.
|
||||
//
|
||||
// Only when NOT split. In split the two frequencies mean different VFOs and a
|
||||
// guess about which one just moved is how a client ends up writing the transmit
|
||||
// frequency onto the dial — the poll is left to settle that case.
|
||||
func (m *Manager) noteCommandedFreq(hz int64) {
|
||||
if hz <= 0 {
|
||||
return
|
||||
}
|
||||
m.mu.Lock()
|
||||
st := m.state
|
||||
if !st.Connected || st.Split || st.FreqHz == hz {
|
||||
m.mu.Unlock()
|
||||
return
|
||||
}
|
||||
st.FreqHz = hz
|
||||
st.Band = BandFromHz(hz)
|
||||
st.UpdatedAt = time.Now()
|
||||
m.state = st
|
||||
m.mu.Unlock()
|
||||
m.emitState()
|
||||
}
|
||||
|
||||
// SetMode dispatches a SetMode call to the CAT goroutine.
|
||||
func (m *Manager) SetMode(mode string) error {
|
||||
return m.exec(func(b Backend) error { return b.SetMode(mode) })
|
||||
err := m.exec(func(b Backend) error { return b.SetMode(mode) })
|
||||
if err == nil {
|
||||
m.noteCommandedMode(mode)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// noteCommandedMode is the mode half of noteCommandedFreq, and exists for the
|
||||
// same client readback.
|
||||
//
|
||||
// "DATA" is deliberately not published. A backend reports data mode under the
|
||||
// operator's own digital mode (FT8, JS8, RTTY…), and that name is what a QSO is
|
||||
// logged with — a plain "DATA" standing in for a poll cycle is a mode nobody
|
||||
// works, in a field that ends up in an ADIF file. The poll is a fraction of a
|
||||
// second away and knows the real name.
|
||||
func (m *Manager) noteCommandedMode(mode string) {
|
||||
if mode == "" || strings.EqualFold(mode, "DATA") {
|
||||
return
|
||||
}
|
||||
m.mu.Lock()
|
||||
st := m.state
|
||||
if !st.Connected || st.Mode == mode {
|
||||
m.mu.Unlock()
|
||||
return
|
||||
}
|
||||
st.Mode = mode
|
||||
st.UpdatedAt = time.Now()
|
||||
m.state = st
|
||||
m.mu.Unlock()
|
||||
m.emitState()
|
||||
}
|
||||
|
||||
// SetPTT dispatches a transmit on/off request to the CAT goroutine.
|
||||
@@ -256,6 +323,33 @@ func (m *Manager) SetPTT(on bool) error {
|
||||
return m.exec(func(b Backend) error { return b.SetPTT(on) })
|
||||
}
|
||||
|
||||
// dataPTTSetter is implemented by a backend that can key the DATA input rather
|
||||
// than the microphone. A Kenwood TS-590 has two transmit commands and takes its
|
||||
// audio from a different socket for each: TX (or TX0) opens the front mic, TX1
|
||||
// the rear ACC2/USB. Send the wrong one and the radio transmits in silence,
|
||||
// because the audio arriving on USB is simply not the input it is listening to.
|
||||
type dataPTTSetter interface {
|
||||
SetPTTData(on bool) error
|
||||
}
|
||||
|
||||
// SetPTTSource keys the transmitter, saying WHERE the audio is coming from.
|
||||
//
|
||||
// data=true means "the audio reaches the radio on its data/USB input" — what a
|
||||
// voice keyer playing through the rig's own sound card needs. A backend that
|
||||
// draws no distinction (every rig where one PTT is all there is) falls back to
|
||||
// the ordinary key, so nothing changes for it.
|
||||
func (m *Manager) SetPTTSource(on, data bool) error {
|
||||
if !data {
|
||||
return m.SetPTT(on)
|
||||
}
|
||||
return m.exec(func(b Backend) error {
|
||||
if d, ok := b.(dataPTTSetter); ok {
|
||||
return d.SetPTTData(on)
|
||||
}
|
||||
return b.SetPTT(on)
|
||||
})
|
||||
}
|
||||
|
||||
// splitSetter is implemented by the backends that can arm split AND place the
|
||||
// transmit frequency. Both together: arming without setting the dial transmits
|
||||
// on whatever the transmit VFO happened to hold, which is worse than refusing.
|
||||
@@ -677,6 +771,10 @@ type IcomController interface {
|
||||
SetVOXGain(int) error
|
||||
SetAntiVOX(int) error
|
||||
SetPower(bool) error // turn the transceiver on/off (manual — never auto on connect)
|
||||
// RecallBandStack moves the VFO to what the radio's own band stacking
|
||||
// register holds — the operator's last frequency and mode on that band.
|
||||
// Returns the frequency landed on.
|
||||
RecallBandStack(band, reg int) (int64, error)
|
||||
}
|
||||
|
||||
// ScopeSweep is one complete spectrum-scope sweep reassembled from the Icom's
|
||||
|
||||
@@ -425,3 +425,49 @@ func indexPreamble(buf []byte, from int) int {
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// ── Band stacking registers (CI-V 0x1A sub 0x01) ──────────────────────────
|
||||
//
|
||||
// Every modern Icom remembers the last few frequency/mode pairs used on each
|
||||
// band, and its front-panel band key walks through them. That is why pressing
|
||||
// [14] on the radio lands on the FT8 watering hole rather than on a number
|
||||
// somebody chose in software: the register is the operator's OWN last visit.
|
||||
//
|
||||
// The frame is a READ — it asks the rig what a register holds and changes
|
||||
// nothing — so a rig that does not know the command answers NG and the caller
|
||||
// is exactly where it started.
|
||||
//
|
||||
// → 1A 01 <band> <reg>
|
||||
// ← 1A 01 <band> <reg> <freq 5 BCD, LE> <mode> <filter> <data mode> …
|
||||
//
|
||||
// Anything past the data-mode byte (duplex, tone, DV squelch on the VHF rigs)
|
||||
// is not read here: the question is where the operator last was, and the answer
|
||||
// to that is the frequency and the mode.
|
||||
const SubBandStack = 0x01
|
||||
|
||||
// BandStack is one register's contents.
|
||||
type BandStack struct {
|
||||
FreqHz int64
|
||||
Mode byte
|
||||
Data bool // the data-mode flag that goes with Mode
|
||||
}
|
||||
|
||||
// DecodeBandStack reads the payload of a 0x1A 0x01 reply, i.e. everything after
|
||||
// the command byte. ok is false for a frame that is not the register asked for,
|
||||
// which is what a desynchronised read looks like.
|
||||
func DecodeBandStack(data []byte, band, reg byte) (BandStack, bool) {
|
||||
if len(data) < 9 || data[0] != SubBandStack || data[1] != band || data[2] != reg {
|
||||
return BandStack{}, false
|
||||
}
|
||||
hz, ok := BCDToFreq(data[3:8])
|
||||
if !ok || hz <= 0 {
|
||||
return BandStack{}, false
|
||||
}
|
||||
bs := BandStack{FreqHz: hz, Mode: data[8]}
|
||||
// Filter then data mode. A rig that stops at the filter byte is not an
|
||||
// error — it is a register without a data flag, so the flag stays false.
|
||||
if len(data) >= 11 {
|
||||
bs.Data = data[10] != 0
|
||||
}
|
||||
return bs, true
|
||||
}
|
||||
|
||||
@@ -204,3 +204,36 @@ func TestBCDToFreqRejectsNonDecimal(t *testing.T) {
|
||||
t.Error("a short but valid BCD frame must still decode")
|
||||
}
|
||||
}
|
||||
|
||||
// A band stacking register reply, byte for byte as the rigs send it:
|
||||
// 1A 01 <band> <reg> <freq 5 LE-BCD> <mode> <filter> <data>. The payload here
|
||||
// is everything after the command byte, which is what Decoded.Data holds.
|
||||
func TestDecodeBandStack(t *testing.T) {
|
||||
// 14.074.000 MHz, USB, FIL1, data mode on — the FT8 stack on 20 m.
|
||||
frame := []byte{0x01, 0x05, 0x03, 0x00, 0x40, 0x07, 0x14, 0x00, ModeUSB, 0x01, 0x01}
|
||||
bs, ok := DecodeBandStack(frame, 0x05, 0x03)
|
||||
if !ok {
|
||||
t.Fatal("a well-formed register was rejected")
|
||||
}
|
||||
if bs.FreqHz != 14_074_000 {
|
||||
t.Errorf("freq = %d, want 14074000", bs.FreqHz)
|
||||
}
|
||||
if bs.Mode != ModeUSB || !bs.Data {
|
||||
t.Errorf("mode = 0x%02X data = %v, want USB + data", bs.Mode, bs.Data)
|
||||
}
|
||||
// The register ASKED FOR is part of the answer: a reply about another one is
|
||||
// a desynchronised read, not a frequency to send the radio to.
|
||||
if _, ok := DecodeBandStack(frame, 0x05, 0x01); ok {
|
||||
t.Error("a reply for register 3 was accepted as register 1")
|
||||
}
|
||||
if _, ok := DecodeBandStack(frame, 0x03, 0x03); ok {
|
||||
t.Error("a reply about 40 m was accepted as 20 m")
|
||||
}
|
||||
// A register without the data-mode byte is a shorter frame, not a bad one.
|
||||
if bs, ok := DecodeBandStack(frame[:10], 0x05, 0x03); !ok || bs.FreqHz != 14_074_000 || bs.Data {
|
||||
t.Errorf("short register = %+v ok=%v, want the frequency with no data flag", bs, ok)
|
||||
}
|
||||
if _, ok := DecodeBandStack([]byte{0x01, 0x05, 0x03}, 0x05, 0x03); ok {
|
||||
t.Error("a truncated frame was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,6 +594,15 @@ func (b *IcomSerial) SetMode(mode string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return b.setModeBytes(mode, code, data)
|
||||
}
|
||||
|
||||
// setModeBytes is SetMode once the mode is already a CI-V byte and a data flag.
|
||||
// Split out for the band-stacking recall, which gets both FROM the radio and
|
||||
// must not go back through an ADIF name to reach them: a register holding CW-R
|
||||
// or LSB would come back as plain CW or as whatever the band convention says,
|
||||
// i.e. not the mode the operator left there.
|
||||
func (b *IcomSerial) setModeBytes(mode string, code byte, data bool) error {
|
||||
// Set the base mode (keeping the rig's current filter by sending only the
|
||||
// mode byte), then set the data-mode flag for digital modes.
|
||||
if err := b.execIdempotent("set mode "+mode, civ.CmdSetMode, code); err != nil {
|
||||
@@ -1543,6 +1552,14 @@ func (b *IcomSerial) modeCode(mode string) (code byte, data bool, err error) {
|
||||
return civ.ModeCW, false, nil
|
||||
case "SSB":
|
||||
return usb, false, nil
|
||||
case "USB":
|
||||
// The SIDEBAND, asked for by name. "SSB" resolves to whichever side the
|
||||
// band convention wants, which is right for a logged mode and useless
|
||||
// when the operator means "put this radio in USB" — on 40 m there was no
|
||||
// way to say it at all, and the console's own button could not either.
|
||||
return civ.ModeUSB, false, nil
|
||||
case "LSB":
|
||||
return civ.ModeLSB, false, nil
|
||||
case "AM":
|
||||
return civ.ModeAM, false, nil
|
||||
case "FM":
|
||||
@@ -2180,3 +2197,59 @@ func (b *IcomSerial) TXAudioSender() (func([]byte) error, error) {
|
||||
}
|
||||
return nil, fmt.Errorf("this rig takes transmit audio through its USB sound card, not the CAT link")
|
||||
}
|
||||
|
||||
// ── Band stacking registers ───────────────────────────────────────────────
|
||||
|
||||
// RecallBandStack puts the VFO where the operator last was on a band, by asking
|
||||
// the radio rather than by holding an opinion about it.
|
||||
//
|
||||
// The console's band buttons used to send a frequency chosen in software — a
|
||||
// reasonable middle-of-the-band number, and never where anybody actually
|
||||
// operates. The radio already knows better: every band key press it has ever
|
||||
// had is remembered in that band's stacking registers, so register 1 is the
|
||||
// last place used on that band, and cycling through 2 and 3 walks back through
|
||||
// the ones before it — CW where CW was worked, and the FT8 frequency where FT8
|
||||
// was worked, without either being written down anywhere.
|
||||
//
|
||||
// Reads the register, then sets frequency and mode from it. Returns the
|
||||
// frequency it landed on, so the caller can say where it went; a register the
|
||||
// rig will not read leaves the radio untouched and returns an error, which is
|
||||
// what makes the caller's fallback to a plain frequency safe.
|
||||
func (b *IcomSerial) RecallBandStack(band, reg int) (int64, error) {
|
||||
if b.port == nil {
|
||||
return 0, fmt.Errorf("not connected")
|
||||
}
|
||||
if band <= 0 || reg < 1 || reg > 3 {
|
||||
return 0, fmt.Errorf("icom: band stack %d/%d is not a register", band, reg)
|
||||
}
|
||||
bb, rb := civ.ByteToBCD(band), civ.ByteToBCD(reg)
|
||||
if err := b.write(civ.CmdExtra, civ.SubBandStack, bb, rb); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
f, err := b.recv(icomReadTimeout, func(d civ.Decoded) bool {
|
||||
return d.Cmd == civ.CmdExtra && len(d.Data) >= 2 && d.Data[0] == civ.SubBandStack
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
bs, ok := civ.DecodeBandStack(f.Data, bb, rb)
|
||||
if !ok {
|
||||
// Logged with the raw frame: the register layout has a tail that differs
|
||||
// between models, and a rig that answers something we cannot read is the
|
||||
// one thing worth seeing here.
|
||||
applog.Printf("icom: band stack %d/%d — cannot read the register from % X", band, reg, f.Data)
|
||||
return 0, fmt.Errorf("icom: band stacking register %d/%d not understood", band, reg)
|
||||
}
|
||||
if err := b.SetFrequency(bs.FreqHz); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// The mode is best-effort. Landing on the right frequency in the wrong mode
|
||||
// is a nuisance; refusing the whole recall over it would send the operator
|
||||
// back to a button that does less.
|
||||
if bs.Mode != 0 {
|
||||
if err := b.setModeBytes(civ.ModeToADIF(bs.Mode, bs.Data), bs.Mode, bs.Data); err != nil {
|
||||
applog.Printf("icom: band stack %d/%d — frequency set, mode 0x%02X refused: %v", band, reg, bs.Mode, err)
|
||||
}
|
||||
}
|
||||
return bs.FreqHz, nil
|
||||
}
|
||||
|
||||
@@ -632,6 +632,28 @@ func (k *Kenwood) SetPTT(on bool) error {
|
||||
return k.write("RX;")
|
||||
}
|
||||
|
||||
// SetPTTData keys the transmitter on the DATA input: TX1 on a TS-590, which is
|
||||
// ACC2/USB rather than the front microphone. The radio's own manual is explicit
|
||||
// that the parameter chooses the input — "0: SEND (normal transmission using
|
||||
// the MIC input), 1: DATA SEND (ACC2/USB input)" — so a voice keyer playing
|
||||
// into the rig's USB codec has to say TX1 or it transmits dead air while the
|
||||
// radio listens to a microphone nobody is speaking into.
|
||||
//
|
||||
// Unkeying is the same RX either way; there is no data-flavoured stop.
|
||||
func (k *Kenwood) SetPTTData(on bool) error {
|
||||
k.mu.Lock()
|
||||
defer k.mu.Unlock()
|
||||
if k.port == nil {
|
||||
return fmt.Errorf("kenwood: not connected")
|
||||
}
|
||||
k.tx = on
|
||||
if on {
|
||||
k.txAt = time.Now()
|
||||
return k.write("TX1;")
|
||||
}
|
||||
return k.write("RX;")
|
||||
}
|
||||
|
||||
func (k *Kenwood) write(cmd string) error {
|
||||
if k.port == nil {
|
||||
return fmt.Errorf("kenwood: not connected")
|
||||
|
||||
@@ -388,7 +388,14 @@ func (y *Yaesu) RefreshYaesu() error {
|
||||
}
|
||||
|
||||
func (y *Yaesu) SetYaesuPower(w int) error {
|
||||
return y.setAndRefresh(fmt.Sprintf("PC%03d;", clampInt(w, 5, 100)))
|
||||
// The SAME ceiling the console draws its slider to. It was hard-coded at 100
|
||||
// here while yaesuMaxPower already answered 200 for an FTDX101MP: asking for
|
||||
// 200 W sent PC100, the rig obeyed, and the slider sprang back to 100 on the
|
||||
// next poll — which is how the operator discovered it.
|
||||
y.mu.Lock()
|
||||
max := yaesuMaxPower(y.model, y.panel.RFPower)
|
||||
y.mu.Unlock()
|
||||
return y.setAndRefresh(fmt.Sprintf("PC%03d;", clampInt(w, 5, max)))
|
||||
}
|
||||
|
||||
func (y *Yaesu) SetYaesuMicGain(p int) error {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package cat
|
||||
|
||||
import "testing"
|
||||
|
||||
// Reported on an FTDX101MP: the power slider sprang back to 100 W. The console
|
||||
// already knew the rig could do 200 — yaesuMaxPower says so — but the SET path
|
||||
// clamped to 100, so the radio was politely given half what was asked for.
|
||||
func TestYaesuPowerCeilingFollowsTheModel(t *testing.T) {
|
||||
cases := []struct {
|
||||
model string
|
||||
want int
|
||||
}{
|
||||
{"FTDX101MP", 200},
|
||||
{"FT-DX5000", 200},
|
||||
{"FTDX9000", 200},
|
||||
{"FTDX101D", 100},
|
||||
{"FTDX10", 100},
|
||||
{"Yaesu (0999)", 100}, // unknown: ask for too little, never too much
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := yaesuMaxPower(c.model, 0); got != c.want {
|
||||
t.Errorf("%s ceiling = %d W, want %d", c.model, got, c.want)
|
||||
}
|
||||
}
|
||||
// A rig REPORTING more than the table expects has just proved what it can do.
|
||||
if got := yaesuMaxPower("FTDX10", 150); got != 150 {
|
||||
t.Errorf("a rig reporting 150 W was capped at %d", got)
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -40,6 +40,14 @@ type Match struct {
|
||||
Continent string `json:"continent"`
|
||||
Lat float64 `json:"lat"`
|
||||
Lon float64 `json:"lon"`
|
||||
// Exact marks a hit on cty.dat's "=CALLSIGN" list rather than on a prefix.
|
||||
//
|
||||
// The two carry very different authority. A prefix match is a rule of thumb
|
||||
// about a block of callsigns; an exact entry is somebody having looked at
|
||||
// THIS callsign and written down where it was. A second country file may
|
||||
// improve on the first kind and should not be allowed to overrule the
|
||||
// second.
|
||||
Exact bool `json:"exact,omitempty"`
|
||||
}
|
||||
|
||||
type prefixEntry struct {
|
||||
@@ -149,7 +157,9 @@ func (db *DB) Lookup(callsign string) (Match, bool) {
|
||||
return Match{}, false
|
||||
}
|
||||
if e, ok := db.exact[call]; ok {
|
||||
return materialize(e), true
|
||||
m := materialize(e)
|
||||
m.Exact = true
|
||||
return m, true
|
||||
}
|
||||
// KG4 special case: Guantanamo Bay (DXCC 105) is "KG4" followed by EXACTLY
|
||||
// two characters (KG4XX). "KG4", "KG4X", "KG4XYZ"… are continental USA.
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -104,7 +105,26 @@ func UploadHamlog(ctx context.Context, client *http.Client, cfg ServiceConfig, a
|
||||
return uploadHamlogTo(ctx, client, hamlogAPIEndpoint, cfg, adifRecord)
|
||||
}
|
||||
|
||||
// ErrHamlogClosed is why nothing is sent to HAMLOG.online any more.
|
||||
//
|
||||
// The site stopped issuing API keys, and the upload API takes nothing else. An
|
||||
// operator without a key cannot obtain one, and one WITH an old key is the
|
||||
// exception this cannot be built around — so the door is closed here rather
|
||||
// than left ajar for a request that can only fail.
|
||||
//
|
||||
// The code stays: their confirmations still arrive as an ADIF FILE (QSL Manager
|
||||
// → HAMLOG.online → Import confirmations), which never needed a key, and the
|
||||
// sent/received state already in operators' logs stays readable, filterable and
|
||||
// bulk-editable.
|
||||
var ErrHamlogClosed = errors.New("hamlog: HAMLOG.online no longer issues API keys, so uploading is not possible — their confirmations can still be imported from a file")
|
||||
|
||||
func uploadHamlogTo(ctx context.Context, client *http.Client, endpoint string, cfg ServiceConfig, adifRecord string) (UploadResult, error) {
|
||||
return UploadResult{}, ErrHamlogClosed
|
||||
}
|
||||
|
||||
// uploadHamlogLive is the upload as it was, kept whole against the day keys
|
||||
// come back. Nothing calls it.
|
||||
func uploadHamlogLive(ctx context.Context, client *http.Client, endpoint string, cfg ServiceConfig, adifRecord string) (UploadResult, error) {
|
||||
key := strings.TrimSpace(cfg.APIKey)
|
||||
if key == "" {
|
||||
return UploadResult{}, fmt.Errorf("hamlog: API key not set — get one at %s", hamlogKeyPage)
|
||||
|
||||
@@ -3,6 +3,7 @@ package extsvc
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -28,7 +29,7 @@ func TestUploadHamlogRequestShape(t *testing.T) {
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
res, err := uploadHamlogTo(context.Background(), nil, srv.URL, ServiceConfig{APIKey: "KEY123"}, "<call:5>F4BPO <eor>")
|
||||
res, err := uploadHamlogLive(context.Background(), nil, srv.URL, ServiceConfig{APIKey: "KEY123"}, "<call:5>F4BPO <eor>")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -64,7 +65,7 @@ func TestHamlogFailureIsNotSuccess(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte(tc.body))
|
||||
}))
|
||||
res, err := uploadHamlogTo(context.Background(), nil, srv.URL, ServiceConfig{APIKey: "K"}, "<eor>")
|
||||
res, err := uploadHamlogLive(context.Background(), nil, srv.URL, ServiceConfig{APIKey: "K"}, "<eor>")
|
||||
srv.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", tc.body, err)
|
||||
@@ -80,8 +81,21 @@ func TestHamlogFailureIsNotSuccess(t *testing.T) {
|
||||
|
||||
// Nothing leaves without a key, and the message says where to get one.
|
||||
func TestUploadHamlogNeedsAKey(t *testing.T) {
|
||||
_, err := UploadHamlog(context.Background(), nil, ServiceConfig{}, "<eor>")
|
||||
_, err := uploadHamlogLive(context.Background(), nil, "http://example.invalid", ServiceConfig{}, "<eor>")
|
||||
if err == nil || !strings.Contains(err.Error(), hamlogKeyPage) {
|
||||
t.Fatalf("err = %v, want it to point at %s", err, hamlogKeyPage)
|
||||
}
|
||||
}
|
||||
|
||||
// The door is shut: HAMLOG.online stopped issuing API keys, so an upload that
|
||||
// could only fail is refused before it is attempted. The request-shape tests
|
||||
// above still cover the code kept against the day keys come back.
|
||||
func TestUploadHamlogIsClosed(t *testing.T) {
|
||||
res, err := UploadHamlog(context.Background(), nil, ServiceConfig{APIKey: "KEY123"}, "<eor>")
|
||||
if !errors.Is(err, ErrHamlogClosed) {
|
||||
t.Fatalf("err = %v, want ErrHamlogClosed", err)
|
||||
}
|
||||
if res.OK {
|
||||
t.Error("a refused upload reported success")
|
||||
}
|
||||
}
|
||||
|
||||
+13
-15
@@ -84,9 +84,10 @@ type Deps struct {
|
||||
type Manager struct {
|
||||
deps Deps
|
||||
|
||||
mu sync.Mutex
|
||||
cfg ExternalServices
|
||||
rnd *rand.Rand
|
||||
mu sync.Mutex
|
||||
cfg ExternalServices
|
||||
rnd *rand.Rand
|
||||
hamlogClosedOnce sync.Once
|
||||
}
|
||||
|
||||
// maxUploadAttempts bounds retries of a transient upload failure.
|
||||
@@ -230,13 +231,13 @@ func (m *Manager) OnQSOLogged(id int64) {
|
||||
m.route(ServiceCloudlog, id, c)
|
||||
}
|
||||
}
|
||||
// HAMLOG.online — one API key and nothing else to get wrong.
|
||||
if h := cfg.Hamlog; h.AutoUpload {
|
||||
if h.APIKey == "" {
|
||||
m.logf("extsvc: hamlog auto-upload is ON but no API key is set (QSO %d not sent)", id)
|
||||
} else {
|
||||
m.route(ServiceHamlog, id, h)
|
||||
}
|
||||
// HAMLOG.online is closed to uploads — see ErrHamlogClosed. Said once per
|
||||
// session rather than per QSO, because an operator who left the switch on
|
||||
// deserves to know why nothing leaves, and does not deserve it every minute.
|
||||
if cfg.Hamlog.AutoUpload {
|
||||
m.hamlogClosedOnce.Do(func() {
|
||||
m.logf("extsvc: %v", ErrHamlogClosed)
|
||||
})
|
||||
}
|
||||
// HamQTH — the callbook credentials double as the logbook login.
|
||||
if h := cfg.HamQTH; h.AutoUpload {
|
||||
@@ -296,9 +297,7 @@ func (m *Manager) onCloseServices() []Service {
|
||||
if c := cfg.Cloudlog; c.AutoUpload && c.UploadMode == ModeOnClose && c.URL != "" && c.APIKey != "" && c.StationID != "" {
|
||||
out = append(out, ServiceCloudlog)
|
||||
}
|
||||
if h := cfg.Hamlog; h.AutoUpload && h.UploadMode == ModeOnClose && h.APIKey != "" {
|
||||
out = append(out, ServiceHamlog)
|
||||
}
|
||||
|
||||
if h := cfg.HamQTH; h.AutoUpload && h.UploadMode == ModeOnClose && h.Username != "" && h.Password != "" {
|
||||
out = append(out, ServiceHamQTH)
|
||||
}
|
||||
@@ -348,8 +347,7 @@ func (m *Manager) FlushOnClose() int {
|
||||
uploaded += m.flushOneByOne(svc, ids, cfg.HRDLog)
|
||||
case ServiceCloudlog:
|
||||
uploaded += m.flushOneByOne(svc, ids, cfg.Cloudlog)
|
||||
case ServiceHamlog:
|
||||
uploaded += m.flushOneByOne(svc, ids, cfg.Hamlog)
|
||||
|
||||
case ServiceHamQTH:
|
||||
uploaded += m.flushOneByOne(svc, ids, cfg.HamQTH)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ package geo
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -118,3 +119,65 @@ func NeighbourGrids(lat, lon float64, ring int) []string {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// GridsWithin returns every Maidenhead square whose centre lies within km of
|
||||
// (lat, lon), nearest first, at most max of them.
|
||||
//
|
||||
// NeighbourGrids answers "the ring around here", which is the right shape for a
|
||||
// few hundred kilometres and the wrong one past that: a ring is a square, so
|
||||
// asking for 2000 km through it means 1369 squares, most of them further away
|
||||
// than the ones it left out. This measures instead, and the count then follows
|
||||
// the AREA asked for rather than the corner of a box.
|
||||
//
|
||||
// Nearest first because the caller has to be able to trim: these become one
|
||||
// broker subscription each, and when there are more than can be afforded, the
|
||||
// squares to keep are the close ones.
|
||||
func GridsWithin(lat, lon, km float64, max int) []string {
|
||||
if km <= 0 || max <= 0 {
|
||||
return nil
|
||||
}
|
||||
// One square is 1° of latitude and 2° of longitude. Sweep a box big enough
|
||||
// to hold the circle — a degree of latitude is ~111 km everywhere, and a
|
||||
// degree of longitude never MORE than that, so this cannot cut the circle.
|
||||
steps := int(km/111.0) + 1
|
||||
type cand struct {
|
||||
grid string
|
||||
d float64
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
out := []cand{}
|
||||
for dLat := -steps; dLat <= steps; dLat++ {
|
||||
for dLon := -2 * steps; dLon <= 2*steps; dLon++ {
|
||||
la := lat + float64(dLat)
|
||||
lo := lon + float64(dLon)*2
|
||||
if la > 90 || la < -90 {
|
||||
continue
|
||||
}
|
||||
g := LatLonToGrid(la, lo)
|
||||
if seen[g] {
|
||||
continue
|
||||
}
|
||||
// Measured to the square's own centre, not to the sample point, so
|
||||
// two samples landing in one square agree about how far it is.
|
||||
cLat, cLon, ok := GridToLatLon(g)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
d := HaversineKm(lat, lon, cLat, cLon)
|
||||
if d > km {
|
||||
continue
|
||||
}
|
||||
seen[g] = true
|
||||
out = append(out, cand{g, d})
|
||||
}
|
||||
}
|
||||
sort.Slice(out, func(i, j int) bool { return out[i].d < out[j].d })
|
||||
if len(out) > max {
|
||||
out = out[:max]
|
||||
}
|
||||
grids := make([]string, len(out))
|
||||
for i, c := range out {
|
||||
grids[i] = c.grid
|
||||
}
|
||||
return grids
|
||||
}
|
||||
|
||||
@@ -113,3 +113,27 @@ func TestDecodeKeepsTheRawModeMarkerForReplies(t *testing.T) {
|
||||
ev.DecodeModeRaw, "~")
|
||||
}
|
||||
}
|
||||
|
||||
// Reported from a real shack: JTDX decoding FT4 showed up as Q65.
|
||||
//
|
||||
// The two forks disagree about ":" — Q65 in WSJT-X, FT4 in JTDX — so the
|
||||
// character alone cannot answer, and the wrong answer poisons every verdict
|
||||
// that follows: new mode, new slot, the mode filter. The program's own Status
|
||||
// names the mode in full and settles it.
|
||||
func TestAmbiguousModeCharDefersToTheProgram(t *testing.T) {
|
||||
cases := []struct {
|
||||
raw, status, want, why string
|
||||
}{
|
||||
{":", "FT4", "FT4", "JTDX decoding FT4"},
|
||||
{":", "Q65", "Q65", "WSJT-X decoding Q65"},
|
||||
{":", "", "Q65", "no Status yet — WSJT-X's reading, the older and commoner"},
|
||||
// The unambiguous markers are unaffected, Status or no Status.
|
||||
{"~", "FT4", "FT8", "a tilde is FT8 in both"},
|
||||
{"+", "", "FT4", "a plus is FT4 in both"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := DecodeModeName(c.raw, c.status); got != c.want {
|
||||
t.Errorf("DecodeModeName(%q, %q) = %q, want %q — %s", c.raw, c.status, got, c.want, c.why)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,10 +523,24 @@ var decodeModeChar = map[string]string{
|
||||
"#": "JT65",
|
||||
"@": "JT9",
|
||||
"&": "MSK144",
|
||||
":": "Q65",
|
||||
"`": "FST4",
|
||||
}
|
||||
|
||||
// ambiguousModeChar is a marker the forks do not agree on.
|
||||
//
|
||||
// ":" is Q65 in WSJT-X and FT4 in JTDX, so the character alone cannot answer:
|
||||
// a JTDX operator decoding FT4 was told they were on Q65, and every verdict
|
||||
// downstream — new mode, new slot, the mode filter — was computed against a
|
||||
// mode nobody was using.
|
||||
//
|
||||
// The sender's own Status settles it. It comes from the same program, names the
|
||||
// mode in full, and is re-sent whenever it changes, so it knows what that
|
||||
// program is decoding in a way one character never can. The fallback is
|
||||
// WSJT-X's reading, which is the older and commoner one.
|
||||
var ambiguousModeChar = map[string]string{
|
||||
":": "Q65",
|
||||
}
|
||||
|
||||
// DecodeModeName resolves a Decode's mode field to a real mode name. statusMode
|
||||
// is the mode from the same program's last Status, used when the field is a
|
||||
// marker we do not know, or empty.
|
||||
@@ -535,6 +549,13 @@ func DecodeModeName(raw, statusMode string) string {
|
||||
if m, ok := decodeModeChar[raw]; ok {
|
||||
return m
|
||||
}
|
||||
if fallback, ok := ambiguousModeChar[raw]; ok {
|
||||
// Believe the program over the character it happened to print.
|
||||
if st := strings.ToUpper(strings.TrimSpace(statusMode)); st != "" {
|
||||
return st
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
// A mode name is at least two alphanumeric characters ("FT8", "JS8", "Q65").
|
||||
// Anything shorter, or carrying punctuation, is a marker rather than a name.
|
||||
if len(raw) >= 2 {
|
||||
|
||||
@@ -167,9 +167,14 @@ func (m *Manager) Lookup(ctx context.Context, callsign string) (Result, error) {
|
||||
r.Callsign = call
|
||||
r.Source = p.Name()
|
||||
r.FetchedAt = time.Now().UTC()
|
||||
fillFromDXCC(&r, dxcc)
|
||||
normalizeNames(&r)
|
||||
// Cached BEFORE the cty.dat pass, so the row is a copy of the
|
||||
// callbook page rather than of our conclusions about it. Every
|
||||
// read runs the pass again (see the cache-hit path above), so a
|
||||
// later cty.dat update reaches old rows — and a value we derived
|
||||
// can never come back looking like something the page said.
|
||||
_ = m.cache.Put(ctx, r)
|
||||
fillFromDXCC(&r, dxcc)
|
||||
return r, nil
|
||||
}
|
||||
if errors.Is(err, ErrNotFound) {
|
||||
@@ -208,9 +213,9 @@ func (m *Manager) Lookup(ctx context.Context, callsign string) (Result, error) {
|
||||
if !saysNothingAboutLocation(call) {
|
||||
clearHomeLocation(&r)
|
||||
}
|
||||
fillFromDXCC(&r, dxcc) // entity/zones/lat-lon from the FULL (slashed) call
|
||||
normalizeNames(&r)
|
||||
_ = m.cache.Put(ctx, r)
|
||||
_ = m.cache.Put(ctx, r) // the page as it was; cty.dat is applied on read
|
||||
fillFromDXCC(&r, dxcc) // entity/zones/lat-lon from the FULL (slashed) call
|
||||
return r, nil
|
||||
}
|
||||
}
|
||||
@@ -441,11 +446,23 @@ func fillFromDXCC(r *Result, dxcc DXCCResolver) bool {
|
||||
r.Continent = cont
|
||||
filled = true
|
||||
}
|
||||
if cqz != 0 {
|
||||
// Zones FILL, they do not override.
|
||||
//
|
||||
// The rule above is right for the country and wrong for the zones, because
|
||||
// they answer different questions. An entity is what a callsign IS, and
|
||||
// cty.dat is the authority on that. A zone is where the station SITS, and a
|
||||
// large entity has many: Asiatic Russia spans CQ 16 to 23 and ITU 20 to 34,
|
||||
// and cty.dat carries one representative pair for the whole country. Stamping
|
||||
// it on every UA0 threw away the callbook's per-station answer and recorded a
|
||||
// WAZ credit for a zone the operator had not worked — RU0LL is CQ 19, ITU 34,
|
||||
// and was logged 17/30.
|
||||
//
|
||||
// So the callbook wins where it spoke, and cty.dat fills the silence.
|
||||
if cqz != 0 && r.CQZ == 0 {
|
||||
r.CQZ = cqz
|
||||
filled = true
|
||||
}
|
||||
if ituz != 0 {
|
||||
if ituz != 0 && r.ITUZ == 0 {
|
||||
r.ITUZ = ituz
|
||||
filled = true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package lookup
|
||||
|
||||
import "testing"
|
||||
|
||||
// asiaticRussia stands in for cty.dat: one representative zone pair for a
|
||||
// country eight CQ zones wide.
|
||||
func asiaticRussia(cqz, ituz int) fakeDXCC {
|
||||
return fakeDXCC{"RU0LL": {num: 15, country: "Asiatic Russia", cont: "AS", cqz: cqz, ituz: ituz}}
|
||||
}
|
||||
|
||||
// A zone is where the station SITS; an entity is what the callsign IS. Asiatic
|
||||
// Russia spans CQ 16-23 and ITU 20-34, and cty.dat carries one representative
|
||||
// pair for the whole country — so stamping it over a callbook's per-station
|
||||
// answer records a WAZ credit for a zone the operator never worked.
|
||||
//
|
||||
// Reported with real callsigns: RU0LL is CQ 19 / ITU 34 and was logged 17/30.
|
||||
func TestCallbookZonesSurviveTheEntityDefault(t *testing.T) {
|
||||
// What QRZ said about this very station.
|
||||
r := Result{Callsign: "RU0LL", CQZ: 19, ITUZ: 34}
|
||||
fillFromDXCC(&r, asiaticRussia(17, 30))
|
||||
if r.CQZ != 19 || r.ITUZ != 34 {
|
||||
t.Errorf("callbook zones were overwritten: CQ%d ITU%d, want CQ19 ITU34", r.CQZ, r.ITUZ)
|
||||
}
|
||||
if r.Country != "Asiatic Russia" {
|
||||
t.Errorf("the ENTITY must still come from cty.dat, got %q", r.Country)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEntityZonesFillSilence(t *testing.T) {
|
||||
// A callbook that says nothing about zones still gets an answer.
|
||||
r := Result{Callsign: "RU0LL"}
|
||||
fillFromDXCC(&r, asiaticRussia(17, 30))
|
||||
if r.CQZ != 17 || r.ITUZ != 30 {
|
||||
t.Errorf("empty zones were not filled: CQ%d ITU%d", r.CQZ, r.ITUZ)
|
||||
}
|
||||
}
|
||||
+31
-5
@@ -140,8 +140,17 @@ func New(cfg Config) *Watcher {
|
||||
// same measurement is 0.2 to 1.2 — the load follows distance, which is what the
|
||||
// feed is actually about, and it is the same for every operator.
|
||||
func (w *Watcher) topics() []string {
|
||||
bands := w.cfg.Bands
|
||||
// One subscription per band per square multiplies, and past a point the
|
||||
// cheaper trade is to take every band from those squares and drop the
|
||||
// unwanted ones here: four bands over six hundred squares is 2400
|
||||
// subscriptions, where "+" is 600 for maybe three times the messages —
|
||||
// which are then filtered locally, as they already are for everything else.
|
||||
if len(bands) > 1 && len(bands)*len(w.cfg.RxGrids) > 1000 {
|
||||
bands = []string{"+"}
|
||||
}
|
||||
out := []string{}
|
||||
for _, b := range w.cfg.Bands {
|
||||
for _, b := range bands {
|
||||
if len(w.cfg.RxGrids) == 0 {
|
||||
out = append(out, "pskr/filter/v2/"+b+"/#")
|
||||
continue
|
||||
@@ -181,13 +190,30 @@ func (w *Watcher) Start() error {
|
||||
|
||||
opts.OnConnect = func(c mqtt.Client) {
|
||||
w.cfg.Logf("pskr: connected to %s", w.cfg.Broker)
|
||||
for _, topic := range w.topics() {
|
||||
if tok := c.Subscribe(topic, 0, w.handle); tok.Wait() && tok.Error() != nil {
|
||||
w.cfg.Logf("pskr: subscribe %s failed: %v", topic, tok.Error())
|
||||
topics := w.topics()
|
||||
// In batches, not one at a time. Each Subscribe waits for its own
|
||||
// acknowledgement, which is fine for the nine squares this started with
|
||||
// and is minutes of waiting for the six hundred a 2000 km radius asks
|
||||
// for — during which the feed is only partly subscribed and the panel
|
||||
// looks broken.
|
||||
const batch = 100
|
||||
subbed := 0
|
||||
for i := 0; i < len(topics); i += batch {
|
||||
end := i + batch
|
||||
if end > len(topics) {
|
||||
end = len(topics)
|
||||
}
|
||||
filters := make(map[string]byte, end-i)
|
||||
for _, t := range topics[i:end] {
|
||||
filters[t] = 0
|
||||
}
|
||||
if tok := c.SubscribeMultiple(filters, w.handle); tok.Wait() && tok.Error() != nil {
|
||||
w.cfg.Logf("pskr: subscribing to %d topics failed: %v", len(filters), tok.Error())
|
||||
continue
|
||||
}
|
||||
w.cfg.Logf("pskr: watching %s", topic)
|
||||
subbed += len(filters)
|
||||
}
|
||||
w.cfg.Logf("pskr: watching %d topics (%d bands × %d receiver squares)", subbed, len(w.cfg.Bands), max(len(w.cfg.RxGrids), 1))
|
||||
}
|
||||
opts.OnConnectionLost = func(_ mqtt.Client, err error) {
|
||||
w.mu.Lock()
|
||||
|
||||
@@ -0,0 +1,863 @@
|
||||
// Package pskrtgt answers one question about one station: can they hear me?
|
||||
//
|
||||
// It is the other way round from internal/pskr. That watcher asks what is
|
||||
// happening AROUND HERE — reports collected near the operator, whoever sent
|
||||
// them — and it is the right shape for finding a band opening or a new entity.
|
||||
// This one starts from a callsign the operator wants to work and gathers the
|
||||
// evidence about that path, in both directions:
|
||||
//
|
||||
// - did the DX decode MY call, and how long ago
|
||||
// - who NEAR ME did the DX decode (the path is open at my end)
|
||||
// - who near the DX decoded ME (the path is open at his end, even when he
|
||||
// uploads nothing himself)
|
||||
// - how many stations he is decoding right now (the pileup I am up against)
|
||||
// - where in his receive passband those decodes land, so a caller can pick a
|
||||
// slot he is not already covered on
|
||||
//
|
||||
// Nothing here is persisted and nothing is inferred from a QSO: it is a sliding
|
||||
// window of PSK Reporter reports, and when the window empties the answer goes
|
||||
// back to "not known", which is the honest answer.
|
||||
//
|
||||
// The window is FIVE minutes. An FT8 cycle is fifteen seconds, so that is
|
||||
// twenty chances for a path to show itself — short enough that "he decoded you"
|
||||
// still means now, long enough that one missed cycle does not erase it.
|
||||
package pskrtgt
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
)
|
||||
|
||||
// DefaultBroker is PSK Reporter's public MQTT endpoint, TLS. Same one the
|
||||
// band-opening watcher uses — two connections to it, because the two want
|
||||
// opposite slices of the feed and neither can be filtered out of the other's.
|
||||
const DefaultBroker = "tls://mqtt.pskreporter.info:1884"
|
||||
|
||||
const (
|
||||
// window is how far back a report still counts.
|
||||
//
|
||||
// TEN minutes. Five was chosen as "recent enough to still mean now", and on
|
||||
// the air it meant half the evidence: PSK Reporter's uploaders batch their
|
||||
// reports, many of them every five minutes, so a five-minute window catches
|
||||
// roughly one upload cycle per station. Side by side with DXHunter on the
|
||||
// same DX, the same second: 18 decodes here against 27 there, and a station
|
||||
// missing from "from your area" that was simply six minutes old.
|
||||
//
|
||||
// It is a window on ONE station's activity, not on the band: ten minutes of
|
||||
// a DX working a pileup is still what he is doing now.
|
||||
window = 10 * time.Minute
|
||||
// pileupWindow is the tighter one for "how many stations is he working
|
||||
// through". A station he decoded four minutes ago has very likely moved on,
|
||||
// and counting it inflates the only number an operator uses to decide
|
||||
// whether it is worth calling at all.
|
||||
pileupWindow = 2 * time.Minute
|
||||
|
||||
// The passband histogram: 60 Hz bins from 200 Hz to 4000 Hz. Above 4 kHz
|
||||
// there is essentially no FT8, and drawing the empty space made the strip
|
||||
// look broken rather than empty.
|
||||
binHz = 60
|
||||
lowHz = 200
|
||||
highHz = 4000
|
||||
)
|
||||
|
||||
// Scope decides how much of the feed is subscribed to.
|
||||
type Scope string
|
||||
|
||||
const (
|
||||
// ScopeTarget subscribes to three filters: what the DX transmits, what he
|
||||
// receives, and who hears the operator. A handful of messages a second, and
|
||||
// the REST backfill fills the window the moment the target changes.
|
||||
ScopeTarget Scope = "target"
|
||||
// ScopeBand subscribes to the whole band's FTx traffic. Switching target is
|
||||
// then instant with no backfill, at the cost of every message on the band —
|
||||
// hundreds a second when 20 m is busy.
|
||||
ScopeBand Scope = "band"
|
||||
)
|
||||
|
||||
// spot is one PSK Reporter reception report, as the v2 payload carries it.
|
||||
type spot struct {
|
||||
Freq int64 `json:"f"`
|
||||
Mode string `json:"md"`
|
||||
SNR int `json:"rp"`
|
||||
TxCall string `json:"sc"`
|
||||
TxGrid string `json:"sl"`
|
||||
RxCall string `json:"rc"`
|
||||
RxGrid string `json:"rl"`
|
||||
Band string `json:"b"`
|
||||
// at is stamped on arrival. The payload's own timestamps differ between
|
||||
// versions of the feed, and everything here is measured in minutes.
|
||||
at time.Time
|
||||
}
|
||||
|
||||
// Entry is one station in one of the lists the panel shows.
|
||||
type Entry struct {
|
||||
Call string `json:"call"`
|
||||
Grid string `json:"grid"`
|
||||
SNR int `json:"snr"`
|
||||
OffsetHz int `json:"offset_hz"` // audio offset from the operator's dial
|
||||
AgeSec int `json:"age_sec"`
|
||||
}
|
||||
|
||||
// Bin is one 60 Hz slice of the DX's receive passband.
|
||||
type Bin struct {
|
||||
OffsetHz int `json:"offset_hz"`
|
||||
Count int `json:"count"`
|
||||
AvgSNR float64 `json:"avg_snr"`
|
||||
}
|
||||
|
||||
// Analysis is the whole snapshot the panel draws, recomputed on demand.
|
||||
type Analysis struct {
|
||||
Target string `json:"target"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
// Enabled is the operator's switch; Online is whether the broker is
|
||||
// actually connected. A panel that says nothing has to be able to say WHY.
|
||||
Enabled bool `json:"enabled"`
|
||||
Online bool `json:"online"`
|
||||
// Spots is everything in the window, the sign that the feed is alive even
|
||||
// when every counter below is legitimately zero.
|
||||
Spots int `json:"spots"`
|
||||
|
||||
// HeMe is the answer to the question. The rest is what to do when it is no.
|
||||
HeMe bool `json:"he_me"`
|
||||
HeMeSeconds int `json:"he_me_seconds"`
|
||||
HeMeSNR int `json:"he_me_snr"`
|
||||
HeMeOffset int `json:"he_me_offset_hz"`
|
||||
|
||||
// TargetUploads distinguishes "he is not hearing anybody" from "his software
|
||||
// tells PSK Reporter nothing" — without it, a silent panel reads as a dead
|
||||
// band when it may be a full one.
|
||||
TargetUploads bool `json:"target_uploads"`
|
||||
TargetGrid string `json:"target_grid,omitempty"`
|
||||
|
||||
// Near the DX: stations in his square that decoded the operator. This is
|
||||
// what still works when he uploads nothing himself.
|
||||
NearHimCount int `json:"near_him_count"`
|
||||
NearHimTop []Entry `json:"near_him_top"`
|
||||
|
||||
// Near the operator: stations in his own field that the DX decoded.
|
||||
FromMyAreaCount int `json:"from_my_area_count"`
|
||||
FromMyAreaTop []Entry `json:"from_my_area_top"`
|
||||
PathOpen bool `json:"path_open"`
|
||||
|
||||
// Who heard the DX, worldwide and locally.
|
||||
HeardByCount int `json:"heard_by_count"`
|
||||
HeardNearMe int `json:"heard_near_me"`
|
||||
HeardNearMeTop []Entry `json:"heard_near_me_top"`
|
||||
|
||||
// The pileup: everyone he decoded (window), and the recent slice of it.
|
||||
DecodedByCount int `json:"decoded_by_count"`
|
||||
DecodedByTop []Entry `json:"decoded_by_top"`
|
||||
DecodedByCalls []string `json:"decoded_by_calls"`
|
||||
PileupCount int `json:"pileup_count"`
|
||||
|
||||
// His receive passband, and a slot in it that nobody is using.
|
||||
DialHz int64 `json:"dial_hz"`
|
||||
CeilingHz int `json:"ceiling_hz"`
|
||||
DecodesInWindow int `json:"decodes_in_window"`
|
||||
Bins []Bin `json:"bins"`
|
||||
SuggestedOffset int `json:"suggested_offset"`
|
||||
}
|
||||
|
||||
// Config is what the watcher needs from the application.
|
||||
type Config struct {
|
||||
Broker string
|
||||
Scope Scope
|
||||
// MyCall and MyGrid are the operator's. Both matter: the callsign is what
|
||||
// "he decoded you" is looked up by, and the grid decides what counts as
|
||||
// "near me" — its first two characters, a Maidenhead FIELD, which is a few
|
||||
// hundred kilometres rather than a whole continent.
|
||||
MyCall string
|
||||
MyGrid string
|
||||
// Continent resolves a callsign to EU/NA/AS/… It is only a FALLBACK, for an
|
||||
// operator whose grid is not set: without a grid there is nothing to compare
|
||||
// squares with, and a continent is better than nothing. Injected so this
|
||||
// package does not pull in the country file.
|
||||
Continent func(call string) string
|
||||
Logf func(string, ...any)
|
||||
}
|
||||
|
||||
// Watcher owns the MQTT connection and the window.
|
||||
type Watcher struct {
|
||||
mu sync.Mutex
|
||||
cfg Config
|
||||
client mqtt.Client
|
||||
|
||||
target string // the callsign being analysed, upper case
|
||||
mode string // FT8 / FT4 — the target's mode, for the band-scope topic
|
||||
band string // band tag currently subscribed to under ScopeBand
|
||||
dialHz int64 // the operator's dial, for audio offsets
|
||||
|
||||
// subs is what we are subscribed to right now, so a target change can take
|
||||
// the old filters down without guessing at their shape.
|
||||
subs []string
|
||||
spots []spot
|
||||
|
||||
// backfilled remembers the target the REST history was fetched for, so the
|
||||
// panel's polling cannot re-fetch it every second. PSK Reporter's query API
|
||||
// answers that with a rate limit, and rightly.
|
||||
backfilled string
|
||||
}
|
||||
|
||||
func New(cfg Config) *Watcher {
|
||||
if cfg.Broker == "" {
|
||||
cfg.Broker = DefaultBroker
|
||||
}
|
||||
if cfg.Scope == "" {
|
||||
cfg.Scope = ScopeTarget
|
||||
}
|
||||
if cfg.Logf == nil {
|
||||
cfg.Logf = func(string, ...any) {}
|
||||
}
|
||||
return &Watcher{cfg: cfg}
|
||||
}
|
||||
|
||||
// Watch points the analysis at a callsign. Connects on the first call, so an
|
||||
// operator who never opens the panel never opens a socket.
|
||||
//
|
||||
// Called repeatedly with the same target — the panel re-asserts it as the
|
||||
// operator works — so everything expensive here is guarded on an actual change.
|
||||
func (w *Watcher) Watch(target, mode string, dialHz int64) error {
|
||||
target = strings.ToUpper(strings.TrimSpace(target))
|
||||
mode = strings.ToUpper(strings.TrimSpace(mode))
|
||||
if mode == "" {
|
||||
mode = "FT8"
|
||||
}
|
||||
if target == "" {
|
||||
w.Stop()
|
||||
return nil
|
||||
}
|
||||
|
||||
w.mu.Lock()
|
||||
changed := target != w.target || mode != w.mode
|
||||
w.target, w.mode = target, mode
|
||||
if dialHz > 0 {
|
||||
w.dialHz = dialHz
|
||||
}
|
||||
band := bandTag(w.dialHz)
|
||||
bandChanged := band != "" && band != w.band
|
||||
// Set BEFORE any connect: the subscription is built from it, and a first
|
||||
// connect that found it empty would subscribe to every band at once under
|
||||
// the band-wide scope — the one case where that is expensive.
|
||||
if band != "" {
|
||||
w.band = band
|
||||
}
|
||||
client := w.client
|
||||
w.mu.Unlock()
|
||||
|
||||
if client == nil || !client.IsConnected() {
|
||||
c, err := w.connect()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.mu.Lock()
|
||||
w.client, client = c, c
|
||||
w.mu.Unlock()
|
||||
// connect() subscribes on its own OnConnect handler; anything below
|
||||
// would only repeat it.
|
||||
changed = false
|
||||
bandChanged = false
|
||||
}
|
||||
if !changed && !bandChanged {
|
||||
return nil
|
||||
}
|
||||
|
||||
w.mu.Lock()
|
||||
// The window belongs to the target it was collected for. Keeping it across a
|
||||
// change would answer the new question with the old station's evidence.
|
||||
if changed {
|
||||
w.spots = w.spots[:0]
|
||||
}
|
||||
w.mu.Unlock()
|
||||
|
||||
if err := w.resubscribe(client); err != nil {
|
||||
return err
|
||||
}
|
||||
if changed && w.cfg.Scope == ScopeTarget {
|
||||
// Under the band-wide subscription the window is already full of the new
|
||||
// target's reports; under the narrow one it is empty, and the REST query
|
||||
// is what makes the panel useful in the first fifteen seconds instead of
|
||||
// after five minutes.
|
||||
go w.backfill(target, mode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// resubscribe replaces every filter with the ones the current target and scope
|
||||
// want. Takes the old ones down first: a target change that only ADDED filters
|
||||
// would leave the previous station's reports arriving for ever.
|
||||
func (w *Watcher) resubscribe(c mqtt.Client) error {
|
||||
w.mu.Lock()
|
||||
old := w.subs
|
||||
topics := w.topicsLocked()
|
||||
w.subs = topics
|
||||
target, scope := w.target, w.cfg.Scope
|
||||
w.mu.Unlock()
|
||||
|
||||
if len(old) > 0 {
|
||||
if tok := c.Unsubscribe(old...); tok.Wait() && tok.Error() != nil {
|
||||
w.cfg.Logf("pskr target: unsubscribe failed: %v", tok.Error())
|
||||
}
|
||||
}
|
||||
if len(topics) == 0 {
|
||||
return nil
|
||||
}
|
||||
filters := make(map[string]byte, len(topics))
|
||||
for _, t := range topics {
|
||||
filters[t] = 0
|
||||
}
|
||||
if tok := c.SubscribeMultiple(filters, w.handle); tok.Wait() && tok.Error() != nil {
|
||||
return fmt.Errorf("pskr target: subscribe: %w", tok.Error())
|
||||
}
|
||||
w.cfg.Logf("pskr target: watching %s (%s scope, %d filters)", target, scope, len(topics))
|
||||
return nil
|
||||
}
|
||||
|
||||
// topicsLocked builds the subscription list. The v2 topic is
|
||||
//
|
||||
// pskr/filter/v2/<band>/<mode>/<tx call>/<rx call>/<tx grid>/<rx grid>/<tx dxcc>/<rx dxcc>
|
||||
//
|
||||
// so both directions of one callsign are addressable at the broker, which is
|
||||
// the whole reason the narrow scope costs almost nothing.
|
||||
func (w *Watcher) topicsLocked() []string {
|
||||
if w.target == "" {
|
||||
return nil
|
||||
}
|
||||
if w.cfg.Scope == ScopeBand {
|
||||
band := w.band
|
||||
if band == "" {
|
||||
band = "+"
|
||||
}
|
||||
return []string{"pskr/filter/v2/" + band + "/" + w.mode + "/#"}
|
||||
}
|
||||
out := []string{
|
||||
// What he is transmitting: who is hearing him.
|
||||
"pskr/filter/v2/+/" + w.mode + "/" + w.target + "/#",
|
||||
// What he is receiving: the pileup, and whether the operator is in it.
|
||||
"pskr/filter/v2/+/" + w.mode + "/+/" + w.target + "/#",
|
||||
}
|
||||
// Who hears the OPERATOR. Only some of those receivers are near the DX, and
|
||||
// those are the ones that answer "can I be heard over there" on a DX who
|
||||
// uploads nothing himself. Left out when the callsign is not configured
|
||||
// rather than subscribing to a filter with an empty level in it.
|
||||
if my := strings.ToUpper(strings.TrimSpace(w.cfg.MyCall)); my != "" {
|
||||
out = append(out, "pskr/filter/v2/+/"+w.mode+"/"+my+"/#")
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (w *Watcher) connect() (mqtt.Client, error) {
|
||||
opts := mqtt.NewClientOptions().
|
||||
AddBroker(w.cfg.Broker).
|
||||
SetClientID(fmt.Sprintf("opslog-tgt-%d", time.Now().UnixNano())).
|
||||
SetCleanSession(true).
|
||||
SetAutoReconnect(true).
|
||||
SetConnectRetry(true).
|
||||
SetConnectRetryInterval(30 * time.Second).
|
||||
SetConnectTimeout(15 * time.Second).
|
||||
SetOrderMatters(false)
|
||||
// Re-subscribe on every connect, reconnects included: the session is clean,
|
||||
// so the broker remembers nothing and a dropped link would otherwise come
|
||||
// back up subscribed to nothing at all — a panel that goes quiet for ever
|
||||
// while still saying "online".
|
||||
opts.OnConnect = func(c mqtt.Client) {
|
||||
w.mu.Lock()
|
||||
w.subs = nil
|
||||
target, mode := w.target, w.mode
|
||||
w.mu.Unlock()
|
||||
if err := w.resubscribe(c); err != nil {
|
||||
w.cfg.Logf("pskr target: %v", err)
|
||||
}
|
||||
if target != "" && w.cfg.Scope == ScopeTarget {
|
||||
go w.backfill(target, mode)
|
||||
}
|
||||
}
|
||||
opts.OnConnectionLost = func(_ mqtt.Client, err error) {
|
||||
w.cfg.Logf("pskr target: connection lost: %v (will retry)", err)
|
||||
}
|
||||
c := mqtt.NewClient(opts)
|
||||
tok := c.Connect()
|
||||
if !tok.WaitTimeout(15*time.Second) || tok.Error() != nil {
|
||||
err := tok.Error()
|
||||
if err == nil {
|
||||
err = fmt.Errorf("timeout")
|
||||
}
|
||||
return nil, fmt.Errorf("pskr target: connect %s: %w", w.cfg.Broker, err)
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (w *Watcher) handle(_ mqtt.Client, m mqtt.Message) {
|
||||
var s spot
|
||||
if err := json.Unmarshal(m.Payload(), &s); err != nil {
|
||||
return
|
||||
}
|
||||
if s.TxCall == "" || s.RxCall == "" {
|
||||
return
|
||||
}
|
||||
s.TxCall = strings.ToUpper(s.TxCall)
|
||||
s.RxCall = strings.ToUpper(s.RxCall)
|
||||
s.TxGrid = strings.ToUpper(s.TxGrid)
|
||||
s.RxGrid = strings.ToUpper(s.RxGrid)
|
||||
s.at = time.Now()
|
||||
w.mu.Lock()
|
||||
w.spots = append(w.spots, s)
|
||||
w.mu.Unlock()
|
||||
}
|
||||
|
||||
// Stop drops the target and the connection. The window goes with it: it is
|
||||
// evidence about a station nobody is asking about any more.
|
||||
func (w *Watcher) Stop() {
|
||||
w.mu.Lock()
|
||||
c := w.client
|
||||
w.client, w.target, w.band, w.subs, w.backfilled = nil, "", "", nil, ""
|
||||
w.spots = nil
|
||||
w.mu.Unlock()
|
||||
if c != nil {
|
||||
c.Disconnect(250)
|
||||
}
|
||||
}
|
||||
|
||||
// SetDial updates the frequency audio offsets are measured against.
|
||||
func (w *Watcher) SetDial(hz int64) {
|
||||
if hz <= 0 {
|
||||
return
|
||||
}
|
||||
w.mu.Lock()
|
||||
w.dialHz = hz
|
||||
w.mu.Unlock()
|
||||
}
|
||||
|
||||
// SetOperator refreshes the operator's own callsign and grid. Called when the
|
||||
// station profile changes: every "near me" answer is measured from these, and a
|
||||
// stale pair would quietly measure them from somebody else's station.
|
||||
func (w *Watcher) SetOperator(call, grid string) {
|
||||
w.mu.Lock()
|
||||
w.cfg.MyCall = strings.ToUpper(strings.TrimSpace(call))
|
||||
w.cfg.MyGrid = strings.ToUpper(strings.TrimSpace(grid))
|
||||
w.mu.Unlock()
|
||||
}
|
||||
|
||||
// Snapshot recomputes the analysis from the window.
|
||||
func (w *Watcher) Snapshot() Analysis {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
now := time.Now()
|
||||
cutoff := now.Add(-window)
|
||||
kept := w.spots[:0]
|
||||
for _, s := range w.spots {
|
||||
if s.at.After(cutoff) {
|
||||
kept = append(kept, s)
|
||||
}
|
||||
}
|
||||
w.spots = kept
|
||||
|
||||
a := Analysis{
|
||||
Target: w.target,
|
||||
Mode: w.mode,
|
||||
Online: w.client != nil && w.client.IsConnected(),
|
||||
DialHz: w.dialHz,
|
||||
Spots: len(w.spots),
|
||||
}
|
||||
if w.target == "" {
|
||||
return a
|
||||
}
|
||||
|
||||
myCall := strings.ToUpper(strings.TrimSpace(w.cfg.MyCall))
|
||||
myField := ""
|
||||
if g := strings.ToUpper(strings.TrimSpace(w.cfg.MyGrid)); len(g) >= 2 {
|
||||
myField = g[:2]
|
||||
}
|
||||
myCont := ""
|
||||
if myField == "" && myCall != "" && w.cfg.Continent != nil {
|
||||
myCont = strings.ToUpper(w.cfg.Continent(myCall))
|
||||
}
|
||||
|
||||
// His square, taken from any report where he was transmitting. It is what
|
||||
// "near him" is measured against, so without it that whole answer is
|
||||
// unavailable rather than approximated.
|
||||
for i := range w.spots {
|
||||
if w.spots[i].TxCall == w.target && len(w.spots[i].TxGrid) >= 4 {
|
||||
a.TargetGrid = w.spots[i].TxGrid[:4]
|
||||
}
|
||||
}
|
||||
|
||||
entry := func(call, grid string, s *spot) Entry {
|
||||
off := 0
|
||||
if w.dialHz > 0 {
|
||||
off = int(s.Freq - w.dialHz)
|
||||
}
|
||||
return Entry{Call: call, Grid: grid, SNR: s.SNR, OffsetHz: off,
|
||||
AgeSec: int(now.Sub(s.at).Seconds())}
|
||||
}
|
||||
// One entry per station, overwritten as newer reports arrive, so a station
|
||||
// calling every cycle counts once and shows its latest report.
|
||||
heardBy := map[string]Entry{}
|
||||
heardNearMe := map[string]Entry{}
|
||||
fromMyArea := map[string]Entry{}
|
||||
decodedBy := map[string]Entry{}
|
||||
nearHim := map[string]Entry{}
|
||||
pileup := map[string]struct{}{}
|
||||
pileupCutoff := now.Add(-pileupWindow)
|
||||
|
||||
type acc struct {
|
||||
n int
|
||||
sum float64
|
||||
}
|
||||
bins := map[int]*acc{}
|
||||
var lastHeMe *spot
|
||||
|
||||
near := func(theirGrid, call string) bool {
|
||||
if myField != "" {
|
||||
return strings.HasPrefix(strings.ToUpper(theirGrid), myField)
|
||||
}
|
||||
if myCont != "" && w.cfg.Continent != nil {
|
||||
return strings.ToUpper(w.cfg.Continent(call)) == myCont
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
for i := range w.spots {
|
||||
s := &w.spots[i]
|
||||
|
||||
// He transmitted: somebody heard him.
|
||||
if s.TxCall == w.target {
|
||||
e := entry(s.RxCall, s.RxGrid, s)
|
||||
heardBy[s.RxCall] = e
|
||||
if near(s.RxGrid, s.RxCall) {
|
||||
heardNearMe[s.RxCall] = e
|
||||
}
|
||||
}
|
||||
|
||||
// The operator transmitted and a station in the DX's own square heard
|
||||
// it. That is a path to his region, proved without his help.
|
||||
if a.TargetGrid != "" && myCall != "" && s.TxCall == myCall &&
|
||||
strings.HasPrefix(s.RxGrid, a.TargetGrid) {
|
||||
nearHim[s.RxCall] = entry(s.RxCall, s.RxGrid, s)
|
||||
}
|
||||
|
||||
// He received: this is the pileup, the passband, and the answer.
|
||||
if s.RxCall == w.target {
|
||||
a.DecodesInWindow++
|
||||
if s.TxCall == myCall {
|
||||
if lastHeMe == nil || s.at.After(lastHeMe.at) {
|
||||
lastHeMe = s
|
||||
}
|
||||
continue // the operator is not part of his own pileup
|
||||
}
|
||||
decodedBy[s.TxCall] = entry(s.TxCall, s.TxGrid, s)
|
||||
if s.at.After(pileupCutoff) {
|
||||
pileup[s.TxCall] = struct{}{}
|
||||
}
|
||||
if near(s.TxGrid, s.TxCall) {
|
||||
fromMyArea[s.TxCall] = entry(s.TxCall, s.TxGrid, s)
|
||||
}
|
||||
if w.dialHz > 0 {
|
||||
off := int(s.Freq - w.dialHz)
|
||||
if off >= lowHz && off <= highHz {
|
||||
edge := (off / binHz) * binHz
|
||||
b := bins[edge]
|
||||
if b == nil {
|
||||
b = &acc{}
|
||||
bins[edge] = b
|
||||
}
|
||||
b.n++
|
||||
b.sum += float64(s.SNR)
|
||||
if off > a.CeilingHz {
|
||||
a.CeilingHz = off
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if lastHeMe != nil {
|
||||
a.HeMe = true
|
||||
a.HeMeSeconds = int(now.Sub(lastHeMe.at).Seconds())
|
||||
a.HeMeSNR = lastHeMe.SNR
|
||||
if w.dialHz > 0 {
|
||||
a.HeMeOffset = int(lastHeMe.Freq - w.dialHz)
|
||||
}
|
||||
}
|
||||
a.TargetUploads = a.DecodesInWindow > 0
|
||||
a.HeardByCount = len(heardBy)
|
||||
a.HeardNearMe = len(heardNearMe)
|
||||
a.HeardNearMeTop = top(heardNearMe, 5)
|
||||
a.FromMyAreaCount = len(fromMyArea)
|
||||
a.FromMyAreaTop = top(fromMyArea, 5)
|
||||
a.PathOpen = a.FromMyAreaCount > 0
|
||||
a.NearHimCount = len(nearHim)
|
||||
a.NearHimTop = top(nearHim, 5)
|
||||
a.DecodedByCount = len(decodedBy)
|
||||
a.DecodedByTop = top(decodedBy, 10)
|
||||
a.DecodedByCalls = make([]string, 0, len(decodedBy))
|
||||
for c := range decodedBy {
|
||||
a.DecodedByCalls = append(a.DecodedByCalls, c)
|
||||
}
|
||||
sort.Strings(a.DecodedByCalls)
|
||||
a.PileupCount = len(pileup)
|
||||
|
||||
a.Bins = make([]Bin, 0, len(bins))
|
||||
for edge, b := range bins {
|
||||
avg := 0.0
|
||||
if b.n > 0 {
|
||||
avg = b.sum / float64(b.n)
|
||||
}
|
||||
a.Bins = append(a.Bins, Bin{OffsetHz: edge, Count: b.n, AvgSNR: avg})
|
||||
}
|
||||
sort.Slice(a.Bins, func(i, j int) bool { return a.Bins[i].OffsetHz < a.Bins[j].OffsetHz })
|
||||
a.SuggestedOffset = suggestOffset(a.Bins, a.CeilingHz)
|
||||
return a
|
||||
}
|
||||
|
||||
// top returns the freshest entries from a per-callsign map, newest first.
|
||||
func top(m map[string]Entry, limit int) []Entry {
|
||||
out := make([]Entry, 0, len(m))
|
||||
for _, e := range m {
|
||||
out = append(out, e)
|
||||
}
|
||||
sort.Slice(out, func(i, j int) bool { return out[i].AgeSec < out[j].AgeSec })
|
||||
if len(out) > limit {
|
||||
out = out[:limit]
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// suggestOffset picks an audio slot to call on: the middle of the widest run of
|
||||
// empty bins below the ceiling.
|
||||
//
|
||||
// Below the CEILING, not below 4000 Hz. The ceiling is the highest offset he
|
||||
// has actually decoded, and it is the only evidence available about how wide
|
||||
// his receiver is set — plenty of stations run 2500 Hz. Suggesting 3400 Hz to
|
||||
// somebody whose passband stops at 2700 is advice to transmit into a filter.
|
||||
func suggestOffset(bins []Bin, ceiling int) int {
|
||||
if ceiling < 1000 {
|
||||
return 0
|
||||
}
|
||||
used := map[int]bool{}
|
||||
for _, b := range bins {
|
||||
if b.Count > 0 {
|
||||
used[b.OffsetHz] = true
|
||||
// The neighbours too: FT8 is 50 Hz wide and the bins are 60, so a
|
||||
// signal on a bin edge covers the next one as surely as its own.
|
||||
used[b.OffsetHz-binHz] = true
|
||||
used[b.OffsetHz+binHz] = true
|
||||
}
|
||||
}
|
||||
bestStart, bestLen := -1, 0
|
||||
start, run := -1, 0
|
||||
// From 1000 Hz up: below that is where every default transmit offset sits,
|
||||
// so it is the most crowded part of the passband and the least useful
|
||||
// advice.
|
||||
for edge := 1020; edge+binHz <= ceiling; edge += binHz {
|
||||
if used[edge] {
|
||||
start, run = -1, 0
|
||||
continue
|
||||
}
|
||||
if start < 0 {
|
||||
start = edge
|
||||
}
|
||||
run++
|
||||
if run > bestLen {
|
||||
bestStart, bestLen = start, run
|
||||
}
|
||||
}
|
||||
if bestStart < 0 || bestLen < 2 {
|
||||
return 0
|
||||
}
|
||||
return bestStart + bestLen*binHz/2
|
||||
}
|
||||
|
||||
// bandTag names the band a dial frequency is on, in PSK Reporter's own
|
||||
// vocabulary ("20m"). Only used by the band-wide scope, to subscribe to one
|
||||
// band instead of all of them.
|
||||
func bandTag(hz int64) string {
|
||||
khz := hz / 1000
|
||||
switch {
|
||||
case khz >= 1800 && khz <= 2000:
|
||||
return "160m"
|
||||
case khz >= 3500 && khz <= 4000:
|
||||
return "80m"
|
||||
case khz >= 5250 && khz <= 5450:
|
||||
return "60m"
|
||||
case khz >= 7000 && khz <= 7300:
|
||||
return "40m"
|
||||
case khz >= 10100 && khz <= 10150:
|
||||
return "30m"
|
||||
case khz >= 14000 && khz <= 14350:
|
||||
return "20m"
|
||||
case khz >= 18068 && khz <= 18168:
|
||||
return "17m"
|
||||
case khz >= 21000 && khz <= 21450:
|
||||
return "15m"
|
||||
case khz >= 24890 && khz <= 24990:
|
||||
return "12m"
|
||||
case khz >= 28000 && khz <= 29700:
|
||||
return "10m"
|
||||
case khz >= 50000 && khz <= 54000:
|
||||
return "6m"
|
||||
case khz >= 70000 && khz <= 70500:
|
||||
return "4m"
|
||||
case khz >= 144000 && khz <= 148000:
|
||||
return "2m"
|
||||
case khz >= 430000 && khz <= 440000:
|
||||
return "70cm"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ── REST backfill ─────────────────────────────────────────────────────────
|
||||
//
|
||||
// The narrow subscription starts empty, and five minutes of waiting is not an
|
||||
// answer to "should I call this station now". PSK Reporter's query API hands
|
||||
// back the last quarter hour in one request, so the window is populated before
|
||||
// the first cycle finishes.
|
||||
//
|
||||
// Fetched ONCE per target. The panel polls every second, and a query per poll
|
||||
// is what gets an application rate-limited off the service for everyone.
|
||||
|
||||
type pskrReport struct {
|
||||
Sender string `xml:"senderCallsign,attr"`
|
||||
SenderGrid string `xml:"senderLocator,attr"`
|
||||
Receiver string `xml:"receiverCallsign,attr"`
|
||||
ReceiverGrid string `xml:"receiverLocator,attr"`
|
||||
Frequency string `xml:"frequency,attr"`
|
||||
SNR string `xml:"sNR,attr"`
|
||||
Mode string `xml:"mode,attr"`
|
||||
FlowStartSecs string `xml:"flowStartSeconds,attr"`
|
||||
}
|
||||
|
||||
type pskrReports struct {
|
||||
XMLName xml.Name `xml:"receptionReports"`
|
||||
Reports []pskrReport `xml:"receptionReport"`
|
||||
}
|
||||
|
||||
// backfill fetches the last quarter hour for a target, in BOTH directions.
|
||||
//
|
||||
// Two queries, because the panel asks two questions and the service answers
|
||||
// them separately: what the target RECEIVED (his pileup, the passband, whether
|
||||
// he decoded us) and what he TRANSMITTED (who is hearing him, and how much of
|
||||
// that is near us). The live feed fills both eventually; a target picked ten
|
||||
// seconds ago has neither, and with the narrow subscription there is nothing in
|
||||
// the window at all until his own uploader next reports.
|
||||
//
|
||||
// Fetched ONCE per target. The panel polls every second, and a query per poll
|
||||
// is what gets an application rate-limited off the service for everyone.
|
||||
func (w *Watcher) backfill(target, mode string) {
|
||||
w.mu.Lock()
|
||||
if w.backfilled == target {
|
||||
w.mu.Unlock()
|
||||
return
|
||||
}
|
||||
w.backfilled = target
|
||||
w.mu.Unlock()
|
||||
|
||||
got := 0
|
||||
for _, dir := range []struct{ param, what string }{
|
||||
{"receiverCallsign", "decoded by him"},
|
||||
{"senderCallsign", "who is hearing him"},
|
||||
} {
|
||||
q := url.Values{}
|
||||
q.Set(dir.param, target)
|
||||
q.Set("mode", mode)
|
||||
q.Set("flowStartSeconds", strconv.Itoa(-900))
|
||||
q.Set("nolocator", "0")
|
||||
// The pskquery5 endpoint rather than retrieve.pskreporter.info: this is
|
||||
// the one DXHunter has been using against the live service, and a
|
||||
// backfill that silently returns nothing is worse than none at all.
|
||||
req, err := http.NewRequest("GET", "https://pskreporter.info/cgi-bin/pskquery5.pl?"+q.Encode(), nil)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
req.Header.Set("User-Agent", "OpsLog (PSK Reporter target analysis)")
|
||||
resp, err := (&http.Client{Timeout: 15 * time.Second}).Do(req)
|
||||
if err != nil {
|
||||
w.cfg.Logf("pskr target: history for %s (%s) unavailable: %v", target, dir.what, err)
|
||||
continue
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
// 503 is the service saying "too often". Worth a line, because the
|
||||
// panel then fills at the live feed's pace and looks slow for no
|
||||
// visible reason.
|
||||
w.cfg.Logf("pskr target: history for %s (%s) refused (HTTP %d)", target, dir.what, resp.StatusCode)
|
||||
resp.Body.Close()
|
||||
continue
|
||||
}
|
||||
var rr pskrReports
|
||||
err = xml.NewDecoder(resp.Body).Decode(&rr)
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
got += w.absorb(target, rr.Reports)
|
||||
}
|
||||
if got > 0 {
|
||||
w.cfg.Logf("pskr target: %d recent reports for %s from the history queries", got, target)
|
||||
}
|
||||
}
|
||||
|
||||
// absorb adds fetched reports to the window, skipping what the live feed has
|
||||
// already delivered. Without the check the same report arrives twice — once by
|
||||
// MQTT, once by query — and every count that is not per-callsign doubles: the
|
||||
// decode total, and the bars of the passband.
|
||||
func (w *Watcher) absorb(target string, reports []pskrReport) int {
|
||||
now := time.Now()
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
// Still the same target? The operator may have moved on while this was in
|
||||
// flight, and dropping a stale answer into the window would attribute one
|
||||
// station's pileup to another.
|
||||
if w.target != target {
|
||||
return 0
|
||||
}
|
||||
type key struct {
|
||||
tx, rx string
|
||||
hz int64
|
||||
}
|
||||
seen := make(map[key]bool, len(w.spots))
|
||||
for i := range w.spots {
|
||||
seen[key{w.spots[i].TxCall, w.spots[i].RxCall, w.spots[i].Freq}] = true
|
||||
}
|
||||
added := 0
|
||||
for _, r := range reports {
|
||||
hz, _ := strconv.ParseInt(r.Frequency, 10, 64)
|
||||
snr, _ := strconv.Atoi(r.SNR)
|
||||
k := key{strings.ToUpper(r.Sender), strings.ToUpper(r.Receiver), hz}
|
||||
if hz == 0 || seen[k] {
|
||||
continue
|
||||
}
|
||||
at := now
|
||||
if secs, err := strconv.ParseInt(r.FlowStartSecs, 10, 64); err == nil {
|
||||
switch {
|
||||
case secs > 1_000_000_000:
|
||||
at = time.Unix(secs, 0) // an absolute time
|
||||
case secs < 0:
|
||||
at = now.Add(time.Duration(secs) * time.Second) // an age in seconds
|
||||
}
|
||||
}
|
||||
// Stamped with its REAL age, so it ages out of the window on its own and
|
||||
// a quarter-hour-old decode is never read as "he heard you just now".
|
||||
if at.Before(now.Add(-window)) {
|
||||
continue
|
||||
}
|
||||
seen[k] = true
|
||||
w.spots = append(w.spots, spot{
|
||||
Freq: hz, Mode: strings.ToUpper(r.Mode), SNR: snr,
|
||||
TxCall: k.tx, TxGrid: strings.ToUpper(r.SenderGrid),
|
||||
RxCall: k.rx, RxGrid: strings.ToUpper(r.ReceiverGrid),
|
||||
at: at,
|
||||
})
|
||||
added++
|
||||
}
|
||||
return added
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package pskrtgt
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// feed builds a watcher with a window already populated, so the analysis can be
|
||||
// pinned without a broker.
|
||||
func feed(target string, spots ...spot) *Watcher {
|
||||
w := New(Config{MyCall: "F4BPO", MyGrid: "JN36BQ"})
|
||||
w.target, w.mode, w.dialHz = target, "FT8", 14_074_000
|
||||
w.spots = spots
|
||||
return w
|
||||
}
|
||||
|
||||
func rep(tx, txGrid, rx, rxGrid string, snr int, offset int, ago time.Duration) spot {
|
||||
return spot{
|
||||
TxCall: tx, TxGrid: txGrid, RxCall: rx, RxGrid: rxGrid,
|
||||
SNR: snr, Freq: 14_074_000 + int64(offset), at: time.Now().Add(-ago),
|
||||
}
|
||||
}
|
||||
|
||||
func TestHeardYouIsTheOperatorsOwnCallOnly(t *testing.T) {
|
||||
w := feed("YI5RLS",
|
||||
rep("F4BPO", "JN36", "YI5RLS", "LM43", -14, 1200, 20*time.Second),
|
||||
rep("F4XYZ", "JN36", "YI5RLS", "LM43", -8, 900, 30*time.Second),
|
||||
)
|
||||
a := w.Snapshot()
|
||||
if !a.HeMe {
|
||||
t.Fatal("the DX decoded the operator and the panel says he did not")
|
||||
}
|
||||
if a.HeMeSNR != -14 || a.HeMeOffset != 1200 {
|
||||
t.Errorf("he_me = %d dB @ %d Hz, want -14 dB @ 1200 Hz", a.HeMeSNR, a.HeMeOffset)
|
||||
}
|
||||
// The operator is not part of the pileup he is calling into: counting
|
||||
// yourself as competition is how a "1 caller" band looks contested.
|
||||
if a.PileupCount != 1 {
|
||||
t.Errorf("pileup = %d, want 1 (the other station only)", a.PileupCount)
|
||||
}
|
||||
// F4XYZ shares the operator's Maidenhead field, so the path from this
|
||||
// region is demonstrably open.
|
||||
if !a.PathOpen || a.FromMyAreaCount != 1 {
|
||||
t.Errorf("from my area = %d (open=%v), want 1 open", a.FromMyAreaCount, a.PathOpen)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNearHimNeedsHisSquareAndTheOperatorsCall(t *testing.T) {
|
||||
// He transmits (so his square is known), and a station in that square hears
|
||||
// the operator. He himself has decoded nobody.
|
||||
w := feed("YI5RLS",
|
||||
rep("YI5RLS", "LM43", "OH5CX", "KP30", -3, 0, 40*time.Second),
|
||||
rep("F4BPO", "JN36", "YI9XY", "LM43CC", -19, 1500, 25*time.Second),
|
||||
)
|
||||
a := w.Snapshot()
|
||||
if a.TargetGrid != "LM43" {
|
||||
t.Fatalf("his square = %q, want LM43", a.TargetGrid)
|
||||
}
|
||||
if a.NearHimCount != 1 || len(a.NearHimTop) != 1 || a.NearHimTop[0].Call != "YI9XY" {
|
||||
t.Errorf("near him = %d %v, want the one receiver in his square", a.NearHimCount, a.NearHimTop)
|
||||
}
|
||||
// He uploads nothing: the panel must be able to say so, or an operator
|
||||
// reads an empty panel as a closed band.
|
||||
if a.TargetUploads {
|
||||
t.Error("he received nothing in the window, yet the panel claims he uploads")
|
||||
}
|
||||
if a.HeMe {
|
||||
t.Error("nobody reported HIM decoding the operator")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWindowDropsWhatIsTooOld(t *testing.T) {
|
||||
// Inside the window: a report from six minutes ago is still evidence. Five
|
||||
// minutes was too short — measured against DXHunter on the same station at
|
||||
// the same moment, it hid a third of the decodes and a co-area station.
|
||||
w := feed("YI5RLS",
|
||||
rep("F4BPO", "JN36", "YI5RLS", "LM43", -14, 1200, 6*time.Minute),
|
||||
)
|
||||
if a := w.Snapshot(); !a.HeMe {
|
||||
t.Errorf("a six-minute-old report was dropped from a ten-minute window: %+v", a)
|
||||
}
|
||||
// Past it, it goes.
|
||||
w = feed("YI5RLS",
|
||||
rep("F4BPO", "JN36", "YI5RLS", "LM43", -14, 1200, 11*time.Minute),
|
||||
)
|
||||
if a := w.Snapshot(); a.HeMe || a.Spots != 0 {
|
||||
t.Errorf("an eleven-minute-old report survived: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuggestOffsetAvoidsTheOccupiedBinsAndTheCeiling(t *testing.T) {
|
||||
// Busy from 1000 to 1500 Hz, empty from 1560 to 2400, ceiling 2400.
|
||||
bins := []Bin{}
|
||||
for hz := 1020; hz <= 1500; hz += binHz {
|
||||
bins = append(bins, Bin{OffsetHz: hz, Count: 3})
|
||||
}
|
||||
bins = append(bins, Bin{OffsetHz: 2400, Count: 1})
|
||||
got := suggestOffset(bins, 2400)
|
||||
if got < 1620 || got > 2340 {
|
||||
t.Errorf("suggested %d Hz, want somewhere in the empty 1560-2400 run", got)
|
||||
}
|
||||
// A passband that stops low must not produce advice above it: transmitting
|
||||
// past the DX's filter is the one outcome worse than picking a busy slot.
|
||||
if got := suggestOffset(bins, 1500); got != 0 {
|
||||
t.Errorf("suggested %d Hz with a 1500 Hz ceiling and no room, want none", got)
|
||||
}
|
||||
if got := suggestOffset(nil, 0); got != 0 {
|
||||
t.Errorf("suggested %d Hz with no data at all, want none", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTopicsFollowTheScope(t *testing.T) {
|
||||
w := New(Config{MyCall: "F4BPO", Scope: ScopeTarget})
|
||||
w.target, w.mode, w.band = "YI5RLS", "FT8", "20m"
|
||||
got := w.topicsLocked()
|
||||
want := []string{
|
||||
"pskr/filter/v2/+/FT8/YI5RLS/#",
|
||||
"pskr/filter/v2/+/FT8/+/YI5RLS/#",
|
||||
"pskr/filter/v2/+/FT8/F4BPO/#",
|
||||
}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("narrow scope = %v, want %v", got, want)
|
||||
}
|
||||
for i := range want {
|
||||
if got[i] != want[i] {
|
||||
t.Errorf("filter %d = %q, want %q", i, got[i], want[i])
|
||||
}
|
||||
}
|
||||
|
||||
w.cfg.Scope = ScopeBand
|
||||
if got := w.topicsLocked(); len(got) != 1 || got[0] != "pskr/filter/v2/20m/FT8/#" {
|
||||
t.Errorf("band scope = %v, want the one band-wide filter", got)
|
||||
}
|
||||
}
|
||||
+24
-9
@@ -2013,7 +2013,7 @@ type WorkedBefore struct {
|
||||
// at all about yesterday.
|
||||
type BandStatus struct {
|
||||
Band string `json:"band"` // ADIF lowercase band, e.g. "20m"
|
||||
Class string `json:"class"` // "PH" | "CW" | "DIG"
|
||||
Class string `json:"class"` // "PH" | "CW" | "DIG", or a raw digital mode ("FT8", "RTTY"…)
|
||||
Status string `json:"status"` // "call_c" | "call_w" | "dxcc_c" | "dxcc_w"
|
||||
// Call is "", "w" (worked with this callsign) or "c" (confirmed with it).
|
||||
Call string `json:"call,omitempty"`
|
||||
@@ -2402,17 +2402,32 @@ func (r *Repo) WorkedBefore(ctx context.Context, callsign string, dxccHint int,
|
||||
return wb, fmt.Errorf("scan band status: %w", err)
|
||||
}
|
||||
code := bandStatusCode(callW == 1, callC == 1, dxccConfirmed == 1)
|
||||
k := cellKey{band: band, class: modeClass(mode)}
|
||||
if cur, ok := best[k]; !ok || code > cur {
|
||||
best[k] = code
|
||||
keys := []cellKey{{band: band, class: modeClass(mode)}}
|
||||
// The DIGITAL row can be cycled through the individual modes in the UI —
|
||||
// FT8, then FT4, then RTTY — so the same cell is also published under the
|
||||
// raw mode name. The query already grouped by mode; only the collapse to
|
||||
// a class threw that away, and re-asking the database for it would be a
|
||||
// second scan to learn what we had just read.
|
||||
//
|
||||
// Digital only: PH and CW have nothing to cycle through, and publishing
|
||||
// "SSB" beside "PH" would just double the payload.
|
||||
if um := strings.ToUpper(mode); modeClass(mode) == "DIG" && um != "" {
|
||||
keys = append(keys, cellKey{band: band, class: um})
|
||||
}
|
||||
for _, k := range keys {
|
||||
if cur, ok := best[k]; !ok || code > cur {
|
||||
best[k] = code
|
||||
}
|
||||
}
|
||||
// Confirmed beats worked here too, and neither is ever erased by the
|
||||
// entity: this is only ever about the callsign.
|
||||
switch {
|
||||
case callC == 1:
|
||||
callByCell[k] = "c"
|
||||
case callW == 1 && callByCell[k] == "":
|
||||
callByCell[k] = "w"
|
||||
for _, k := range keys {
|
||||
switch {
|
||||
case callC == 1:
|
||||
callByCell[k] = "c"
|
||||
case callW == 1 && callByCell[k] == "":
|
||||
callByCell[k] = "w"
|
||||
}
|
||||
}
|
||||
}
|
||||
statusRows.Close()
|
||||
|
||||
@@ -262,7 +262,18 @@ func (s *Server) serve(c net.Conn) {
|
||||
return
|
||||
}
|
||||
req := strings.TrimSpace(line)
|
||||
started := time.Now()
|
||||
resp, quit := s.handle(req)
|
||||
// A command the radio took a visible time to accept is worth a line of its
|
||||
// own, always — not behind the trace switch below.
|
||||
//
|
||||
// This is the shape every "WSJT-X takes ten seconds to change band" report
|
||||
// has: the client is waiting on us, we are waiting on the rig, and the log
|
||||
// showed neither. Which command, and how long, is the whole diagnosis —
|
||||
// and one second is already far outside anything a healthy link does.
|
||||
if took := time.Since(started); took > time.Second && req != "" {
|
||||
s.log("rigctld: %q took %s — the radio was slow to answer, the client waited that long", req, took.Round(10*time.Millisecond))
|
||||
}
|
||||
// The whole exchange, when tracing is on.
|
||||
//
|
||||
// Only PTT transitions were ever recorded, so when JTDX aborted a
|
||||
@@ -362,6 +373,21 @@ func (s *Server) handle(line string) (resp string, quit bool) {
|
||||
if len(args) < 1 {
|
||||
return rprt(-1), false
|
||||
}
|
||||
// Only touch the radio on a CHANGE, the same rule set_ptt above follows.
|
||||
//
|
||||
// WSJT-X restates the mode on every band change and after every transmit,
|
||||
// almost always the mode the rig is already in. On a native backend that
|
||||
// is not free: an Icom set_mode is the mode frame, the data-mode frame and
|
||||
// a readback to check the rig honoured them, each a round trip — over a
|
||||
// remote CI-V link that is seconds, spent to arrive where we already were,
|
||||
// with the client blocked on the answer the whole time.
|
||||
//
|
||||
// Compared in the CLIENT's own vocabulary — what "m" would report against
|
||||
// what it just asked for — so nothing it can observe changes. A rig whose
|
||||
// mode we do not know yet (empty) is never assumed.
|
||||
if cur := s.rig.Mode(); cur != "" && adifToHamlib(cur) == adifToHamlib(hamlibToADIF(args[0])) {
|
||||
return rprt(0), false
|
||||
}
|
||||
if err := s.rig.SetMode(hamlibToADIF(args[0])); err != nil {
|
||||
s.log("rigctld: set_mode %q failed: %v", args[0], err)
|
||||
return rprt(-9), false
|
||||
|
||||
@@ -332,3 +332,31 @@ func TestModeMapping(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A mode the rig is already in must not reach it. WSJT-X restates the mode on
|
||||
// every band change, and on a native backend each restatement is several CI-V
|
||||
// round trips with the client blocked on the answer.
|
||||
func TestSetModeSkipsWhenUnchanged(t *testing.T) {
|
||||
cases := []struct {
|
||||
rig string // what the rig reports (ADIF)
|
||||
ask string // what the client asks for (hamlib)
|
||||
want int // times the radio should be touched
|
||||
}{
|
||||
{"CW", "CW", 0},
|
||||
{"SSB", "USB", 0}, // "SSB" is reported as USB to a client
|
||||
{"FT8", "PKTUSB", 0}, // data rides on USB; both name it PKTUSB
|
||||
{"USB", "PKTUSB", 1}, // out of data mode into it: a real change
|
||||
{"CW", "USB", 1}, // a real change
|
||||
{"", "USB", 1}, // mode unknown: never assume
|
||||
}
|
||||
for _, c := range cases {
|
||||
f := &fakeRig{mode: c.rig, freq: 14074000}
|
||||
s := New(4532, f, nil)
|
||||
if got, _ := s.handle("M " + c.ask); got != "RPRT 0\n" {
|
||||
t.Fatalf("set_mode %q on a rig in %q = %q", c.ask, c.rig, got)
|
||||
}
|
||||
if n := len(f.setModes); n != c.want {
|
||||
t.Errorf("rig in %q, client asked %q: rig touched %d times, want %d", c.rig, c.ask, n, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.bug.st/serial"
|
||||
@@ -71,32 +72,99 @@ func NewSerial(comPort string, baud int) *Client {
|
||||
return &Client{ComPort: comPort, Baud: baud}
|
||||
}
|
||||
|
||||
// roundTrip opens a connection (TCP or serial per the client's config), sends
|
||||
// one CR-terminated command and (when wantReply) reads one CR/LF-terminated
|
||||
// reply line.
|
||||
// bootSettle is how long a freshly opened serial port is left alone before the
|
||||
// first command.
|
||||
//
|
||||
// An Arduino-based controller — K3NG's firmware, the ERC family — RESETS when
|
||||
// the serial port is opened: the DTR line pulses its reset pin, and the
|
||||
// bootloader then holds the processor for a second or more. A command sent into
|
||||
// that window is simply lost, which is exactly how a controller that answers
|
||||
// PuTTY perfectly reports "no reply" here.
|
||||
const bootSettle = 2 * time.Second
|
||||
|
||||
// heldPort is an open serial port, kept between calls.
|
||||
//
|
||||
// The package holds it rather than the Client because the callers build a FRESH
|
||||
// Client for every poll (one per heading request), and the port has to outlive
|
||||
// them. Reopening per command is what made an Arduino controller reboot several
|
||||
// times a second and never answer anything. A serial port is a single-owner
|
||||
// resource in any case: two clients for COM5 would be two handles on one cable.
|
||||
type heldPort struct {
|
||||
p serial.Port
|
||||
openedAt time.Time
|
||||
}
|
||||
|
||||
var (
|
||||
portsMu sync.Mutex
|
||||
openPorts = map[string]*heldPort{}
|
||||
)
|
||||
|
||||
// acquire returns the open port for com, opening it if needed.
|
||||
func acquire(com string, baud int) (*heldPort, error) {
|
||||
portsMu.Lock()
|
||||
defer portsMu.Unlock()
|
||||
if h, ok := openPorts[com]; ok && h.p != nil {
|
||||
return h, nil
|
||||
}
|
||||
if baud <= 0 {
|
||||
baud = 9600
|
||||
}
|
||||
sp, err := serial.Open(com, &serial.Mode{BaudRate: baud})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("open rotator %s @ %d baud: %w", com, baud, err)
|
||||
}
|
||||
_ = sp.SetReadTimeout(200 * time.Millisecond)
|
||||
h := &heldPort{p: sp, openedAt: time.Now()}
|
||||
openPorts[com] = h
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// drop closes and forgets a port, so the next call opens a fresh one. Called
|
||||
// when an exchange fails: a half-spoken conversation is worse than a new one.
|
||||
func drop(com string) {
|
||||
portsMu.Lock()
|
||||
defer portsMu.Unlock()
|
||||
if h, ok := openPorts[com]; ok {
|
||||
if h.p != nil {
|
||||
_ = h.p.Close()
|
||||
}
|
||||
delete(openPorts, com)
|
||||
}
|
||||
}
|
||||
|
||||
// roundTrip sends one CR-terminated command and (when wantReply) reads one
|
||||
// CR/LF-terminated reply line. Serial keeps its port open between calls; TCP
|
||||
// dials per call, which is what the ARCO's LAN side expects.
|
||||
func (c *Client) roundTrip(cmd string, wantReply bool) (string, error) {
|
||||
var conn io.ReadWriteCloser
|
||||
if c.ComPort != "" {
|
||||
baud := c.Baud
|
||||
if baud <= 0 {
|
||||
baud = 9600
|
||||
}
|
||||
sp, err := serial.Open(c.ComPort, &serial.Mode{BaudRate: baud})
|
||||
h, err := acquire(c.ComPort, c.Baud)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("open rotator %s @ %d baud: %w", c.ComPort, baud, err)
|
||||
return "", err
|
||||
}
|
||||
_ = sp.SetReadTimeout(200 * time.Millisecond)
|
||||
conn = sp
|
||||
// Let a just-reset controller finish booting before speaking to it.
|
||||
if wait := bootSettle - time.Since(h.openedAt); wait > 0 {
|
||||
time.Sleep(wait)
|
||||
}
|
||||
conn = h.p
|
||||
// Whatever is already in the buffer belongs to the last exchange — the
|
||||
// trailing LF of the previous reply, or a line the controller volunteered
|
||||
// while nobody was reading. Read as the answer to THIS command it would
|
||||
// be an answer to the wrong question.
|
||||
drain(h.p)
|
||||
} else {
|
||||
nc, err := net.DialTimeout("tcp", net.JoinHostPort(c.Host, strconv.Itoa(c.Port)), dialTimeout)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("connect ARCO %s:%d: %w", c.Host, c.Port, err)
|
||||
}
|
||||
_ = nc.SetDeadline(time.Now().Add(ioTimeout))
|
||||
defer nc.Close()
|
||||
conn = nc
|
||||
}
|
||||
defer conn.Close()
|
||||
if _, err := conn.Write([]byte(cmd + "\r")); err != nil {
|
||||
if c.ComPort != "" {
|
||||
drop(c.ComPort)
|
||||
}
|
||||
return "", fmt.Errorf("send %q: %w", cmd, err)
|
||||
}
|
||||
if !wantReply {
|
||||
@@ -121,11 +189,29 @@ func (c *Client) roundTrip(cmd string, wantReply bool) (string, error) {
|
||||
}
|
||||
line := strings.TrimSpace(sb.String())
|
||||
if line == "" {
|
||||
// Silence may mean the port is fine and the controller is not, or that
|
||||
// the handle is stale (a USB adapter unplugged and replugged). Let go of
|
||||
// it so the next attempt starts from a clean open rather than repeating
|
||||
// the same silence for ever.
|
||||
if c.ComPort != "" {
|
||||
drop(c.ComPort)
|
||||
}
|
||||
return "", fmt.Errorf("no reply to %q", cmd)
|
||||
}
|
||||
return line, nil
|
||||
}
|
||||
|
||||
// drain empties whatever is waiting, without blocking for long.
|
||||
func drain(sp serial.Port) {
|
||||
buf := make([]byte, 128)
|
||||
for i := 0; i < 4; i++ {
|
||||
n, err := sp.Read(buf)
|
||||
if n == 0 || err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GoTo points the antenna at the given azimuth (0-359). GS-232A takes M000-M450
|
||||
// (overlap rotators accept >360); we normalise to [0,360).
|
||||
func (c *Client) GoTo(az int) error {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package gs232
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Real replies, as the controllers actually send them — a K3NG answering "C"
|
||||
// with "+0140" and CR+LF among them (reported from a live controller).
|
||||
func TestAzimuthReplies(t *testing.T) {
|
||||
cases := []struct {
|
||||
raw string
|
||||
want int
|
||||
}{
|
||||
{"+0140\r\n", 140}, // GS-232A, K3NG firmware
|
||||
{"+0000\r", 0}, // due north
|
||||
{"+0359\r\n", 359}, // just short of it
|
||||
{"AZ=140\r\n", 140}, // GS-232B flavour
|
||||
{"AZ=140 EL=000\r\n", 140}, // GS-232B with elevation on the same line
|
||||
{"\r\n+0075\r\n", 75}, // a leftover terminator ahead of the answer
|
||||
}
|
||||
for _, c := range cases {
|
||||
m := azRe.FindStringSubmatch(strings.TrimSpace(c.raw))
|
||||
if m == nil {
|
||||
t.Errorf("no azimuth found in %q", c.raw)
|
||||
continue
|
||||
}
|
||||
got, _ := strconv.Atoi(m[1])
|
||||
if got%360 != c.want {
|
||||
t.Errorf("%q parsed as %d, want %d", c.raw, got%360, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,11 @@ func TestProfileSwitchReappliesEveryStartupDevice(t *testing.T) {
|
||||
"startAllEnabledClusters": "the cluster panel reconnects itself; its servers are a global list",
|
||||
"startGridCache": "a shared on-disk grid cache, not a profile's",
|
||||
"startBandOpenFeed": "PSK Reporter, keyed on the operator grid it re-reads itself",
|
||||
// The auto-call loop is ONE goroutine for the life of the process —
|
||||
// starting a second on every profile switch would give one engine two
|
||||
// sweepers. Its settings do follow the profile: reloadAfterProfileSwitch
|
||||
// calls applyAutoCall, which re-reads them and clears the target.
|
||||
"startAutoCall": "a single sweeper goroutine; applyAutoCall in the reload carries the settings",
|
||||
}
|
||||
|
||||
startup := body(t, string(src), "func (a *App) startup(ctx context.Context) {")
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
package main
|
||||
|
||||
// PSK Reporter target analysis — the panel beside the FT decodes.
|
||||
//
|
||||
// The FT decodes list says who is on the air. It cannot say whether the station
|
||||
// you are about to call can hear you, and on FT8 that is the only question that
|
||||
// matters: a pileup is invisible from this end, and calling a DX who is not
|
||||
// hearing your region at all is the commonest way to spend twenty minutes for
|
||||
// nothing.
|
||||
//
|
||||
// internal/pskrtgt does the work. This file is the wiring: settings, lifecycle,
|
||||
// and the bindings the panel polls.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"hamlog/internal/applog"
|
||||
"hamlog/internal/pskrtgt"
|
||||
)
|
||||
|
||||
const (
|
||||
keyPSKTargetOn = "pskrtgt.enabled" // the operator's master switch
|
||||
keyPSKTargetScope = "pskrtgt.scope" // "target" (narrow) | "band" (whole band)
|
||||
)
|
||||
|
||||
// PSKTargetSettings is the panel's shape in Settings.
|
||||
type PSKTargetSettings struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
// Scope is how much of the PSK Reporter feed is subscribed to. The narrow
|
||||
// one is three filters about two callsigns; the wide one is every FTx report
|
||||
// on the band. The difference is a few messages a second against several
|
||||
// hundred, which on an old PC is the difference between a panel and a
|
||||
// problem — so the narrow one is the default, and the wide one is there for
|
||||
// an operator who switches target constantly and has the machine for it.
|
||||
Scope string `json:"scope"`
|
||||
}
|
||||
|
||||
func (a *App) GetPSKTargetSettings() PSKTargetSettings {
|
||||
scope := a.settingOr(keyPSKTargetScope, string(pskrtgt.ScopeTarget))
|
||||
if scope != string(pskrtgt.ScopeBand) {
|
||||
scope = string(pskrtgt.ScopeTarget)
|
||||
}
|
||||
return PSKTargetSettings{
|
||||
Enabled: a.settingOr(keyPSKTargetOn, "0") == "1",
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) SavePSKTargetSettings(s PSKTargetSettings) error {
|
||||
on := "0"
|
||||
if s.Enabled {
|
||||
on = "1"
|
||||
}
|
||||
scope := s.Scope
|
||||
if scope != string(pskrtgt.ScopeBand) {
|
||||
scope = string(pskrtgt.ScopeTarget)
|
||||
}
|
||||
a.setSetting(keyPSKTargetOn, on)
|
||||
a.setSetting(keyPSKTargetScope, scope)
|
||||
// Rebuilt rather than reconfigured: the scope decides the subscriptions, and
|
||||
// a watcher that changed them under itself would have to unpick filters it
|
||||
// no longer knows the shape of. It reconnects on the next Watch call, which
|
||||
// the panel makes every second anyway.
|
||||
a.stopPSKTarget()
|
||||
applog.Printf("pskr target: %v (scope %s)", s.Enabled, scope)
|
||||
return nil
|
||||
}
|
||||
|
||||
// pskTargetWatcher returns the watcher, building it on first use. Nothing is
|
||||
// connected until a target is set, so an operator who never opens the panel
|
||||
// never opens a socket to the broker.
|
||||
func (a *App) pskTargetWatcher() *pskrtgt.Watcher {
|
||||
a.pskTgtMu.Lock()
|
||||
defer a.pskTgtMu.Unlock()
|
||||
if a.pskTgt != nil {
|
||||
return a.pskTgt
|
||||
}
|
||||
s := a.GetPSKTargetSettings()
|
||||
a.pskTgt = pskrtgt.New(pskrtgt.Config{
|
||||
Scope: pskrtgt.Scope(s.Scope),
|
||||
MyCall: a.opCall,
|
||||
MyGrid: a.opGrid,
|
||||
// Only a fallback, for a station with no grid set — see the package.
|
||||
Continent: func(call string) string {
|
||||
if a.dxcc == nil {
|
||||
return ""
|
||||
}
|
||||
if m, ok := a.dxcc.Lookup(call); ok {
|
||||
return m.Continent
|
||||
}
|
||||
return ""
|
||||
},
|
||||
Logf: applog.Printf,
|
||||
})
|
||||
return a.pskTgt
|
||||
}
|
||||
|
||||
func (a *App) stopPSKTarget() {
|
||||
a.pskTgtMu.Lock()
|
||||
w := a.pskTgt
|
||||
a.pskTgt = nil
|
||||
a.pskTgtMu.Unlock()
|
||||
if w != nil {
|
||||
w.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
// SetPSKTarget points the analysis at a callsign — normally the station the
|
||||
// operator has just clicked or is calling. An empty callsign takes the feed
|
||||
// down: no target, no subscription.
|
||||
//
|
||||
// mode is the target's own (FT8/FT4), and dialHz the operator's dial, which is
|
||||
// what turns a report's frequency into an audio offset.
|
||||
func (a *App) SetPSKTarget(call, mode string, dialHz int64) error {
|
||||
if !a.GetPSKTargetSettings().Enabled {
|
||||
a.stopPSKTarget()
|
||||
return nil
|
||||
}
|
||||
call = strings.ToUpper(strings.TrimSpace(call))
|
||||
if call == "" {
|
||||
a.stopPSKTarget()
|
||||
return nil
|
||||
}
|
||||
w := a.pskTargetWatcher()
|
||||
// The operator's identity is re-asserted on every call rather than captured
|
||||
// once: a profile switch changes both the callsign "he decoded you" looks
|
||||
// for and the square "near me" is measured from.
|
||||
w.SetOperator(a.opCall, a.opGrid)
|
||||
if err := w.Watch(call, mode, dialHz); err != nil {
|
||||
return fmt.Errorf("PSK Reporter: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPSKAnalysis is what the panel polls. Always answers, even with the feature
|
||||
// off or no target set — the panel says WHY it is empty, and it can only do
|
||||
// that if it is told.
|
||||
func (a *App) GetPSKAnalysis() pskrtgt.Analysis {
|
||||
s := a.GetPSKTargetSettings()
|
||||
a.pskTgtMu.Lock()
|
||||
w := a.pskTgt
|
||||
a.pskTgtMu.Unlock()
|
||||
if w == nil {
|
||||
return pskrtgt.Analysis{Enabled: s.Enabled}
|
||||
}
|
||||
an := w.Snapshot()
|
||||
an.Enabled = s.Enabled
|
||||
return an
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
const (
|
||||
// appVersion is stamped on every heartbeat (and could feed the About box).
|
||||
appVersion = "0.27.7"
|
||||
appVersion = "0.27.12"
|
||||
|
||||
// posthogHost is the PostHog ingestion endpoint. EU cloud by default; change
|
||||
// to https://us.i.posthog.com for a US project.
|
||||
|
||||
Reference in New Issue
Block a user