Files
StarPilot/mapd_repo/utils/update_tracker.go
T
firestar5683 ab81464bd1 Maps
Add navigation and map matching providers with the vendored map service sources.

Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
2026-10-14 19:56:17 -05: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())
}