From 8d0301879634423791b52476f7985efc9d632477 Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Sun, 4 Oct 2020 14:42:36 +0200 Subject: [PATCH] Validate Sota chaser log --- README.md | 6 +++--- doc/whats_new.md | 11 +++++++--- fleprocess/csv_process.go | 19 ++++++++++++++++- fleprocess/csv_process_test.go | 39 ++++++++++++++++++++++++++++------ fleprocess/csv_write_test.go | 17 ++++++++++++++- 5 files changed, 78 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0edb347..6eef44b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ But is also the alibi to learn and explore GO. ## Installing The tool is installed by downloading and unpacking the archive for your operating system. -A version is available for Windows, MacOS, Linux and ARM (RaspeberyPi). +A version is available for Windows, MacOS, Linux and ARM (RaspberryPi). Most of them are available as 32 or 64 bit applications. A docker version is also available. @@ -29,11 +29,11 @@ Detailed installation instructions can be found [at this page](doc/install.md). Detailed explanations can be found [on this page](doc/usage.md). -Most comon use cases are described hereafter as examples. +Most common use cases are described hereafter as examples. ### Example: validate the FLE syntax of a file -To load and validate the FLE formated file (`myActivation.txt`: +To load and validate the FLE formatted file (`myActivation.txt`): ``` ./FLEcli load myActivation.txt diff --git a/doc/whats_new.md b/doc/whats_new.md index 239918e..d7c016f 100644 --- a/doc/whats_new.md +++ b/doc/whats_new.md @@ -1,6 +1,13 @@ # What's new? -## v0.1.2 +## v0.1.3 + +* Enable FLEcli to be used to generate CSV chaser logs +* Fix the display for longer calls (issue #61) + +## Previous releases + +### v0.1.2 * DATE keyword is now optional * Date can have several delimiter ("-", "/", ".", or " ") @@ -11,8 +18,6 @@ * Time is now correctly inferred when start and end of gap is in the same minute * Correct some typos and bugs -## Previous releases - ### v0.1.1 * Improved test coverage * Improved build automation diff --git a/fleprocess/csv_process.go b/fleprocess/csv_process.go index 935ef48..6dc1489 100644 --- a/fleprocess/csv_process.go +++ b/fleprocess/csv_process.go @@ -59,9 +59,11 @@ func validateDataForSotaCsv(loadedLogFile []LogLine) error { return fmt.Errorf("No QSO found") } + isNoMySota := false //MySOTA and MyCall are header values. If missing on the first line, it will be missing at every line if loadedLogFile[0].MySOTA == "" { - return fmt.Errorf("Missing MY-SOTA reference") + //if not set, we might be dealing with a chaser log + isNoMySota = true } if loadedLogFile[0].MyCall == "" { return fmt.Errorf("Missing MyCall") @@ -109,6 +111,21 @@ func validateDataForSotaCsv(loadedLogFile []LogLine) error { } errorsBuffer.WriteString(fmt.Sprintf("missing QSO time %s", errorLocation)) } + //FIXME: if isNoMySota and MySota defined means that it was defined later in the log file + if (isNoMySota && loadedLogFile[i].MySOTA != "") { + if errorsBuffer.String() != "" { + errorsBuffer.WriteString(fmt.Sprintf(", ")) + } + errorsBuffer.WriteString(fmt.Sprintf("encountered an unexpexted MySota reference while processing what should be a chaser log %s", errorLocation)) + } + + + if (isNoMySota && loadedLogFile[i].SOTA == "") { + if errorsBuffer.String() != "" { + errorsBuffer.WriteString(fmt.Sprintf(", ")) + } + errorsBuffer.WriteString(fmt.Sprintf("missing SOTA reference while attempting to process chaser log %s", errorLocation)) + } } if errorsBuffer.String() != "" { return fmt.Errorf(errorsBuffer.String()) diff --git a/fleprocess/csv_process_test.go b/fleprocess/csv_process_test.go index c6d992f..238aa22 100644 --- a/fleprocess/csv_process_test.go +++ b/fleprocess/csv_process_test.go @@ -15,7 +15,7 @@ func Test_validateDataForSotaCsv(t *testing.T) { want error }{ { - "Happy Case", + "Happy Case (activator)", args{loadedLogFile: []LogLine{ {Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "time", Call: "call"}, {Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "time", Call: "call"}, @@ -23,6 +23,15 @@ func Test_validateDataForSotaCsv(t *testing.T) { }, nil, }, + { + "Happy Case (chaser)", + args{loadedLogFile: []LogLine{ + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call", SOTA: "Sota1"}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call", SOTA: "Sota2"}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call", SOTA: "Sota3"}}, + }, + nil, + }, { "Missing Date", args{loadedLogFile: []LogLine{ @@ -42,13 +51,31 @@ func Test_validateDataForSotaCsv(t *testing.T) { fmt.Errorf("Missing MyCall"), }, { - "Missing MySota", + "Neither Activator nor Chaser", + args{loadedLogFile: []LogLine{ + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:01", Call: "call"}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:02", Call: "call"}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:03", Call: "call"}}, + }, + fmt.Errorf("missing SOTA reference while attempting to process chaser log for log entry at 12:01 (#1), missing SOTA reference while attempting to process chaser log for log entry at 12:02 (#2), missing SOTA reference while attempting to process chaser log for log entry at 12:03 (#3)"), + }, + { + "SOTA Chaser log with one reference missing", + args{loadedLogFile: []LogLine{ + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:01", Call: "call", SOTA: "Sota1"}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:02", Call: "call"}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:03", Call: "call", SOTA: "Sota3"}}, + }, + fmt.Errorf("missing SOTA reference while attempting to process chaser log for log entry at 12:02 (#2)"), + }, + { + "SOTA Chaser log with mySota redefinition", args{loadedLogFile: []LogLine{ - {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call"}, - {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call"}, - {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "time", Call: "call"}}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:01", Call: "call", SOTA: "Sota1"}, + {Date: "date", MyCall: "myCall", MySOTA: "mySota", Mode: "mode", Band: "band", Time: "12:02", Call: "call", SOTA: "Sota2"}, + {Date: "date", MyCall: "myCall", MySOTA: "", Mode: "mode", Band: "band", Time: "12:03", Call: "call", SOTA: "Sota3"}}, }, - fmt.Errorf("Missing MY-SOTA reference"), + fmt.Errorf("encountered an unexpexted MySota reference while processing what should be a chaser log for log entry at 12:02 (#2)"), }, { "Misc. missing data (Band, Time, Mode, Call)", diff --git a/fleprocess/csv_write_test.go b/fleprocess/csv_write_test.go index 05ae6cb..1f1d589 100644 --- a/fleprocess/csv_write_test.go +++ b/fleprocess/csv_write_test.go @@ -61,13 +61,23 @@ func Test_buildCsv(t *testing.T) { {MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM", Nickname: "ONFF-0259-1", SOTA: "ON/ON-002"}, {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM", Comment: "QSL Message"}, } - //add case with no SOTA and with or no comment expectedOutput2 := []string{ "V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14MHz,CW,S57LC,ON/ON-002", "V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14MHz,CW,ON4LY,,QSL Message", } + //Chaser log + chaserLog := []LogLine{ + {MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", Operator: "ON4KJM", Nickname: "ONFF-0259-1", SOTA: "ON/ON-002"}, + {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", Operator: "ON4KJM", Comment: "QSL Message", SOTA: "ON/ON-003"}, + } + + expectedChaserOutput3 := []string{ + "V2,ON4KJM/P,,24/05/20,1310,14MHz,CW,S57LC,ON/ON-002", + "V2,ON4KJM/P,,24/05/20,1312,14MHz,CW,ON4LY,ON/ON-003,QSL Message", + } + type args struct { fullLog []LogLine } @@ -86,6 +96,11 @@ func Test_buildCsv(t *testing.T) { args{fullLog: sampleFilledLog2}, expectedOutput2, }, + { + "Chaser Log", + args{fullLog: chaserLog}, + expectedChaserOutput3, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {