up
This commit is contained in:
parent
40a6b71865
commit
6bef3f45cd
@ -25,6 +25,8 @@ type New struct {
|
||||
NewDXCC bool
|
||||
NewMode bool
|
||||
NewBand bool
|
||||
Worked bool
|
||||
MyCall bool
|
||||
}
|
||||
|
||||
type HTTPServer struct {
|
||||
@ -32,11 +34,11 @@ type HTTPServer struct {
|
||||
Log4OMRepo Log4OMContactsRepository
|
||||
Repo FlexDXClusterRepository
|
||||
Log *log.Logger
|
||||
FlexClient FlexClient
|
||||
TCPServer TCPServer
|
||||
SpotChanToHTTPServer chan TelnetSpot
|
||||
}
|
||||
|
||||
func NewHTTPServer(cRepo Log4OMContactsRepository, fRepo FlexDXClusterRepository, FlexClient *FlexClient, TCPServer *TCPServer, log *log.Logger) *HTTPServer {
|
||||
func NewHTTPServer(cRepo Log4OMContactsRepository, fRepo FlexDXClusterRepository, TCPServer *TCPServer, SpotChanToHTTPServer chan TelnetSpot, log *log.Logger) *HTTPServer {
|
||||
|
||||
gRouter := mux.NewRouter()
|
||||
|
||||
@ -45,8 +47,8 @@ func NewHTTPServer(cRepo Log4OMContactsRepository, fRepo FlexDXClusterRepository
|
||||
Log4OMRepo: cRepo,
|
||||
Repo: fRepo,
|
||||
Log: log,
|
||||
FlexClient: *FlexClient,
|
||||
TCPServer: *TCPServer,
|
||||
SpotChanToHTTPServer: SpotChanToHTTPServer,
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +65,7 @@ func (s *HTTPServer) SetRoutes() {
|
||||
func (s *HTTPServer) StartHTTPServer() {
|
||||
|
||||
go func() {
|
||||
for spot := range s.FlexClient.FlexSpotChan {
|
||||
for spot := range s.SpotChanToHTTPServer {
|
||||
s.GetListofNew(spot)
|
||||
}
|
||||
}()
|
||||
@ -105,7 +107,7 @@ func (s *HTTPServer) GetNew(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl.ExecuteTemplate(w, "new", listNew)
|
||||
}
|
||||
|
||||
func (s *HTTPServer) GetListofNew(spot FlexSpot) {
|
||||
func (s *HTTPServer) GetListofNew(spot TelnetSpot) {
|
||||
new := New{}
|
||||
|
||||
new.DX = spot.DX
|
||||
|
12
TCPClient.go
12
TCPClient.go
@ -25,26 +25,26 @@ type TCPClient struct {
|
||||
Writer *bufio.Writer
|
||||
Conn *net.TCPConn
|
||||
TCPServer TCPServer
|
||||
FlexClient FlexClient
|
||||
MsgChan chan string
|
||||
CmdChan chan string
|
||||
SpotChan chan TelnetSpot
|
||||
SpotChanToFlex chan TelnetSpot
|
||||
SpotChanToHTTPServer chan TelnetSpot
|
||||
Log *log.Logger
|
||||
Config *Config
|
||||
Countries Countries
|
||||
}
|
||||
|
||||
func NewTCPClient(TCPServer *TCPServer, FlexClient *FlexClient, log *log.Logger, Countries Countries) *TCPClient {
|
||||
func NewTCPClient(TCPServer *TCPServer, log *log.Logger, Countries Countries) *TCPClient {
|
||||
return &TCPClient{
|
||||
Address: Cfg.Cluster.Server,
|
||||
Port: Cfg.Cluster.Port,
|
||||
Login: Cfg.Cluster.Login,
|
||||
MsgChan: TCPServer.MsgChan,
|
||||
CmdChan: TCPServer.CmdChan,
|
||||
SpotChan: FlexClient.SpotChan,
|
||||
SpotChanToFlex: make(chan TelnetSpot, 100),
|
||||
Log: log,
|
||||
TCPServer: *TCPServer,
|
||||
FlexClient: *FlexClient,
|
||||
SpotChanToHTTPServer: make(chan TelnetSpot, 100),
|
||||
Countries: Countries,
|
||||
}
|
||||
}
|
||||
@ -151,7 +151,7 @@ func (c *TCPClient) ReadLine() {
|
||||
}
|
||||
|
||||
// start := time.Now()
|
||||
go ProcessTelnetSpot(spotRe, message, c.SpotChan, c.Countries)
|
||||
go ProcessTelnetSpot(spotRe, message, c.SpotChanToFlex, c.SpotChanToHTTPServer, c.Countries)
|
||||
// elapsed := time.Since(start)
|
||||
// Log.Infof("Total time for processing spot: %s", elapsed)
|
||||
|
||||
|
15
flexradio.go
15
flexradio.go
@ -45,20 +45,18 @@ type FlexClient struct {
|
||||
Reader *bufio.Reader
|
||||
Writer *bufio.Writer
|
||||
Conn *net.TCPConn
|
||||
SpotChan chan TelnetSpot
|
||||
SpotChanToFlex chan TelnetSpot
|
||||
MsgChan chan string
|
||||
FlexSpotChan chan FlexSpot
|
||||
Repo FlexDXClusterRepository
|
||||
TCPServer *TCPServer
|
||||
IsConnected bool
|
||||
}
|
||||
|
||||
func NewFlexClient(repo FlexDXClusterRepository, TCPServer *TCPServer) *FlexClient {
|
||||
func NewFlexClient(repo FlexDXClusterRepository, TCPServer *TCPServer, SpotChanToFlex chan TelnetSpot) *FlexClient {
|
||||
return &FlexClient{
|
||||
Address: Cfg.Flex.IP,
|
||||
Port: "4992",
|
||||
SpotChan: make(chan TelnetSpot, 100),
|
||||
FlexSpotChan: make(chan FlexSpot, 100),
|
||||
SpotChanToFlex: SpotChanToFlex,
|
||||
MsgChan: TCPServer.MsgChan,
|
||||
Repo: repo,
|
||||
TCPServer: TCPServer,
|
||||
@ -91,7 +89,7 @@ func (fc *FlexClient) StartFlexClient() {
|
||||
fc.IsConnected = true
|
||||
|
||||
go func() {
|
||||
for message := range fc.SpotChan {
|
||||
for message := range fc.SpotChanToFlex {
|
||||
fc.SendSpottoFlex(message)
|
||||
}
|
||||
}()
|
||||
@ -188,11 +186,6 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) {
|
||||
Log.Debugf("could not find the DX in the database: ", err)
|
||||
}
|
||||
|
||||
// send FlexSpot to HTTP Server
|
||||
if Cfg.General.HTTPServer {
|
||||
fc.FlexSpotChan <- flexSpot
|
||||
}
|
||||
|
||||
var stringSpot string
|
||||
if srcFlexSpot.DX == "" {
|
||||
fc.Repo.CreateSpot(flexSpot)
|
||||
|
10
main.go
10
main.go
@ -67,15 +67,17 @@ func main() {
|
||||
defer cRepo.db.Close()
|
||||
|
||||
TCPServer := NewTCPServer(cfg.TelnetServer.Host, cfg.TelnetServer.Port, log)
|
||||
|
||||
FlexClient := NewFlexClient(*fRepo, TCPServer)
|
||||
TCPClient := NewTCPClient(TCPServer, FlexClient, log, Countries)
|
||||
HTTPServer := NewHTTPServer(*cRepo, *fRepo, FlexClient, TCPServer, log)
|
||||
TCPClient := NewTCPClient(TCPServer, log, Countries)
|
||||
FlexClient := NewFlexClient(*fRepo, TCPServer, TCPClient.SpotChanToFlex)
|
||||
HTTPServer := NewHTTPServer(*cRepo, *fRepo, TCPServer, TCPClient.SpotChanToHTTPServer, log)
|
||||
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
|
||||
|
||||
if Cfg.General.FlexRadioSpot {
|
||||
go FlexClient.StartFlexClient()
|
||||
}
|
||||
|
||||
go TCPClient.StartClient()
|
||||
go TCPServer.StartServer()
|
||||
|
||||
|
13
spot.go
13
spot.go
@ -25,7 +25,7 @@ type TelnetSpot struct {
|
||||
CallsignWorked bool
|
||||
}
|
||||
|
||||
func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSpot, Countries Countries) {
|
||||
func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan TelnetSpot, SpotChanToHTTPServer chan TelnetSpot, Countries Countries) {
|
||||
match := re.FindStringSubmatch(spotRaw)
|
||||
|
||||
if len(match) != 0 {
|
||||
@ -76,7 +76,14 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp
|
||||
}
|
||||
|
||||
// send spot to SpotChan to Flex Client to send the spot to Flex radio
|
||||
SpotChan <- spot
|
||||
if Cfg.General.FlexRadioSpot {
|
||||
SpotChanToFlex <- spot
|
||||
}
|
||||
|
||||
// send FlexSpot to HTTP Server
|
||||
if Cfg.General.HTTPServer {
|
||||
SpotChanToHTTPServer <- 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",
|
||||
@ -195,7 +202,7 @@ func (spot *TelnetSpot) GuessMode() {
|
||||
if freqInt >= 7074 && freqInt < 7078 {
|
||||
spot.Mode = "FT8"
|
||||
}
|
||||
if freqInt >= 7078 && freqInt <= 7200 {
|
||||
if freqInt >= 7078 && freqInt <= 7300 {
|
||||
spot.Mode = "LSB"
|
||||
}
|
||||
case "30M":
|
||||
|
Loading…
x
Reference in New Issue
Block a user