Skip to content

Commit

Permalink
add a new option to ignore the timestamp coming from a spot source
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed Dec 3, 2023
1 parent 21dea80 commit 9e7da11
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,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, c.configuration.SpotLifetime())
c.Clusters = cluster.NewClusters(c.configuration.SpotSources(), c.Bandmap, c.bandplan, c.dxccFinder)
c.Clusters = cluster.NewClusters(c.configuration.SpotSources(), c.Bandmap, c.bandplan, c.dxccFinder, c.clock)
c.Entry = entry.NewController(
c.Settings,
c.clock,
Expand Down
16 changes: 11 additions & 5 deletions core/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Clusters struct {
myContinent string
}

func NewClusters(sources []core.SpotSource, bandmap Bandmap, bandplan bandplan.Bandplan, entities DXCCFinder) *Clusters {
func NewClusters(sources []core.SpotSource, bandmap Bandmap, bandplan bandplan.Bandplan, entities DXCCFinder, clock core.Clock) *Clusters {
result := &Clusters{
clusters: make([]*cluster, 0, len(sources)),
bandmap: bandmap,
Expand All @@ -57,9 +57,9 @@ func NewClusters(sources []core.SpotSource, bandmap Bandmap, bandplan bandplan.B
for _, spotSource := range sources {
var cluster *cluster
if isDemoSource(spotSource.Name) {
cluster = newDemoCluster(result, spotSource, bandmap, bandplan)
cluster = newDemoCluster(result, spotSource, bandmap, bandplan, clock)
} else {
cluster = newCluster(result, spotSource, bandmap, bandplan)
cluster = newCluster(result, spotSource, bandmap, bandplan, clock)
}
result.clusters = append(result.clusters, cluster)
}
Expand Down Expand Up @@ -179,17 +179,19 @@ type cluster struct {
source core.SpotSource
bandmap Bandmap
bandplan bandplan.Bandplan
clock core.Clock

client clusterClient
openCluster openClusterFunc
}

func newCluster(parent *Clusters, source core.SpotSource, bandmap Bandmap, bandplan bandplan.Bandplan) *cluster {
func newCluster(parent *Clusters, source core.SpotSource, bandmap Bandmap, bandplan bandplan.Bandplan, clock core.Clock) *cluster {
return &cluster{
parent: parent,
source: source,
bandmap: bandmap,
bandplan: bandplan,
clock: clock,

openCluster: openClusterix,
}
Expand Down Expand Up @@ -250,6 +252,9 @@ func (c *cluster) DX(msg clusterix.DXMessage) {
Time: msg.Time,
Source: c.source.Type,
}
if c.source.IgnoreTimestamp {
spot.Time = c.clock.Now()
}
c.bandmap.Add(spot)
}

Expand Down Expand Up @@ -334,12 +339,13 @@ func toCoreBand(bandName bandplan.BandName) core.Band {
return core.Band(bandName)
}

func newDemoCluster(parent *Clusters, source core.SpotSource, bandmap Bandmap, bandplan bandplan.Bandplan) *cluster {
func newDemoCluster(parent *Clusters, source core.SpotSource, bandmap Bandmap, bandplan bandplan.Bandplan, clock core.Clock) *cluster {
return &cluster{
parent: parent,
source: source,
bandmap: bandmap,
bandplan: bandplan,
clock: clock,

openCluster: openDemoCluster(bandmap),
}
Expand Down
13 changes: 7 additions & 6 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,13 @@ const (
)

type SpotSource struct {
Name string `json:"name"`
Type SpotType `json:"type"`
HostAddress string `json:"host_address"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
Filter SpotFilter `json:"filter,omitempty"`
Name string `json:"name"`
Type SpotType `json:"type"`
HostAddress string `json:"host_address"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
Filter SpotFilter `json:"filter,omitempty"`
IgnoreTimestamp bool `json:"ignore_timestamp,omitempty"`
}

type Spot struct {
Expand Down

0 comments on commit 9e7da11

Please sign in to comment.