package main import "powerpod/gotool/pb" // accelSamplesFromCacheStatus maps combined CACHE_STATUS entries to AccelSample // (for dashboard / WebSocket accel push). func accelSamplesFromCacheStatus(r *pb.CacheStatusResponse) []*pb.AccelSample { if r == nil { return nil } out := make([]*pb.AccelSample, 0, len(r.GetClients())) for _, c := range r.GetClients() { if c.GetAccel() == nil { continue } a := c.GetAccel() out = append(out, &pb.AccelSample{ ClientId: c.GetClientId(), Valid: a.GetValid(), X: a.GetX(), Y: a.GetY(), Z: a.GetZ(), AgeMs: a.GetAgeMs(), }) } return out } // tapEventsFromCacheStatus maps combined CACHE_STATUS entries to TapEvent // (only clients with a consumed pending tap). func tapEventsFromCacheStatus(r *pb.CacheStatusResponse) []*pb.TapEvent { if r == nil { return nil } out := make([]*pb.TapEvent, 0, len(r.GetClients())) for _, c := range r.GetClients() { if c.GetTap() == nil { continue } t := c.GetTap() out = append(out, &pb.TapEvent{ ClientId: c.GetClientId(), Valid: true, Kind: t.GetKind(), AgeMs: t.GetAgeMs(), }) } return out }