Skip to content

Commit

Permalink
Use monotonic clock for status print.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyoung committed Jan 7, 2016
1 parent f4c9af1 commit cfd1541
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main/gen_gdl90.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ func printStats() {
log.Printf(" - CPUTemp=%.02f deg C, MemStats.Alloc=%s, MemStats.Sys=%s, totalNetworkMessagesSent=%s\n", globalStatus.CPUTemp, humanize.Bytes(uint64(memstats.Alloc)), humanize.Bytes(uint64(memstats.Sys)), humanize.Comma(int64(totalNetworkMessagesSent)))
log.Printf(" - UAT/min %s/%s [maxSS=%.02f%%], ES/min %s/%s\n, Total traffic targets tracked=%s", humanize.Comma(int64(globalStatus.UAT_messages_last_minute)), humanize.Comma(int64(globalStatus.UAT_messages_max)), float64(maxSignalStrength)/10.0, humanize.Comma(int64(globalStatus.ES_messages_last_minute)), humanize.Comma(int64(globalStatus.ES_messages_max)), humanize.Comma(int64(len(seenTraffic))))
if globalSettings.GPS_Enabled {
log.Printf(" - Last GPS fix: %s, GPS solution type: %d using %d satellites (%d/%d seen/tracked), NACp: %d, est accuracy %.02f m\n", humanize.Time(mySituation.LastFixLocalTime), mySituation.quality, mySituation.Satellites, mySituation.SatellitesSeen, mySituation.SatellitesTracked, mySituation.NACp, mySituation.Accuracy)
log.Printf(" - Last GPS fix: %s, GPS solution type: %d using %d satellites (%d/%d seen/tracked), NACp: %d, est accuracy %.02f m\n", stratuxClock.HumanizeTime(mySituation.LastFixLocalTime), mySituation.quality, mySituation.Satellites, mySituation.SatellitesSeen, mySituation.SatellitesTracked, mySituation.NACp, mySituation.Accuracy)
log.Printf(" - GPS vertical velocity: %.02f ft/sec; GPS vertical accuracy: %v m\n", mySituation.GPSVertVel, mySituation.AccuracyVert)
}
}
Expand Down
5 changes: 5 additions & 0 deletions main/monotonic.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
humanize "github.com/dustin/go-humanize"
"time"
)

Expand All @@ -24,6 +25,10 @@ func (m *monotonic) Since(t time.Time) time.Duration {
return m.Time.Sub(t)
}

func (m *monotonic) HumanizeTime(t time.Time) string {
return humanize.RelTime(time.Time{}, t, "ago", "from now")
}

func NewMonotonic() *monotonic {
t := &monotonic{Seconds: 0, Time: time.Time{}, ticker: time.NewTicker(1 * time.Second)}
go t.Watcher()
Expand Down

0 comments on commit cfd1541

Please sign in to comment.