当前位置: 首页>>代码示例>>C#>>正文


C# ActivityInfo.HeartRateZoneInfo方法代码示例

本文整理汇总了C#中ActivityInfo.HeartRateZoneInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ActivityInfo.HeartRateZoneInfo方法的具体用法?C# ActivityInfo.HeartRateZoneInfo怎么用?C# ActivityInfo.HeartRateZoneInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActivityInfo的用法示例。


在下文中一共展示了ActivityInfo.HeartRateZoneInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Formulas

        private static string Formulas(IActivity activity, ActivityInfo activityInfo, string field)
        {
            string fieldValue = "";

            if (field.Contains("TRIMPFORMULA"))
            {
                double trimp = 0;

                foreach (var zone in activityInfo.HeartRateZoneInfo(CalculatedFields.GetLogBook().HeartRateZones[0]).Zones)
                {
                    if (zone.Name.Contains("1"))
                    {
                        trimp += zone.TotalTime.TotalSeconds / 60f * 1.1;
                    }
                    if (zone.Name.Contains("2"))
                    {
                        trimp += zone.TotalTime.TotalSeconds / 60f * 1.6;
                    }
                    if (zone.Name.Contains("3"))
                    {
                        trimp += zone.TotalTime.TotalSeconds / 60f * 2.2;
                    }
                    if (zone.Name.Contains("4"))
                    {
                        trimp += zone.TotalTime.TotalSeconds / 60f * 3.0;
                    }
                    if (zone.Name.Contains("5"))
                    {
                        trimp += zone.TotalTime.TotalSeconds / 60f * 4.1;
                    }
                }

                fieldValue = trimp.ToString(CultureInfo.InvariantCulture.NumberFormat);
            }
            if (field.Contains("HALFSPEEDRATIO"))
            {
                bool onlyActive = field.Contains("ACTIVE");

                var dataTrack = GetDataTrack(activity, onlyActive, false);

                float halfDistance = (dataTrack.Last().Distance - dataTrack.First().Distance) / 2f;
                int firstHalfDistanceElapsed = 0;

                for (int i = 0; i < dataTrack.Count; i++)
                {
                    if (dataTrack[i].Distance >= (dataTrack.First().Distance + halfDistance))
                    {
                        firstHalfDistanceElapsed = i;

                        break;
                    }
                }

                int secondHalfDistanceElapsed = dataTrack.Count - firstHalfDistanceElapsed;

                float firstHalfSpeedRatio = halfDistance / (float)firstHalfDistanceElapsed;
                float secondsHalfSpeedRatio = halfDistance / (float)secondHalfDistanceElapsed;

                fieldValue = ((firstHalfSpeedRatio - secondsHalfSpeedRatio) / firstHalfSpeedRatio).ToString(CultureInfo.InvariantCulture.NumberFormat);
            }
            if (field.Contains("DECOUPLINGRATIO"))
            {
                bool onlyActive = field.Contains("ACTIVE");

                var dataTrack = GetDataTrack(activity, onlyActive, false);

                float halfDistance = (dataTrack.Last().Distance - dataTrack.First().Distance) / 2f;
                int firstHalfDistanceElapsed = 0;

                for (int i = 0; i < dataTrack.Count; i++)
                {
                    if (dataTrack[i].Distance >= (dataTrack.First().Distance + halfDistance))
                    {
                        firstHalfDistanceElapsed = i;

                        break;
                    }
                }

                int secondHalfDistanceElapsed = dataTrack.Count - firstHalfDistanceElapsed;

                float firstHalfSpeedHRRatio = (halfDistance / (float)firstHalfDistanceElapsed) / dataTrack.Where((o, index) => index >= 0 && index <= firstHalfDistanceElapsed).Average(o => o.HR);
                float secondsHalfSpeedHRRatio = (halfDistance / (float)secondHalfDistanceElapsed) / dataTrack.Where((o, index) => index > firstHalfDistanceElapsed).Average(o => o.HR);

                fieldValue = ((firstHalfSpeedHRRatio - secondsHalfSpeedHRRatio) / firstHalfSpeedHRRatio).ToString(CultureInfo.InvariantCulture.NumberFormat);
            }
            if (field.Contains("RANGE"))
            {
                field = ParseExpression(field, activity, "", null);

                bool active = field.StartsWith("ACTIVE");

                string returnType = Regex.Match(field, "(?<=RANGE).*(?=\\()").Value;
                string dataField = Regex.Match(field, "(?<=\\()[a-zA-Z]*(?=,)").Value.ToUpper();
                float lowerBound = Single.Parse(Regex.Match(field, "(?<=,)[0-9.-]*(?=,)").Value, CultureInfo.InvariantCulture.NumberFormat);
                float upperBound = Single.Parse(Regex.Match(field, "(?<=,)[0-9.-]*(?=\\))").Value, CultureInfo.InvariantCulture.NumberFormat);

                if (dataField == "ELAPSED")
                {
                    lowerBound *= (1000f / GlobalSettings.dataTrackResolution);
//.........这里部分代码省略.........
开发者ID:gerhardol,项目名称:calculatedfields,代码行数:101,代码来源:Evaluator.cs


注:本文中的ActivityInfo.HeartRateZoneInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。