@ -17,8 +17,11 @@ limitations under the License.
import (
import (
"fmt"
"regexp"
"regexp"
"strconv"
"strings"
"strings"
//"fmt"
)
)
//TODO: validate a record for minimal values
//TODO: validate a record for minimal values
@ -36,8 +39,8 @@ type LogLine struct {
Mode string
Mode string
ModeType string
ModeType string
Band string
Band string
BandLowerLimit float 32
BandLowerLimit float 64
BandUpperLimit float 32
BandUpperLimit float 64
Frequency string
Frequency string
Time string
Time string
Call string
Call string
@ -56,7 +59,7 @@ var regexpIsTimePart = regexp.MustCompile("^[0-5]{1}[0-9]{1}$|^[1-9]{1}$")
var regexpIsOMname = regexp . MustCompile ( "^@" )
var regexpIsOMname = regexp . MustCompile ( "^@" )
var regexpIsGridLoc = regexp . MustCompile ( "^#" )
var regexpIsGridLoc = regexp . MustCompile ( "^#" )
var regexpIsRst = regexp . MustCompile ( "^[\\d]{1,3}$" )
var regexpIsRst = regexp . MustCompile ( "^[\\d]{1,3}$" )
var regexpIsFreq = regexp . MustCompile ( "^[\\d]+ .[\\d]+$")
var regexpIsFreq = regexp . MustCompile ( "^[\\d]+ \\ .[\\d]+$")
// ParseLine cuts a FLE line into useful bits
// ParseLine cuts a FLE line into useful bits
func ParseLine ( inputStr string , previousLine LogLine ) ( logLine LogLine , errorMsg string ) {
func ParseLine ( inputStr string , previousLine LogLine ) ( logLine LogLine , errorMsg string ) {
@ -126,11 +129,18 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
// Is it a Frequency?
// Is it a Frequency?
if regexpIsFreq . MatchString ( element ) {
if regexpIsFreq . MatchString ( element ) {
//TODO: check if we are in the band limits (is a band defined?)
var qrg float64
//TODO: how do we handle/report errors
qrg , _ = strconv . ParseFloat ( element , 32 )
//TODO: take only 3 decimal digits
if ( logLine . BandLowerLimit != 0.0 ) && ( logLine . BandUpperLimit != 0.0 ) {
//TODO: update the column display
if ( qrg >= logLine . BandLowerLimit ) && ( qrg <= logLine . BandUpperLimit ) {
logLine . Frequency = element
logLine . Frequency = fmt . Sprintf ( "%.3f" , qrg )
} else {
logLine . Frequency = ""
errorMsg = errorMsg + " Frequency " + element + " is invalid for " + logLine . Band + " band"
}
} else {
errorMsg = errorMsg + " Unable to load frequency " + element + ": no band defined."
}
continue
continue
}
}
@ -242,6 +252,9 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
_ , logLine . RSTrcvd = getDefaultReport ( logLine . Mode )
_ , logLine . RSTrcvd = getDefaultReport ( logLine . Mode )
}
}
//For debug purposes
//fmt.Println("\n", SprintLogRecord(logLine))
return logLine , errorMsg
return logLine , errorMsg
}
}