better match dxcc
This commit is contained in:
parent
861a5ff14b
commit
10f936838f
BIN
FlexDXCluster.exe~
Normal file
BIN
FlexDXCluster.exe~
Normal file
Binary file not shown.
@ -149,7 +149,7 @@ func (c *TCPClient) ReadLine() {
|
||||
Log.Info("Start receiving spots")
|
||||
}
|
||||
|
||||
go ProcessTelnetSpot(spotRe, message, c.SpotChanToFlex, c.SpotChanToHTTPServer, c.Countries)
|
||||
ProcessTelnetSpot(spotRe, message, c.SpotChanToFlex, c.SpotChanToHTTPServer, c.Countries)
|
||||
|
||||
// Send the spot message to TCP server
|
||||
if len(c.TCPServer.Clients) > 0 {
|
||||
|
@ -1,7 +1,7 @@
|
||||
general:
|
||||
delete_log_file_at_start: true
|
||||
log_to_file: true
|
||||
log_level: INFO # INFO or DEBUG or WARN
|
||||
log_level: DEBUG # INFO or DEBUG or WARN
|
||||
httpserver: true # not in use for now
|
||||
telnetserver: true # not in use for now
|
||||
flexradiospot: true # not in use for now
|
||||
@ -13,7 +13,7 @@ cluster:
|
||||
port: 7300
|
||||
login: xv9q
|
||||
skimmer: true
|
||||
ft8: false
|
||||
ft8: true
|
||||
ft4: false
|
||||
command: #SET/NOFILTER
|
||||
login_prompt: "Please enter your call:"
|
||||
|
105
country.xml
105
country.xml
@ -1918,7 +1918,7 @@
|
||||
<EndDate>2007-12-31T23:59:59Z</EndDate>
|
||||
</CountryPrefix>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^OE.*</PrefixList>
|
||||
<PrefixList>^OE.*|^4U1A$</PrefixList>
|
||||
<StartDate>2007-12-31T23:59:59Z</StartDate>
|
||||
<EndDate xsi:nil="true" />
|
||||
</CountryPrefix>
|
||||
@ -4883,33 +4883,6 @@
|
||||
</CountryPrefix>
|
||||
</CountryPrefixList>
|
||||
</Country>
|
||||
<Country>
|
||||
<ArrlPrefix>OK/D</ArrlPrefix>
|
||||
<Comment />
|
||||
<Continent>EU</Continent>
|
||||
<CountryName>Czechoslovakia</CountryName>
|
||||
<CqZone>15</CqZone>
|
||||
<CqZoneList>
|
||||
<int>15</int>
|
||||
</CqZoneList>
|
||||
<Dxcc>218</Dxcc>
|
||||
<ItuZone>28</ItuZone>
|
||||
<IaruRegion>1</IaruRegion>
|
||||
<ItuZoneList>
|
||||
<int>28</int>
|
||||
</ItuZoneList>
|
||||
<Latitude>50.1</Latitude>
|
||||
<Longitude>15.5</Longitude>
|
||||
<Active>false</Active>
|
||||
<CountryTag />
|
||||
<CountryPrefixList>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^OK.*|^OL.*|^OM.*</PrefixList>
|
||||
<StartDate xsi:nil="true" />
|
||||
<EndDate>1992-12-31T23:59:59Z</EndDate>
|
||||
</CountryPrefix>
|
||||
</CountryPrefixList>
|
||||
</Country>
|
||||
<Country>
|
||||
<ArrlPrefix>CR8/D</ArrlPrefix>
|
||||
<Comment />
|
||||
@ -6510,7 +6483,7 @@
|
||||
<EndDate>1992-02-29T23:59:59Z</EndDate>
|
||||
</CountryPrefix>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^F.*|^HW.*|^HX.*|^HY.*|^TH.*|^TM.*|^TP.*|^TQ.*|^TV.*|^TW.*</PrefixList>
|
||||
<PrefixList>^F1.*|^F2.*|^F3.*|^F4.*|^F5.*|^F6.*|^F7.*|^F8.*|^HW.*|^HX.*|^HY.*|^TH.*|^TM.*|^TP.*|^TQ.*|^TV.*|^TW.*</PrefixList>
|
||||
<StartDate>1992-02-29T23:59:59Z</StartDate>
|
||||
<EndDate xsi:nil="true" />
|
||||
</CountryPrefix>
|
||||
@ -8147,48 +8120,6 @@
|
||||
</CountryPrefix>
|
||||
</CountryPrefixList>
|
||||
</Country>
|
||||
<Country>
|
||||
<ArrlPrefix>I5</ArrlPrefix>
|
||||
<Comment />
|
||||
<Continent>AF</Continent>
|
||||
<CountryName>Italian Somali</CountryName>
|
||||
<CqZone>38</CqZone>
|
||||
<CqZoneList>
|
||||
<int>38</int>
|
||||
</CqZoneList>
|
||||
<Dxcc>115</Dxcc>
|
||||
<ItuZone>47</ItuZone>
|
||||
<IaruRegion>1</IaruRegion>
|
||||
<ItuZoneList>
|
||||
<int>47</int>
|
||||
</ItuZoneList>
|
||||
<Latitude>2.1</Latitude>
|
||||
<Longitude>45.4</Longitude>
|
||||
<Active>false</Active>
|
||||
<CountryTag />
|
||||
<CountryPrefixList>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^MD4.*|^MS4.*</PrefixList>
|
||||
<StartDate>1947-03-01T00:00:00Z</StartDate>
|
||||
<EndDate>1949-12-31T23:59:59Z</EndDate>
|
||||
</CountryPrefix>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^MS4.*</PrefixList>
|
||||
<StartDate>1949-12-31T23:59:59Z</StartDate>
|
||||
<EndDate>1950-02-01T00:00:00Z</EndDate>
|
||||
</CountryPrefix>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^I5.*|^MS4.*</PrefixList>
|
||||
<StartDate>1950-02-01T00:00:00Z</StartDate>
|
||||
<EndDate>1950-12-31T23:59:59Z</EndDate>
|
||||
</CountryPrefix>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^I5.*</PrefixList>
|
||||
<StartDate>1950-12-31T23:59:59Z</StartDate>
|
||||
<EndDate>1960-06-30T23:59:59Z</EndDate>
|
||||
</CountryPrefix>
|
||||
</CountryPrefixList>
|
||||
</Country>
|
||||
<Country>
|
||||
<ArrlPrefix>I</ArrlPrefix>
|
||||
<Comment />
|
||||
@ -14929,38 +14860,6 @@
|
||||
</CountryPrefix>
|
||||
</CountryPrefixList>
|
||||
</Country>
|
||||
<Country>
|
||||
<ArrlPrefix>CN2</ArrlPrefix>
|
||||
<Comment />
|
||||
<Continent>AF</Continent>
|
||||
<CountryName>Tangier</CountryName>
|
||||
<CqZone>33</CqZone>
|
||||
<CqZoneList>
|
||||
<int>33</int>
|
||||
</CqZoneList>
|
||||
<Dxcc>264</Dxcc>
|
||||
<ItuZone>37</ItuZone>
|
||||
<IaruRegion>1</IaruRegion>
|
||||
<ItuZoneList>
|
||||
<int>37</int>
|
||||
</ItuZoneList>
|
||||
<Latitude>35.7</Latitude>
|
||||
<Longitude>-5.8</Longitude>
|
||||
<Active>false</Active>
|
||||
<CountryTag />
|
||||
<CountryPrefixList>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^CN2.*|^EK1.*|^EK4.*</PrefixList>
|
||||
<StartDate xsi:nil="true" />
|
||||
<EndDate>1952-02-01T00:00:00Z</EndDate>
|
||||
</CountryPrefix>
|
||||
<CountryPrefix>
|
||||
<PrefixList>^CN2.*|^EK1.*|^EK4.*|^KT1.*|^WT1.*</PrefixList>
|
||||
<StartDate>1952-02-01T00:00:00Z</StartDate>
|
||||
<EndDate>1960-06-30T23:59:59Z</EndDate>
|
||||
</CountryPrefix>
|
||||
</CountryPrefixList>
|
||||
</Country>
|
||||
<Country>
|
||||
<ArrlPrefix>5H</ArrlPrefix>
|
||||
<Comment />
|
||||
|
@ -242,7 +242,7 @@ func (r *FlexDXClusterRepository) GetSpotters() []Spotter {
|
||||
|
||||
sList := []Spotter{}
|
||||
|
||||
rows, err := r.db.Query("select spotter, count(*) as occurences from spots group by spotter order by occurences desc, spotter limit 7")
|
||||
rows, err := r.db.Query("select spotter, count(*) as occurences from spots group by spotter order by occurences desc, spotter limit 15")
|
||||
|
||||
if err != nil {
|
||||
r.Log.Error(err)
|
||||
|
@ -83,6 +83,7 @@ func (fc *FlexClient) StartFlexClient() {
|
||||
Log.Infof("Found: %s with Nick: %s, Version: %s, Serial: %s - using IP: %s", d.Model, d.NickName, d.Version, d.Serial, d.IP)
|
||||
} else {
|
||||
Log.Errorln("Could not discover any FlexRadio on the network, please provide an IP address in the config file.")
|
||||
fc.StartFlexClient()
|
||||
}
|
||||
} else if Cfg.Flex.IP != "" {
|
||||
fc.Address = Cfg.Flex.IP
|
||||
|
2
main.go
2
main.go
@ -52,7 +52,7 @@ func main() {
|
||||
cfg := NewConfig(cfgPath)
|
||||
|
||||
log := NewLog()
|
||||
log.Info("config loaded.")
|
||||
log.Info("Running FlexDXCluster version 0.1")
|
||||
log.Infof("Callsign: %s", cfg.SQLite.Callsign)
|
||||
|
||||
DeleteDatabase("./flex.sqlite", log)
|
||||
|
54
spot.go
54
spot.go
@ -144,6 +144,11 @@ func (spot *TelnetSpot) GetBand() {
|
||||
if spot.Mode == "SSB" {
|
||||
spot.Mode = "LSB"
|
||||
}
|
||||
case strings.HasPrefix(spot.Frequency, "5."):
|
||||
spot.Band = "60M"
|
||||
if spot.Mode == "SSB" {
|
||||
spot.Mode = "LSB"
|
||||
}
|
||||
case strings.HasPrefix(spot.Frequency, "7"):
|
||||
spot.Band = "40M"
|
||||
if spot.Mode == "SSB" {
|
||||
@ -181,6 +186,11 @@ func (spot *TelnetSpot) GetBand() {
|
||||
if spot.Mode == "SSB" {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
case strings.HasPrefix(spot.Frequency, "50"):
|
||||
spot.Band = "6M"
|
||||
if spot.Mode == "SSB" {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
default:
|
||||
spot.Band = "N/A"
|
||||
}
|
||||
@ -198,9 +208,35 @@ func (spot *TelnetSpot) GuessMode() {
|
||||
if freqInt >= 1800 && freqInt <= 1840 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 1840 && freqInt <= 1840 {
|
||||
if freqInt >= 1840 && freqInt <= 1844 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
case "80M":
|
||||
if freqInt >= 3500 && freqInt < 3568 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 3568 && freqInt < 3573 {
|
||||
spot.Mode = "FT4"
|
||||
}
|
||||
if freqInt >= 3573 && freqInt < 3580 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 3580 && freqInt < 3600 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 3600 && freqInt <= 3800 {
|
||||
spot.Mode = "LSB"
|
||||
}
|
||||
case "60M":
|
||||
if freqInt >= 5351.5 && freqInt < 5354 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 5354 && freqInt < 5366 {
|
||||
spot.Mode = "LSB"
|
||||
}
|
||||
if freqInt >= 5366 && freqInt <= 5266.5 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
case "40M":
|
||||
if freqInt >= 7000 && freqInt < 7045.5 {
|
||||
spot.Mode = "CW"
|
||||
@ -311,6 +347,22 @@ func (spot *TelnetSpot) GuessMode() {
|
||||
if freqInt >= 29000 && freqInt <= 29700 {
|
||||
spot.Mode = "FM"
|
||||
}
|
||||
case "6M":
|
||||
if freqInt >= 50000 && freqInt < 50100 {
|
||||
spot.Mode = "CW"
|
||||
}
|
||||
if freqInt >= 50100 && freqInt < 50313 {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
if freqInt >= 50313 && freqInt < 50320 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 50320 && freqInt < 50400 {
|
||||
spot.Mode = "USB"
|
||||
}
|
||||
if freqInt >= 50400 && freqInt < +52000 {
|
||||
spot.Mode = "FM"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@
|
||||
<div class="font-bold text-gray-700 text-center text-4xl text-red-800" id="spotCount" hx-get="/spotscount" hx-trigger="every 1s" hx-swap="innerHTML"></div>
|
||||
</div>
|
||||
|
||||
<div class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 ml-4 mr-2" style="height: 17rem;">
|
||||
<div class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700 ml-4 mr-2" style="height: 34rem;">
|
||||
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Top Spotters</h5>
|
||||
<div class="font-normal text-gray-700 dark:text-gray-400" id="spotters" hx-get="/spotters" hx-trigger="every 1s" hx-swap="innerHTML"></div>
|
||||
</div>
|
||||
|
67
xml.go
67
xml.go
@ -5,6 +5,8 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
type Countries struct {
|
||||
@ -43,15 +45,24 @@ type CountryPrefix struct {
|
||||
EndDate string `xml:"EndDate"`
|
||||
}
|
||||
|
||||
type DXCC struct {
|
||||
Callsign string
|
||||
CountryName string
|
||||
DXCC string
|
||||
RegEx string
|
||||
RegExSplit []string
|
||||
RegExCharacters int
|
||||
Ended bool
|
||||
}
|
||||
|
||||
func LoadCountryFile() Countries {
|
||||
// Open our xmlFile
|
||||
xmlFile, err := os.Open("country.xml")
|
||||
// if we os.Open returns an error then handle it
|
||||
if err != nil {
|
||||
Log.Errorln(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Log.Debugln("Successfully loaded country.xml")
|
||||
// defer the closing of our xmlFile so that we can parse it later on
|
||||
defer xmlFile.Close()
|
||||
|
||||
@ -65,14 +76,58 @@ func LoadCountryFile() Countries {
|
||||
}
|
||||
|
||||
func GetDXCC(dxCall string, Countries Countries) string {
|
||||
DXCCList := []DXCC{}
|
||||
d := DXCC{}
|
||||
|
||||
// Get all the matching DXCC for current callsign
|
||||
for i := 0; i < len(Countries.Countries); i++ {
|
||||
// for j := 0; j < len(Countries.Countries[i].CountryPrefixList.CountryPrefixList); j++ {
|
||||
regExp := regexp.MustCompile(Countries.Countries[i].CountryPrefixList.CountryPrefixList[len(Countries.Countries[i].CountryPrefixList.CountryPrefixList)-1].PrefixList)
|
||||
|
||||
match := regExp.FindStringSubmatch(dxCall)
|
||||
if len(match) != 0 {
|
||||
return Countries.Countries[i].Dxcc
|
||||
|
||||
d = DXCC{
|
||||
Callsign: dxCall,
|
||||
CountryName: Countries.Countries[i].CountryName,
|
||||
DXCC: Countries.Countries[i].Dxcc,
|
||||
RegEx: Countries.Countries[i].CountryPrefixList.CountryPrefixList[len(Countries.Countries[i].CountryPrefixList.CountryPrefixList)-1].PrefixList,
|
||||
}
|
||||
|
||||
if Countries.Countries[i].CountryPrefixList.CountryPrefixList[len(Countries.Countries[i].CountryPrefixList.CountryPrefixList)-1].EndDate == "" {
|
||||
d.Ended = false
|
||||
} else {
|
||||
d.Ended = true
|
||||
}
|
||||
|
||||
DXCCList = append(DXCCList, d)
|
||||
}
|
||||
// }
|
||||
}
|
||||
return ""
|
||||
|
||||
for i := 0; i < len(DXCCList); i++ {
|
||||
DXCCList[i].RegExSplit = strings.Split(DXCCList[i].RegEx, "|")
|
||||
|
||||
for j := 0; j < len(DXCCList[i].RegExSplit); j++ {
|
||||
regExp := regexp.MustCompile(DXCCList[i].RegExSplit[j])
|
||||
matched := regExp.FindStringSubmatch(dxCall)
|
||||
if len(matched) > 0 {
|
||||
DXCCList[i].RegExCharacters = utf8.RuneCountInString(DXCCList[i].RegExSplit[j])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DXCCMatch := DXCCList[0]
|
||||
higherMatch := DXCCList[0].RegExCharacters
|
||||
|
||||
if len(DXCCList) > 1 {
|
||||
for i := 0; i < len(DXCCList); i++ {
|
||||
if DXCCList[i].RegExCharacters > higherMatch && !DXCCList[i].Ended {
|
||||
DXCCMatch = DXCCList[i]
|
||||
higherMatch = DXCCList[i].RegExCharacters
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DXCCMatch = DXCCList[0]
|
||||
}
|
||||
|
||||
return DXCCMatch.DXCC
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user