update dxcc
This commit is contained in:
139
spot.go
139
spot.go
@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -27,7 +27,7 @@ type TelnetSpot struct {
|
||||
CallsignWorked bool
|
||||
}
|
||||
|
||||
func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSpot, log *log.Logger) {
|
||||
func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSpot, log *log.Logger, Countries Countries) {
|
||||
match := re.FindStringSubmatch(spotRaw)
|
||||
|
||||
if len(match) != 0 {
|
||||
@ -40,9 +40,14 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp
|
||||
Time: match[6],
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
spot.DXCC = GetDXCC(spot.DX, Countries)
|
||||
elapsed := time.Since(start)
|
||||
Log.Infof("Loop for DXCC: %s", elapsed)
|
||||
|
||||
spot.GetBand()
|
||||
spot.GuessMode()
|
||||
spot.DXCC, _ = CheckClubogDXCC(spot.DX)
|
||||
|
||||
spot.CallsignWorked = false
|
||||
spot.NewBand = false
|
||||
spot.NewMode = false
|
||||
@ -52,10 +57,13 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp
|
||||
|
||||
defer contactRepo.db.Close()
|
||||
|
||||
start = time.Now()
|
||||
contacts, _ := contactRepo.ListByCountry(spot.DXCC)
|
||||
contactsMode, _ := contactRepo.ListByCountryMode(spot.DXCC, spot.Mode)
|
||||
contactsBand, _ := contactRepo.ListByCountryBand(spot.DXCC, spot.Band)
|
||||
contactsCall, _ := contactRepo.ListByCallSign(spot.DX, spot.Band, spot.Mode)
|
||||
elapsed = time.Since(start)
|
||||
Log.Infof("Elapsed db checking %s", elapsed)
|
||||
|
||||
if len(contacts) == 0 {
|
||||
switch spot.DXCC {
|
||||
@ -74,6 +82,9 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp
|
||||
spot.CallsignWorked = true
|
||||
}
|
||||
|
||||
// send spot to SpotChan to Flex Client to send the spot to Flex radio
|
||||
SpotChan <- spot
|
||||
|
||||
if spot.NewDXCC {
|
||||
log.Debugf("(** New DXCC **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - Command: %v, FlexSpot: %v",
|
||||
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.CommandNumber, spot.FlexSpotNumber)
|
||||
@ -103,10 +114,6 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp
|
||||
log.Debugf("DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
|
||||
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC)
|
||||
}
|
||||
|
||||
// send spot to SpotChan to Flex Client to send the spot to Flex radio
|
||||
SpotChan <- spot
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -169,27 +176,131 @@ func (spot *TelnetSpot) GuessMode() {
|
||||
if spot.Mode == "" {
|
||||
freqInt, err := strconv.ParseFloat(spot.Frequency, 32)
|
||||
if err != nil {
|
||||
fmt.Println("could not convert frequency string in float64:", err)
|
||||
Log.Errorf("could not convert frequency string in float64:", err)
|
||||
}
|
||||
|
||||
switch spot.Band {
|
||||
case "160M":
|
||||
if freqInt <= 1840 && freqInt >= 1800 {
|
||||
if freqInt >= 1800 && freqInt <= 1840 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 1840 && freqInt <= 1840 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
case "40M":
|
||||
if freqInt <= 7045.49 && freqInt >= 7000 {
|
||||
if freqInt >= 7000 && freqInt < 7045.5 {
|
||||
spot.Mode = "CW"
|
||||
} else if freqInt <= 7048.49 && freqInt >= 7045.49 {
|
||||
}
|
||||
if freqInt >= 7045.5 && freqInt < 7048.5 {
|
||||
spot.Mode = "FT4"
|
||||
} else if freqInt <= 7073.99 && freqInt > 7048.49 {
|
||||
}
|
||||
if freqInt >= 7048.5 && freqInt < 7074 {
|
||||
spot.Mode = "CW"
|
||||
} else if freqInt <= 7077 && freqInt > 7073.99 {
|
||||
}
|
||||
if freqInt >= 7074 && freqInt < 7078 {
|
||||
spot.Mode = "FT8"
|
||||
} else if freqInt <= 7200 && freqInt > 7077 {
|
||||
}
|
||||
if freqInt >= 7078 && freqInt <= 7200 {
|
||||
spot.Mode = "LSB"
|
||||
}
|
||||
case "30M":
|
||||
if freqInt >= 10100 && freqInt < 10130 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 10130 && freqInt < 10140 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 10140 && freqInt <= 10150 {
|
||||
spot.Mode = "FT4"
|
||||
}
|
||||
case "20M":
|
||||
if freqInt >= 14000 && freqInt < 14074 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 14074 && freqInt < 14078 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 14074 && freqInt < 14078 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 14078 && freqInt < 14083 {
|
||||
spot.Mode = "FT4"
|
||||
}
|
||||
if freqInt >= 14083 && freqInt < 14119 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 14119 && freqInt < 14350 {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
|
||||
case "17M":
|
||||
if freqInt >= 18068 && freqInt < 18095 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 18095 && freqInt < 18104 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 18104 && freqInt < 18108 {
|
||||
spot.Mode = "FT4"
|
||||
}
|
||||
if freqInt >= 18108 && freqInt <= 18168 {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
|
||||
case "15M":
|
||||
if freqInt >= 21000 && freqInt < 21074 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 21074 && freqInt < 21100 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 21100 && freqInt < 21140 {
|
||||
spot.Mode = "RTTY"
|
||||
}
|
||||
if freqInt >= 21140 && freqInt < 21144 {
|
||||
spot.Mode = "FT4"
|
||||
}
|
||||
if freqInt >= 21144 && freqInt <= 21450 {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
|
||||
case "12M":
|
||||
if freqInt >= 24890 && freqInt < 24915 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 24915 && freqInt < 24919 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 24919 && freqInt < 24930 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 24930 && freqInt <= 24990 {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
|
||||
case "10M":
|
||||
if freqInt >= 28000 && freqInt < 28074 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 28074 && freqInt < 28080 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 28080 && freqInt < 28100 {
|
||||
spot.Mode = "RTTY"
|
||||
}
|
||||
if freqInt >= 28100 && freqInt < 28300 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 28300 && freqInt < 29000 {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
if freqInt >= 29000 && freqInt <= 29700 {
|
||||
spot.Mode = "FM"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if spot.Mode == "" {
|
||||
Log.Infof("Could not identify mode for %s on %s", spot.DX, spot.Frequency)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user