QRG rounding (#75)

* support frequency up to the 100hz while default resolution is to the Khz
pull/76/head
Jean-Marc MEESSEN 3 years ago committed by GitHub
parent 61c42d1c75
commit fe7836fdb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -150,7 +150,6 @@ func Test_validateDataforAdif2(t *testing.T) {
}
}
func TestProcessAdifCommand(t *testing.T) {
type args struct {
adifParams AdifParams
@ -164,10 +163,10 @@ func TestProcessAdifCommand(t *testing.T) {
"Bad output filename (directory)",
args{
adifParams: AdifParams{
InputFilename: "../test/data/fle-4-no-qso.txt",
OutputFilename: "../test/data",
InputFilename: "../test/data/fle-4-no-qso.txt",
OutputFilename: "../test/data",
IsInterpolateTime: false,
IsOverwrite: false,
IsOverwrite: false,
},
},
true,
@ -176,10 +175,10 @@ func TestProcessAdifCommand(t *testing.T) {
"input file parsing errors (missing band)",
args{
adifParams: AdifParams{
InputFilename: "../test/data/fle-3-error.txt",
OutputFilename: "",
InputFilename: "../test/data/fle-3-error.txt",
OutputFilename: "",
IsInterpolateTime: false,
IsOverwrite: false,
IsOverwrite: false,
},
},
true,
@ -188,10 +187,10 @@ func TestProcessAdifCommand(t *testing.T) {
"input file parsing errors (wrong call)",
args{
adifParams: AdifParams{
InputFilename: "../test/data/fle-5-wrong-call.txt",
OutputFilename: "",
InputFilename: "../test/data/fle-5-wrong-call.txt",
OutputFilename: "",
IsInterpolateTime: false,
IsOverwrite: false,
IsOverwrite: false,
},
},
true,
@ -200,10 +199,10 @@ func TestProcessAdifCommand(t *testing.T) {
"No QSO in loaded file",
args{
adifParams: AdifParams{
InputFilename: "../test/data/fle-4-no-qso.txt",
OutputFilename: "",
InputFilename: "../test/data/fle-4-no-qso.txt",
OutputFilename: "",
IsInterpolateTime: false,
IsOverwrite: false,
IsOverwrite: false,
},
},
true,

@ -108,7 +108,6 @@ func Test_buildAdif(t *testing.T) {
"<STATION_CALLSIGN:8>ON4KJM/P <CALL:5>ON4LY <QSO_DATE:8>20200524 <TIME_ON:4>1312 <BAND:3>20m <MODE:2>CW <RST_SENT:3>559 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:8>ON-00259 <OPERATOR:6>ON4KJM <EOR>",
}
sampleFilledLogPOTA2 := []LogLine{
{MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", MyGrid: "JO40eu", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", GridLoc: "JO50", MyPOTA: "ON-00259", Operator: "ON4KJM", Nickname: "ON-00259-1"},
{MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", MyGrid: "JO40eu", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MyPOTA: "ON-00259", Operator: "ON4KJM", POTA: "DL-00001"},
@ -124,7 +123,7 @@ func Test_buildAdif(t *testing.T) {
}
type args struct {
fullLog []LogLine
fullLog []LogLine
adifParams AdifParams
}
tests := []struct {
@ -135,7 +134,7 @@ func Test_buildAdif(t *testing.T) {
{
"Happy case-WWFF",
args{
fullLog: sampleFilledLog1,
fullLog: sampleFilledLog1,
adifParams: AdifParams{IsWWFF: true, IsSOTA: false},
},
expectedOutput1,
@ -143,7 +142,7 @@ func Test_buildAdif(t *testing.T) {
{
"Happy case-POTA",
args{
fullLog: sampleFilledLogPOTA,
fullLog: sampleFilledLogPOTA,
adifParams: AdifParams{IsPOTA: true},
},
expectedOutputPOTA,
@ -151,14 +150,14 @@ func Test_buildAdif(t *testing.T) {
{
"Happy case-Grid",
args{fullLog: sampleFilledLog2,
adifParams: AdifParams{IsWWFF: true, IsSOTA: false},
adifParams: AdifParams{IsWWFF: true, IsSOTA: false},
},
expectedOutput2,
},
{
"Happy case-WWFF2WWFF",
args{
fullLog: sampleFilledLog3,
fullLog: sampleFilledLog3,
adifParams: AdifParams{IsWWFF: true},
},
expectedOutput3,
@ -166,7 +165,7 @@ func Test_buildAdif(t *testing.T) {
{
"Happy case-POTA2POTA",
args{
fullLog: sampleFilledLogPOTA2,
fullLog: sampleFilledLogPOTA2,
adifParams: AdifParams{IsPOTA: true},
},
expectedOutputPOTA2,

@ -21,7 +21,6 @@ import (
"regexp"
"strconv"
"strings"
//"fmt"
)
// LogLine is used to store all the data of a single log line
@ -70,6 +69,7 @@ var regexpDatePattern = regexp.MustCompile(`^(\d{2}|\d{4})[-/ .]\d{1,2}[-/ .]\d{
var regexpIsDateKeyWord = regexp.MustCompile(`(?i)^date$`)
var regexpDayIncrementPattern = regexp.MustCompile(`^\+*$`)
var regexpIsDayKeyword = regexp.MustCompile(`(?i)^day$`)
var regexpKhzPartOfQrg = regexp.MustCompile(`\.\d+`)
// ParseLine cuts a FLE line into useful bits
func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string) {
@ -174,17 +174,26 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
logLine.Band = strings.ToLower(element)
logLine.BandLowerLimit = bandLowerLimit
logLine.BandUpperLimit = bandUpperLimit
//As a new band is defined, we reset the stored frequency (from previous lines)
// This assumes that the band is defined before frequency
logLine.Frequency = ""
continue
}
// Is it a Frequency?
if regexpIsFreq.MatchString(element) {
khzPart := regexpKhzPartOfQrg.FindStringSubmatch(element)
var qrg float64
qrg, _ = strconv.ParseFloat(element, 32)
if (logLine.BandLowerLimit != 0.0) && (logLine.BandUpperLimit != 0.0) {
if (qrg >= logLine.BandLowerLimit) && (qrg <= logLine.BandUpperLimit) {
//TODO: print 3f or more is available
logLine.Frequency = fmt.Sprintf("%.3f", qrg)
//Increase precision to half Khz if data is available
if len(khzPart[0]) > 4 {
//The "." is part of the returned string
logLine.Frequency = fmt.Sprintf("%.4f", qrg)
} else {
logLine.Frequency = fmt.Sprintf("%.3f", qrg)
}
} else {
logLine.Frequency = ""
errorMsg = errorMsg + "Frequency [" + element + "] is invalid for " + logLine.Band + " band."
@ -196,7 +205,7 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
}
// Is it a call sign ?
//FIXME:
//FIXME: (don't remember what)
if validCallRegexp.MatchString(strings.ToUpper(element)) {
//If it starts with "#",it is a grid definition and not a call
if element[0] != '#' {

@ -98,6 +98,11 @@ func TestParseLine(t *testing.T) {
args{inputStr: "14.153 on4kjm", previousLine: LogLine{Mode: "SSB", Band: "20m", BandLowerLimit: 14.0, BandUpperLimit: 14.35}},
LogLine{Band: "20m", BandLowerLimit: 14.0, BandUpperLimit: 14.35, Frequency: "14.153", Call: "ON4KJM", Mode: "SSB", RSTsent: "59", RSTrcvd: "59"}, "",
},
{
"Parse frequency (0.5 Khz)",
args{inputStr: "14.1535 on4kjm", previousLine: LogLine{Mode: "SSB", Band: "20m", BandLowerLimit: 14.0, BandUpperLimit: 14.35}},
LogLine{Band: "20m", BandLowerLimit: 14.0, BandUpperLimit: 14.35, Frequency: "14.1535", Call: "ON4KJM", Mode: "SSB", RSTsent: "59", RSTrcvd: "59"}, "",
},
{
"Parse frequency out of limit",
args{inputStr: "14.453 on4kjm", previousLine: LogLine{Mode: "SSB", Band: "20m", BandLowerLimit: 14.0, BandUpperLimit: 14.35}},

@ -14,7 +14,7 @@ date 2016-04-24
8 gw0tlk/m
date 2016-06-03
40m cw
40m 7.0356 cw
1404 gm0aaa 3 7
5 on4ck/p 2
7 dl0dan/p

@ -6,7 +6,7 @@ ADIF Export for Fast Log Entry by DF3CB
<STATION_CALLSIGN:5>G3WGV <CALL:5>G3NOH <QSO_DATE:8>20160424 <TIME_ON:4>1204 <BAND:3>40m <MODE:2>CW <RST_SENT:3>599 <RST_RCVD:3>599 <COMMENT:14>PSE QSL Direct <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:6>GW4GTE <QSO_DATE:8>20160424 <TIME_ON:4>1227 <BAND:2>2m <MODE:2>FM <RST_SENT:2>59 <RST_RCVD:2>59 <COMMENT:4>Dave <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:8>GW0TLK/M <QSO_DATE:8>20160424 <TIME_ON:4>1228 <BAND:2>2m <MODE:2>FM <RST_SENT:2>59 <RST_RCVD:2>59 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:6>GM0AAA <QSO_DATE:8>20160603 <TIME_ON:4>1404 <BAND:3>40m <MODE:2>CW <RST_SENT:3>539 <RST_RCVD:3>579 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:7>ON4CK/P <QSO_DATE:8>20160603 <TIME_ON:4>1405 <BAND:3>40m <MODE:2>CW <RST_SENT:3>529 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:8>DL0DAN/P <QSO_DATE:8>20160603 <TIME_ON:4>1407 <BAND:3>40m <MODE:2>CW <RST_SENT:3>599 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:6>GM0AAA <QSO_DATE:8>20160603 <TIME_ON:4>1404 <BAND:3>40m <MODE:2>CW <FREQ:6>7.0356 <RST_SENT:3>539 <RST_RCVD:3>579 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:7>ON4CK/P <QSO_DATE:8>20160603 <TIME_ON:4>1405 <BAND:3>40m <MODE:2>CW <FREQ:6>7.0356 <RST_SENT:3>529 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:8>DL0DAN/P <QSO_DATE:8>20160603 <TIME_ON:4>1407 <BAND:3>40m <MODE:2>CW <FREQ:6>7.0356 <RST_SENT:3>599 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>
<STATION_CALLSIGN:5>G3WGV <CALL:5>YU7LS <QSO_DATE:8>20160603 <TIME_ON:4>1410 <BAND:3>20m <MODE:2>CW <RST_SENT:3>599 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:6>G-0014 <OPERATOR:5>G3WGV <EOR>

Loading…
Cancel
Save