Add default RST

pull/2/head
Jean-Marc MEESSEN 5 years ago
parent 3867a0eb5f
commit 34f214bd43

@ -40,6 +40,8 @@ type LogLine struct {
QSLmsg string QSLmsg string
OMname string OMname string
GridLoc string GridLoc string
RSTsent string
RSTrcvd string
} }
var regexpIsBand = regexp.MustCompile("m$") var regexpIsBand = regexp.MustCompile("m$")
@ -52,7 +54,13 @@ var regexpIsGridLoc = regexp.MustCompile("^#")
func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string){ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg string){
//TODO: input null protection? //TODO: input null protection?
//Flag telling that we are processing data to the right of the callsign
//isRightOfCall := false
//TODO: Make something more intelligent //TODO: Make something more intelligent
previousLine.Call = ""
previousLine.RSTsent = ""
previousLine.RSTrcvd = ""
logLine = previousLine logLine = previousLine
//TODO: what happens when we have <> or when there are multiple comments //TODO: what happens when we have <> or when there are multiple comments
@ -77,6 +85,23 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
// Is it a mode? // Is it a mode?
if lookupMode( strings.ToUpper(element)) { if lookupMode( strings.ToUpper(element)) {
logLine.Mode = strings.ToUpper(element) logLine.Mode = strings.ToUpper(element)
// Set the default RST depending of the mode
if (logLine.RSTsent == "") || (logLine.RSTrcvd == "") {
switch logLine.Mode {
case "SSB", "AM", "FM" :
logLine.RSTsent = "59"
logLine.RSTrcvd = "59"
case "CW", "RTTY", "PSK":
logLine.RSTsent = "599"
logLine.RSTrcvd = "599"
case "JT65", "JT9", "JT6M", "JT4", "JT44", "FSK441", "FT8", "ISCAT", "MSK144", "QRA64", "T10", "WSPR" :
logLine.RSTsent = "-10"
logLine.RSTrcvd = "-10"
}
} else {
errorMsg = errorMsg + "Double definitiion of RST"
}
continue continue
} }
@ -91,6 +116,7 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
callErrorMsg := "" callErrorMsg := ""
logLine.Call, callErrorMsg = ValidateCall(element) logLine.Call, callErrorMsg = ValidateCall(element)
errorMsg = errorMsg + callErrorMsg errorMsg = errorMsg + callErrorMsg
//isRightOfCall = true
continue continue
} }
@ -155,6 +181,8 @@ func SprintLogRecord(logLine LogLine) (output string){
output = output + "QSLmsg " + logLine.QSLmsg + "\n" output = output + "QSLmsg " + logLine.QSLmsg + "\n"
output = output + "OMname " + logLine.OMname + "\n" output = output + "OMname " + logLine.OMname + "\n"
output = output + "GridLoc " + logLine.GridLoc + "\n" output = output + "GridLoc " + logLine.GridLoc + "\n"
output = output + "RSTsent " + logLine.RSTsent + "\n"
output = output + "RSTrcvd " + logLine.RSTrcvd + "\n"
return output return output
} }

@ -20,7 +20,7 @@ func TestParseLine(t *testing.T) {
{ {
"Parse band and mode only", "Parse band and mode only",
args{ inputStr: "40m cw", previousLine: LogLine{ Mode: "SSB", }}, args{ inputStr: "40m cw", previousLine: LogLine{ Mode: "SSB", }},
LogLine{ Band: "40m", Mode: "CW",}, "", LogLine{ Band: "40m", Mode: "CW", RSTsent: "599", RSTrcvd: "599"}, "",
}, },
{ {
"Parse for time", "Parse for time",

@ -13,4 +13,4 @@ date 2020-05-23
7.025 0958 iz2bzt 9 5 7.025 0958 iz2bzt 9 5
7.037 1012 on6zq 9 449 7.037 1012 on6zq 9 449
1020 dk5zx 9 7 1020 dk5zx 9 7
30m cw

Loading…
Cancel
Save