Skip to content

Commit

Permalink
make the lifetime of spots configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed May 19, 2023
1 parent 413e344 commit a5153e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/ftl/hamradio/bandplan"
"github.com/ftl/hamradio/cwclient"
Expand Down Expand Up @@ -104,6 +105,7 @@ type Configuration interface {
KeyerPort() int
HamlibAddress() string
TCIAddress() string
SpotLifetime() time.Duration
SpotSources() []core.SpotSource
}

Expand Down Expand Up @@ -141,7 +143,7 @@ func (c *Controller) Startup() {

c.Score = score.NewCounter(c.Settings, c.dxccFinder)
c.QSOList = logbook.NewQSOList(c.Settings, c.Score)
c.Bandmap = bandmap.NewBandmap(c.clock, c.Settings, c.QSOList, bandmap.DefaultUpdatePeriod, bandmap.DefaultMaximumAge)
c.Bandmap = bandmap.NewBandmap(c.clock, c.Settings, c.QSOList, bandmap.DefaultUpdatePeriod, c.configuration.SpotLifetime())
c.Clusters = cluster.NewClusters(c.configuration.SpotSources(), c.Bandmap, c.bandplan, c.dxccFinder)
c.Entry = entry.NewController(
c.Settings,
Expand Down
13 changes: 13 additions & 0 deletions core/cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/ftl/hamradio/cfg"
"github.com/pkg/errors"
Expand All @@ -14,6 +15,7 @@ import (
)

const Filename = "hellocontest.json"
const DefaultSpotLifetime = 10 * time.Minute

var Default = Data{
LogDirectory: "$HOME/",
Expand Down Expand Up @@ -65,6 +67,7 @@ var Default = Data{
KeyerPort: 6789,
HamlibAddress: "localhost:4532",
TCIAddress: "localhost:40001",
SpotLifetime: "10m",
SpotSources: []core.SpotSource{
{
Name: "Skimmer",
Expand Down Expand Up @@ -127,6 +130,7 @@ type Data struct {
KeyerPort int `json:"keyer_port"`
HamlibAddress string `json:"hamlib_address"`
TCIAddress string `json:"tci_address"`
SpotLifetime string `json:"spot_lifetime"`
SpotSources []core.SpotSource `json:"spot_sources"`
}

Expand Down Expand Up @@ -181,6 +185,15 @@ func (c *LoadedConfiguration) TCIAddress() string {
return c.data.TCIAddress
}

func (c *LoadedConfiguration) SpotLifetime() time.Duration {
result, err := time.ParseDuration(c.data.SpotLifetime)
if err != nil {
log.Printf("cannot parse spot lifetime: %v", err)
return DefaultSpotLifetime
}
return result
}

func (c *LoadedConfiguration) SpotSources() []core.SpotSource {
return c.data.SpotSources
}

0 comments on commit a5153e6

Please sign in to comment.