Ejemplo n.º 1
0
 /// <summary>
 /// Updates the total values with summary values
 /// </summary>
 /// <param name="summary"></param>
 public void SetSummary(ILapSummary summary)
 {
     // update with valid values from summary
     if (summary.AvgSpeed.HasValue && !FitExtensions.InvalidSpeed.Equals(summary.AvgSpeed.Value))
     {
         AvgSpeed = summary.AvgSpeed;
     }
     if (summary.MaxSpeed.HasValue && !FitExtensions.InvalidSpeed.Equals(summary.MaxSpeed.Value))
     {
         MaxSpeed = summary.MaxSpeed;
     }
     if (summary.AvgCadence != FitExtensions.InvalidCadence && summary.AvgCadence != 0)
     {
         AvgCadence = summary.AvgCadence;
     }
     if (summary.MaxCadence != FitExtensions.InvalidCadence && summary.MaxCadence != 0)
     {
         MaxCadence = summary.MaxCadence;
     }
     if (summary.AvgHeartRate != FitExtensions.InvalidHeartRate && summary.AvgHeartRate != 0)
     {
         AvgHeartRate = summary.AvgHeartRate;
     }
     if (summary.MaxHeartRate != FitExtensions.InvalidHeartRate && summary.MaxHeartRate != 0)
     {
         MaxHeartRate = summary.MaxHeartRate;
     }
     if (summary.AvgPower != FitExtensions.InvalidPower && summary.AvgPower != 0)
     {
         AvgPower = summary.AvgPower;
     }
     if (summary.MaxPower != FitExtensions.InvalidPower && summary.MaxPower != 0)
     {
         MaxPower = summary.MaxPower;
     }
     if (summary.Distance.HasValue && summary.Distance.Value != Distance.InvalidValue)
     {
         _distance = summary.Distance;
     }
     if (summary.StartTime != DateTime.MinValue)
     {
         StartTime = summary.StartTime;
     }
     if (summary.ElapsedTime != 0)
     {
         _elapsedTime = summary.ElapsedTime;
     }
     if (summary.MovingTime != 0)
     {
         _movingTime = summary.MovingTime;
     }
     if (summary.Ascent != 0)
     {
         Ascent = summary.Ascent;
     }
     if (summary.Descent != 0)
     {
         Descent = summary.Descent;
     }
 }
Ejemplo n.º 2
0
        public static LapSummary FromLap(ILapSummary lap)
        {
            var summary = new LapSummary();

            summary.CopyFrom(lap);
            return(summary);
        }
Ejemplo n.º 3
0
        public void WriteLap(ILapSummary lap)
        {
            if (lap == null || lap.ElapsedTime == 0)
            {
                return;
            }

            var lapMsg = new LapMesg();

            lapMsg.SetStartTime(new DateTime(lap.StartTime));
            lapMsg.SetTotalElapsedTime(lap.ElapsedTime);
            lapMsg.SetTotalMovingTime(lap.MovingTime);
            lapMsg.SetTotalDistance(lap.Distance.GetValueAs(DistanceUnit.Meter));
            lapMsg.SetAvgSpeed(FitExtensions.GetValidSpeed(lap.AvgSpeed.GetValueAs(SpeedUnit.MeterPerSecond)));
            lapMsg.SetMaxSpeed(FitExtensions.GetValidSpeed(lap.MaxSpeed.GetValueAs(SpeedUnit.MeterPerSecond)));
            lapMsg.SetAvgHeartRate((byte)lap.AvgHeartRate);
            lapMsg.SetMaxHeartRate((byte)lap.MaxHeartRate);
            lapMsg.SetAvgPower((ushort)lap.AvgPower);
            lapMsg.SetMaxPower((ushort)lap.MaxPower);
            lapMsg.SetAvgCadence((byte)lap.AvgCadence);
            lapMsg.SetMaxCadence((byte)lap.MaxCadence);
            lapMsg.SetTotalAscent(Convert.ToUInt16(lap.Ascent));
            lapMsg.SetTotalDescent(Convert.ToUInt16(lap.Descent));
            _encoder.Write(lapMsg);
        }
Ejemplo n.º 4
0
 public void CopyFrom(ILapSummary source)
 {
     Distance     = source.Distance;
     AvgSpeed     = source.AvgSpeed;
     MaxSpeed     = source.MaxSpeed;
     AvgHeartRate = source.AvgHeartRate;
     MaxHeartRate = source.MaxHeartRate;
     AvgPower     = source.AvgPower;
     MaxPower     = source.MaxPower;
     AvgCadence   = source.AvgCadence;
     MaxCadence   = source.MaxCadence;
     ElapsedTime  = source.ElapsedTime;
     MovingTime   = source.MovingTime;
 }
Ejemplo n.º 5
0
 public static bool HasPower(this ILapSummary summary) => summary.AvgPower != 0 || summary.MaxPower != 0;