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


C# StatusCode.SetCodeBits方法代码示例

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


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

示例1: GetTimeBasedStatusCode

        /// <summary>
        /// Calculates the status code for the slice 
        /// </summary>
        protected StatusCode GetTimeBasedStatusCode(List<SubRegion> regions, StatusCode statusCode)
        {
            // check for empty set.
            if (regions == null || regions.Count == 0)
            {
                return StatusCodes.BadNoData;
            }

            // compute the total good/bad/uncertain.
            double badDuration = 0;
            double goodDuration = 0;
            double totalDuration = 0;

            foreach (SubRegion region in regions)
            {
                totalDuration += region.Duration;

                if (StatusCode.IsBad(region.StatusCode))
                {
                    badDuration += region.Duration;
                    continue;
                }

                if (StatusCode.IsGood(region.StatusCode))
                {
                    goodDuration += region.Duration;
                }
            }

            // default to good.
            statusCode = statusCode.SetCodeBits(StatusCodes.Good);

            // uncertain if the good duration is less than the configured threshold.
            if ((goodDuration/totalDuration)*100 < Configuration.PercentDataGood)
            {
                statusCode = statusCode.SetCodeBits(StatusCodes.UncertainDataSubNormal);
            }

            // bad if the bad duration is greater than or equal to the configured threshold.
            if ((badDuration/totalDuration)*100 >= Configuration.PercentDataBad)
            {
                statusCode = StatusCodes.Bad;
            }

            // always calculated.
            return statusCode;
        }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:50,代码来源:AggregateCalculator.cs

示例2: GetValueBasedStatusCode

        /// <summary>
        /// Calculates the value based status code for the slice 
        /// </summary>
        protected StatusCode GetValueBasedStatusCode(TimeSlice slice, List<DataValue> values, StatusCode statusCode)
        {
            // compute the total good/bad/uncertain.
            double badCount = 0;
            double goodCount = 0;
            double totalCount = 0;

            for (int ii = 0; ii < values.Count; ii++)
            {
                totalCount++;

                if (StatusCode.IsBad(values[ii].StatusCode))
                {
                    badCount++;
                    continue;
                }

                if (StatusCode.IsGood(values[ii].StatusCode))
                {
                    goodCount++;
                }
            }

            // default to good.
            statusCode = statusCode.SetCodeBits(StatusCodes.Good);

            // uncertain if the good duration is less than the configured threshold.
            if ((goodCount / totalCount) * 100 < Configuration.PercentDataGood)
            {
                statusCode = statusCode.SetCodeBits(StatusCodes.UncertainDataSubNormal);
            }

            // bad if the bad duration is greater than or equal to the configured threshold.
            if ((badCount / totalCount) * 100 >= Configuration.PercentDataBad)
            {
                statusCode = StatusCodes.Bad;
            }

            return statusCode;
        }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:43,代码来源:AggregateCalculator.cs


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