private void CalculateActivity(Activity fvActivity) { ActivityStreams stream = ActivityStreams.CreateFromExistingActivityStream(fvActivity.Id); // stream must have watts to calculate TSS/IF! if (!stream.HasIndividualStream(enums.StreamType.Watts)) { return; } ZoneValueOnDay value = new ZoneValueOnDay(); var ftp = value.GetUserZoneValueOnGivenDate(fvActivity.Athlete.UserId, enums.ZoneType.BikePower, fvActivity.Start); if (ftp == null) { return; } BikePower calc = new BikePower(stream.GetIndividualStream <int?>(enums.StreamType.Watts), ftp.Value); fvActivity.TSS = calc.TSS(); fvActivity.IntensityFactor = calc.IntensityFactor(); _uow.Complete(); }
public static ActivityAnalytics RideCreateFromPowerStream(List <Stream> stream, decimal ftp) { BikePower calc = new BikePower(stream, ftp); ActivityAnalytics a = new ActivityAnalytics() { TSS = Math.Round(calc.TSS(), 0), IF = Math.Round(calc.IntensityFactor(), 2), NP = Math.Round(calc.NP(), 0) }; return(a); }