Complete CSV output

pull/2/head
Jean-Marc MEESSEN 4 years ago
parent 7d903fb18c
commit ef2d33f20f

@ -1,4 +1,4 @@
package cmd
//VersionString is the version that will be displayed with the -v switch
const VersionString = "v0.0.0.0-4-g0716f45 (2020-07-13)"
const VersionString = "v0.0.0.0-6-g7d903fb (2020-07-14)"

@ -52,14 +52,6 @@ func init() {
func processAdifCommand() {
verifiedOutputFilename, filenameWasOK := buildOutputFilename(outputFilename, inputFilename, isOverwrite, ".adi")
fmt.Println("adif called")
fmt.Println("Inputfile: ", inputFilename)
fmt.Println("OutputFile: ", outputFilename)
fmt.Println("computed output: ", verifiedOutputFilename)
fmt.Println("Output filenameWasOK: ", filenameWasOK)
fmt.Println("wwff: ", isWWFFcli)
fmt.Println("sota: ", isSOTAcli)
fmt.Println("isOverwrite: ", isOverwrite)
// if the output file could not be parsed correctly do noting
if filenameWasOK {
@ -80,6 +72,12 @@ func processAdifCommand() {
return
}
}
if isSOTAcli {
if loadedLogFile[0].MySOTA == "" {
fmt.Println("Missing MY-SOTA reference. Aborting...")
return
}
}
outputAdif(verifiedOutputFilename, loadedLogFile, isWWFFcli, isSOTAcli)
}

@ -47,13 +47,7 @@ func init() {
func processCsvCommand() {
verifiedOutputFilename, filenameWasOK := buildOutputFilename(outputCsvFilename, inputFilename, isOverwrite, ".csv")
fmt.Println("csv called")
fmt.Println("Inputfile: ", inputFilename)
fmt.Println("OutputFile: ", outputFilename)
fmt.Println("computed output: ", verifiedOutputFilename)
fmt.Println("Output filenameWasOK: ", filenameWasOK)
fmt.Println("isOverwriteCsv: ", isOverwriteCsv)
verifiedOutputFilename, filenameWasOK := buildOutputFilename(outputCsvFilename, inputFilename, isOverwriteCsv, ".csv")
// if the output file could not be parsed correctly do noting
if filenameWasOK {
@ -66,14 +60,11 @@ func processCsvCommand() {
return
}
// //TODO: There are more tests required here
// //check if we have the necessary information for the type
// if isWWFFcli {
// if loadedLogFile[0].MyWWFF == "" {
// fmt.Println("Missing MY-WWFF reference. Aborting...")
// return
// }
// }
//check if we have the necessary information for the type
if loadedLogFile[0].MySOTA == "" {
fmt.Println("Missing MY-SOTA reference. Aborting...")
return
}
outputCsv(verifiedOutputFilename, loadedLogFile)
}

@ -46,7 +46,9 @@ func buildCsv(fullLog []LogLine) (csvList []string) {
csvLine.WriteString(fmt.Sprintf("%s,", logLine.MySOTA))
csvLine.WriteString(fmt.Sprintf("%s,", csvDate(logLine.Date)))
csvLine.WriteString(fmt.Sprintf("%s,", logLine.Time))
// adifLine.WriteString(adifElement("BAND", logLine.Band))
//TODO: Should we test the result
_, _, _, sotaBand := IsBand(logLine.Band)
csvLine.WriteString(fmt.Sprintf("%s,",sotaBand ))
csvLine.WriteString(fmt.Sprintf("%s,",logLine.Mode))
csvLine.WriteString(fmt.Sprintf("%s", logLine.Call))

@ -36,8 +36,8 @@ func Test_buildCsv(t *testing.T) {
}
expectedOutput1 := []string{
"V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14MHz,CW,S57LC",
"V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14MHz,CW,ON4LY",
"V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14Mhz,CW,S57LC",
"V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14Mhz,CW,ON4LY",
}
type args struct {

@ -119,7 +119,7 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
}
// Is it a band?
isBandElement, bandLowerLimit, bandUpperLimit := IsBand(element)
isBandElement, bandLowerLimit, bandUpperLimit, _ := IsBand(element)
if isBandElement {
logLine.Band = strings.ToLower(element)
logLine.BandLowerLimit = bandLowerLimit

@ -113,70 +113,70 @@ func ValidateDate(inputStr string) (ref, errorMsg string) {
}
//IsBand retuns true if the passed input string is a valid string
func IsBand(inputStr string) (result bool, lowerLimit, upperLimit float64) {
func IsBand(inputStr string) (result bool, lowerLimit, upperLimit float64, altBandName string) {
switch strings.ToLower(inputStr) {
case "2190m":
return true, 0.1357, 0.1378
return true, 0.1357, 0.1378, "tbd"
case "630m":
return true, 0.472, 0.479
return true, 0.472, 0.479, "tbd"
case "560m":
return true, 0.501, 0.504
return true, 0.501, 0.504, "tbd"
case "160m":
return true, 1.8, 2.0
return true, 1.8, 2.0, "1.8Mhz"
case "80m":
return true, 3.5, 4.0
return true, 3.5, 4.0, "3.5Mhz"
case "60m":
return true, 5.06, 5.45
return true, 5.06, 5.45, "5Mhz"
case "40m":
return true, 7.0, 7.3
return true, 7.0, 7.3, "7Mhz"
case "30m":
return true, 10.1, 10.15
return true, 10.1, 10.15, "10Mhz"
case "20m":
return true, 14.0, 14.35
return true, 14.0, 14.35, "14Mhz"
case "17m":
return true, 18.068, 18.168
return true, 18.068, 18.168, "18Mhz"
case "15m":
return true, 21.0, 21.45
return true, 21.0, 21.45, "21Mhz"
case "12m":
return true, 24.890, 24.99
return true, 24.890, 24.99, "24Mhz"
case "10m":
return true, 28.0, 29.7
return true, 28.0, 29.7, "28Mhz"
case "6m":
return true, 50, 54
return true, 50, 54, "50Mhz"
case "4m":
return true, 70, 71
return true, 70, 71, "70Mhz"
case "2m":
return true, 144, 148
return true, 144, 148, "144Mhz"
case "1.25m":
return true, 222, 225
return true, 222, 225, "222Mhz"
case "70cm":
return true, 420, 450
return true, 420, 450, "432Mhz"
case "33cm":
return true, 902, 928
return true, 902, 928, "tbd"
case "23cm":
return true, 1240, 1300
return true, 1240, 1300, "tbd"
case "13cm":
return true, 2300, 2450
return true, 2300, 2450, "tbd"
case "9cm":
return true, 3300, 3500
return true, 3300, 3500, "tbd"
case "6cm":
return true, 5650, 5925
return true, 5650, 5925, "tbd"
case "3cm":
return true, 10000, 10500
return true, 10000, 10500, "tbd"
case "1.25cm":
return true, 24000, 24250
return true, 24000, 24250, "tbd"
case "6mm":
return true, 47000, 47200
return true, 47000, 47200, "tbd"
case "4mm":
return true, 75500, 81000
return true, 75500, 81000, "tbd"
case "2.5mm":
return true, 119980, 120020
return true, 119980, 120020, "tbd"
case "2mm":
return true, 142000, 149000
return true, 142000, 149000, "tbd"
case "1mm":
return true, 241000, 250000
return true, 241000, 250000, "tbd"
}
return false, 0, 0
return false, 0, 0, ""
}
func getDefaultReport(mode string) (modeType, defaultReport string) {

@ -266,6 +266,8 @@ func TestValidateDate(t *testing.T) {
}
}
func TestIsBand(t *testing.T) {
type args struct {
inputStr string
@ -276,26 +278,27 @@ func TestIsBand(t *testing.T) {
wantResult bool
wantLowerLimit float64
wantUpperLimit float64
wantAltBandName string
}{
{
"invalid band",
args{inputStr: "zzzz"},
false, 0, 0,
false, 0, 0, "",
},
{
"valid band",
args{inputStr: "40m"},
true, 7.0, 7.3,
true, 7.0, 7.3, "7Mhz",
},
{
"valid band but uppercase",
args{inputStr: "40M"},
true, 7.0, 7.3,
true, 7.0, 7.3,"7Mhz",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotResult, gotLowerLimit, gotUpperLimit := IsBand(tt.args.inputStr)
gotResult, gotLowerLimit, gotUpperLimit, gotAltBandName := IsBand(tt.args.inputStr)
if gotResult != tt.wantResult {
t.Errorf("IsBand() gotResult = %v, want %v", gotResult, tt.wantResult)
}
@ -305,6 +308,9 @@ func TestIsBand(t *testing.T) {
if gotUpperLimit != tt.wantUpperLimit {
t.Errorf("IsBand() gotUpperLimit = %v, want %v", gotUpperLimit, tt.wantUpperLimit)
}
if gotAltBandName != tt.wantAltBandName {
t.Errorf("IsBand() gotAltBandName = %v, want %v", gotAltBandName, tt.wantAltBandName)
}
})
}
}

@ -2,6 +2,7 @@
mycall on4kjm/p
operator on4kjm
mywwff onff-0259
mysota ON/ON-001
nickname ONFF-0259-1
# Log

Loading…
Cancel
Save