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); }
void MessageBroadcaster_RecordMesgEvent(object sender, MesgEventArgs e) { var msgRecord = e.mesg as RecordMesg; if (msgRecord == null) { return; } var timeFrame = new ActivityTimeFrame(); timeFrame.Timestamp = msgRecord.GetTimestamp().GetDateTime(); _lastTime = timeFrame.Timestamp; timeFrame.HeartRate = msgRecord.GetValidHeartRate(); timeFrame.Cadence = msgRecord.GetValidCadence(); timeFrame.Power = msgRecord.GetValidPower(); timeFrame.Timestamp = msgRecord.GetTimestamp().GetDateTime(); timeFrame.Speed = msgRecord.GetValidSpeed(); var distance = FitExtensions.GetValidDistance(msgRecord); if (distance.HasValue) { timeFrame.Distance = new Distance(distance.Value, DistanceUnit.Meter); } var alt = msgRecord.GetEnhancedAltitude(); if (msgRecord.HasPosition()) { timeFrame.Position = new SharpGeo.Position { Latitude = msgRecord.GetPositionLatInDegrees(), Longitude = msgRecord.GetPositionLongInDegrees(), Altitude = msgRecord.GetAltitude().GetValueOrDefault() }; } Activity.AddTimeFrame(timeFrame); }
public void WriteSummary() { // Session message var sessionMsg = new SessionMesg(); sessionMsg.SetStartTime(new DateTime(Activity.StartTime)); sessionMsg.SetTotalElapsedTime(Activity.ElapsedTime); sessionMsg.SetTotalMovingTime(Activity.MovingTime); sessionMsg.SetSport(Activity.Sport); sessionMsg.SetTotalDistance(Activity.Distance.GetValueAs(DistanceUnit.Meter)); sessionMsg.SetAvgSpeed(FitExtensions.GetValidSpeed(Activity.AvgSpeed.GetValueAs(SpeedUnit.MeterPerSecond))); sessionMsg.SetMaxSpeed(FitExtensions.GetValidSpeed(Activity.MaxSpeed.GetValueAs(SpeedUnit.MeterPerSecond))); sessionMsg.SetAvgHeartRate((byte)Activity.AvgHeartRate); sessionMsg.SetMaxHeartRate((byte)Activity.MaxHeartRate); sessionMsg.SetAvgPower((ushort)Activity.AvgPower); sessionMsg.SetMaxPower((ushort)Activity.MaxPower); sessionMsg.SetAvgCadence((byte)Activity.AvgCadence); sessionMsg.SetMaxCadence((byte)Activity.MaxCadence); sessionMsg.SetTotalAscent(Convert.ToUInt16(Activity.Ascent)); sessionMsg.SetTotalDescent(Convert.ToUInt16(Activity.Descent)); _encoder.Write(sessionMsg); }