Files
StarPilot/mapd_repo/utils/update_tracker.go
T
firestar5683 1ce9f73ae2 Navigation and maps
Add navigation and map matching providers with the vendored map service sources.
2026-10-03 22:34:37 +00:00

26 lines
409 B
Go

package utils
import (
"time"
m "pfeifer.dev/mapd/math"
)
type UpdateTracker struct {
LastTime time.Time
Time time.Time
DiffMA m.MovingAverage
}
func (u *UpdateTracker) Init(maLength int) {
u.LastTime = time.Now()
u.Time = time.Now()
u.DiffMA.Init(maLength)
}
func (u *UpdateTracker) Update() {
u.LastTime = u.Time
u.Time = time.Now()
u.DiffMA.Update(u.Time.Sub(u.LastTime).Seconds())
}