ground-dashboard/ground/tool/summerizers/velocity.go
2022-12-05 22:25:36 +00:00

35 lines
699 B
Go

package summerizers
import (
"errors"
"fmt"
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
)
type VelocitySummerizer struct {
mV float64
}
func (s *VelocitySummerizer) Generate(fd []core.DataSegment) error {
s.mV = 0
for _, d := range fd {
//TODO fix mode checking
if d.Computed.SmoothedVelocity > s.mV && d.Computed.FlightMode == core.ModeAscentPowered {
s.mV = d.Computed.SmoothedVelocity
}
}
if s.mV == 0 {
return errors.New("cannot determine max v")
}
return nil
}
func (s *VelocitySummerizer) Value() string {
return fmt.Sprintf("%f m/s", s.mV)
}
func (s *VelocitySummerizer) Name() string {
return "Max Velocity"
}