From bc8b685c158cb22cac27089d15398820db4e0950 Mon Sep 17 00:00:00 2001 From: Trevor Stone Date: Mon, 2 Sep 2024 13:06:49 -0600 Subject: [PATCH] Cabrillo: treat multi-phone as SSB and RTTY+digital as DIGI Previously a log with SSB & FM or a log with RTTY & PSK would be MIXED. --- adif/cabrillo.go | 38 ++++++++++++++++++++++---------------- adif/cabrillo_test.go | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/adif/cabrillo.go b/adif/cabrillo.go index 1d69c69..366d95f 100644 --- a/adif/cabrillo.go +++ b/adif/cabrillo.go @@ -319,28 +319,34 @@ func (o *CabrilloIO) getCategories(l *Logfile) map[string]string { } if cats["MODE"] == "" { modes := fieldValues(l, "MODE") - var mode string - if len(modes) == 1 { - switch maps.Keys(modes)[0] { - case "CW": - mode = "CW" + var phone, fm, cw, rtty, digi int + for m := range modes { + switch m { case "SSB", "AM", "DIGITALVOICE": - mode = "SSB" + phone++ case "FM": - mode = "FM" + fm++ + case "CW": + cw++ case "RTTY": - mode = "RTTY" + rtty++ default: - mode = "DIGI" + digi++ } - } else if len(modes) > 1 { + } + var mode string + if fm == len(modes) { + mode = "FM" + } else if phone+fm == len(modes) { + mode = "SSB" + } else if cw == len(modes) { + mode = "CW" + } else if rtty == len(modes) { + mode = "RTTY" + } else if digi+rtty == len(modes) { mode = "DIGI" - for m := range modes { - if m == "CW" || m == "SSB" || m == "FM" || m == "AM" { - mode = "MIXED" - break - } - } + } else { + mode = "MIXED" } cats["MODE"] = mode } diff --git a/adif/cabrillo_test.go b/adif/cabrillo_test.go index 7cfd437..4d58d51 100644 --- a/adif/cabrillo_test.go +++ b/adif/cabrillo_test.go @@ -365,6 +365,24 @@ func TestInferrCabrilloCategories(t *testing.T) { wantBand: "ALL", wantPower: "HIGH", }, + { + name: "rtty and digi", + modes: []string{"RTTY", "RTTY", "RTTY", "HELL"}, + bands: []string{"40m", "20m", "15m", "10m"}, + powers: []string{"5", "25", "50", "100"}, + wantMode: "DIGI", + wantBand: "ALL", + wantPower: "HIGH", + }, + { + name: "multi phone", + modes: []string{"DIGITALVOICE", "FM", "AM", "SSB"}, + bands: []string{"70cm", "2m", "6m", "10m"}, + powers: []string{"1", "2", "3", "4"}, + wantMode: "SSB", + wantBand: "ALL", + wantPower: "QRP", + }, { name: "mixed mode", modes: []string{"FT8", "SSB"},