From 942503180d9df06cf6380e80e9e670c15c32e6bf Mon Sep 17 00:00:00 2001 From: Florian Thienel Date: Thu, 30 May 2024 15:30:36 +0200 Subject: [PATCH] add the unweighted value to the value prediction of the current QSO --- core/app/app.go | 1 + core/bandmap/bandmap.go | 15 +++++--------- core/bandmap/entries.go | 4 +--- core/callinfo/callinfo.go | 13 ++++++++++--- core/core.go | 41 +++++++++++++++++++-------------------- ui/callinfoView.go | 4 ++-- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/core/app/app.go b/core/app/app.go index be71130..3a2ba5e 100644 --- a/core/app/app.go +++ b/core/app/app.go @@ -192,6 +192,7 @@ func (c *Controller) Startup() { c.Callinfo = callinfo.New(c.dxccFinder, c.scpFinder, c.callHistoryFinder, c.QSOList, c.Score, c.Entry) c.Entry.SetCallinfo(c.Callinfo) c.Bandmap.SetCallinfo(c.Callinfo) + c.Score.Notify(c.Callinfo) c.Settings.Notify(c.Entry) c.Settings.Notify(c.Workmode) diff --git a/core/bandmap/bandmap.go b/core/bandmap/bandmap.go index 4039aa9..ade0959 100644 --- a/core/bandmap/bandmap.go +++ b/core/bandmap/bandmap.go @@ -37,12 +37,10 @@ type Callinfo interface { } var defaultWeights = core.BandmapWeights{ - TotalPoints: 1, - TotalMultis: 1, - AgeSeconds: -0.001, - Spots: 0.001, - Source: 0, - Quality: 0.01, + AgeSeconds: -0.001, + Spots: 0.001, + Source: 0, + Quality: 0.01, } type Bandmap struct { @@ -180,11 +178,8 @@ func (m *Bandmap) ContestChanged(contest core.Contest) { } } -func (m *Bandmap) ScoreUpdated(score core.Score) { - totalScore := score.Result() +func (m *Bandmap) ScoreUpdated(_ core.Score) { m.do <- func() { - m.weights.TotalPoints = float64(totalScore.Points) - m.weights.TotalMultis = float64(totalScore.Multis) m.update() } } diff --git a/core/bandmap/entries.go b/core/bandmap/entries.go index d34e768..aefc537 100644 --- a/core/bandmap/entries.go +++ b/core/bandmap/entries.go @@ -359,9 +359,7 @@ func (l *Entries) calculateWeightedValue(entry *Entry, now time.Time, weights co return 0 } - points := float64(entry.Info.Points) - multis := float64(entry.Info.Multis) - value := (points * weights.TotalMultis) + (multis * weights.TotalPoints) + (points * multis) + value := float64(entry.Info.Value) ageSeconds := now.Sub(entry.LastHeard).Seconds() spots := float64(entry.SpotCount) diff --git a/core/callinfo/callinfo.go b/core/callinfo/callinfo.go index acd61c7..1c04b6b 100644 --- a/core/callinfo/callinfo.go +++ b/core/callinfo/callinfo.go @@ -24,6 +24,7 @@ func New(entities DXCCFinder, callsigns CallsignFinder, callHistory CallHistoryF dupeChecker: dupeChecker, valuer: valuer, exchangeFilter: exchangeFilter, + totalScore: core.BandScore{Points: 1, Multis: 1}, } return result @@ -45,6 +46,7 @@ type Callinfo struct { lastExchange []string predictedExchange []string theirExchangeFields []core.ExchangeField + totalScore core.BandScore bestMatches []string } @@ -85,7 +87,7 @@ type ExchangeFilter interface { type View interface { SetBestMatchingCallsign(callsign core.AnnotatedCallsign) SetDXCC(string, string, int, int, bool) - SetValue(points, multis int) + SetValue(points, multis, value int) SetPredictedExchange(index int, text string) SetPredictedExchangeFields(fields []core.ExchangeField) SetUserInfo(string) @@ -114,6 +116,10 @@ func (c *Callinfo) ContestChanged(contest core.Contest) { c.view.SetPredictedExchangeFields(c.theirExchangeFields) } +func (c *Callinfo) ScoreUpdated(score core.Score) { + c.totalScore = score.Result() +} + func (c *Callinfo) BestMatches() []string { return c.bestMatches } @@ -151,6 +157,7 @@ func (c *Callinfo) GetInfo(call callsign.Callsign, band core.Band, mode core.Mod result.ExchangeText = strings.Join(result.FilteredExchange, " ") result.Points, result.Multis, result.MultiValues = c.valuer.Value(call, entity, band, mode, result.PredictedExchange) + result.Value = (result.Points * c.totalScore.Multis) + (result.Multis * c.totalScore.Points) + (result.Points * result.Multis) return result } @@ -185,7 +192,7 @@ func (c *Callinfo) ShowInfo(call string, band core.Band, mode core.Mode, exchang c.showDXCCEntity(entity) c.view.SetBestMatchingCallsign(bestMatch) c.view.SetUserInfo(callinfo.UserText) - c.view.SetValue(callinfo.Points, callinfo.Multis) + c.view.SetValue(callinfo.Points, callinfo.Multis, callinfo.Value) for i := range c.theirExchangeFields { text := "" if i < len(callinfo.FilteredExchange) { @@ -356,7 +363,7 @@ func (v *nullView) Show() {} func (v *nullView) Hide() {} func (v *nullView) SetBestMatchingCallsign(callsign core.AnnotatedCallsign) {} func (v *nullView) SetDXCC(string, string, int, int, bool) {} -func (v *nullView) SetValue(int, int) {} +func (v *nullView) SetValue(int, int, int) {} func (v *nullView) SetPredictedExchange(int, string) {} func (v *nullView) SetPredictedExchangeFields(fields []core.ExchangeField) {} func (v *nullView) SetUserInfo(string) {} diff --git a/core/core.go b/core/core.go index 36d9cb6..944796c 100644 --- a/core/core.go +++ b/core/core.go @@ -896,21 +896,6 @@ func (s *BandSummary) Multis() int { return result } -type BandmapEntry struct { - Index int - Label string - Call callsign.Callsign - Frequency Frequency - Band Band - Mode Mode - LastHeard time.Time - Source SpotType - SpotCount int - Quality SpotQuality - - Info Callinfo -} - type Callinfo struct { Call callsign.Callsign @@ -929,6 +914,7 @@ type Callinfo struct { Points int Multis int MultiValues map[conval.Property]string + Value int WeightedValue float64 } @@ -941,6 +927,21 @@ const spotFrequencyDeltaThreshold float64 = 300 // spots within at least this proximity will be considered "on frequency" const spotOnFrequencyThreshold float64 = 1.0 - (spotFrequencyDeltaThreshold / spotFrequencyProximityThreshold) +type BandmapEntry struct { + Index int + Label string + Call callsign.Callsign + Frequency Frequency + Band Band + Mode Mode + LastHeard time.Time + Source SpotType + SpotCount int + Quality SpotQuality + + Info Callinfo +} + // ProximityFactor increases the closer the given frequency is to this entry's frequency. // 0.0 = not in proximity, 1.0 = exactly on frequency // the sign indiciates if the entry's frequency is above (>0) or below (<0) the reference frequency @@ -988,12 +989,10 @@ func BandmapByDescendingValue(a, b BandmapEntry) bool { } type BandmapWeights struct { - TotalPoints float64 - TotalMultis float64 - AgeSeconds float64 - Spots float64 - Source float64 - Quality float64 + AgeSeconds float64 + Spots float64 + Source float64 + Quality float64 } type VFO interface { diff --git a/ui/callinfoView.go b/ui/callinfoView.go index 043669a..a8e9f5d 100644 --- a/ui/callinfoView.go +++ b/ui/callinfoView.go @@ -115,7 +115,7 @@ func (v *callinfoView) SetDXCC(dxccName, continent string, itu, cq int, arrlComp v.dxccLabel.SetMarkup(text) } -func (v *callinfoView) SetValue(points, multis int) { +func (v *callinfoView) SetValue(points int, multis int, value int) { style.RemoveClass(&v.valueLabel.Widget, callinfoWorthlessClass) style.RemoveClass(&v.valueLabel.Widget, callinfoMultiClass) @@ -126,7 +126,7 @@ func (v *callinfoView) SetValue(points, multis int) { style.AddClass(&v.valueLabel.Widget, callinfoMultiClass) } - v.valueLabel.SetText(fmt.Sprintf("%dP %dM", points, multis)) + v.valueLabel.SetText(fmt.Sprintf("%dP x %dM = %d", points, multis, value)) } func (v *callinfoView) SetUserInfo(value string) {