mirror of
https://codeberg.org/portospaceteam/ground-dashboard.git
synced 2024-11-25 08:26:26 +00:00
35 lines
699 B
Go
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"
|
|
}
|