From 247f869bf56a0558ab7c1cf79328884f2fe8adcc Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Tue, 23 Jun 2020 14:03:23 +0200 Subject: [PATCH] Start processing frequency --- cmd/parse_line.go | 11 +++++++++++ cmd/parse_line_test.go | 5 +++++ todo.md | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/parse_line.go b/cmd/parse_line.go index cd71715..67898be 100644 --- a/cmd/parse_line.go +++ b/cmd/parse_line.go @@ -56,6 +56,7 @@ var regexpIsTimePart = regexp.MustCompile("^[0-5]{1}[0-9]{1}$|^[1-9]{1}$") var regexpIsOMname = regexp.MustCompile("^@") var regexpIsGridLoc = regexp.MustCompile("^#") var regexpIsRst = regexp.MustCompile("^[\\d]{1,3}$") +var regexpIsFreq = regexp.MustCompile("^[\\d]+.[\\d]+$") // ParseLine cuts a FLE line into useful bits func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string){ @@ -123,6 +124,16 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg continue } + // Is it a Frequency? + if regexpIsFreq.MatchString(element) { + //TODO: check if we are in the band limits (is a band defined?) + //TODO: how do we handle/report errors + //TODO: take only 3 decimal digits + //TODO: update the column display + logLine.Frequency = element + continue + } + // Is it a call sign ? if validCallRegexp.MatchString(strings.ToUpper(element)) { callErrorMsg := "" diff --git a/cmd/parse_line_test.go b/cmd/parse_line_test.go index 767cb7d..413dd80 100644 --- a/cmd/parse_line_test.go +++ b/cmd/parse_line_test.go @@ -67,6 +67,11 @@ func TestParseLine(t *testing.T) { args{ inputStr: "#grid", previousLine: LogLine{ Mode: "SSB", }}, LogLine{ GridLoc: "grid", Mode: "SSB", RSTsent: "59", RSTrcvd: "59"}, "", }, + { + "Parse frequency", + args{ inputStr: "14.453 on4kjm", previousLine: LogLine{ Mode: "SSB", Band: "20m"}}, + LogLine{ Band: "20m", Frequency: "14.453", Call: "ON4KJM" ,Mode: "SSB", RSTsent: "59", RSTrcvd: "59"}, "", + }, { "parse partial RST (sent) - CW", args{ inputStr: "1230 on4kjm 5", previousLine: LogLine{ Mode: "CW", ModeType: "CW"}}, diff --git a/todo.md b/todo.md index e4b850f..70f6cc9 100644 --- a/todo.md +++ b/todo.md @@ -11,14 +11,15 @@ ## Input processing * [x] infer RST +* [x] Create the logic to take over from the previous line +* [ ] decode and check frequency * [ ] DATE keyword is now optional * [ ] New MYGRID keyword -* [ ] Create the logic to take over from the previous line * [ ] Support different date delimiter * [ ] Support extrapolated date * [ ] Support date not prefixed by "date" (non header mode) * [ ] Support date increment -* [ ] decode and check frequency + ## Later * [ ] Process contest reports