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


C# Server.TimeSlice类代码示例

本文整理汇总了C#中Opc.Ua.Server.TimeSlice的典型用法代码示例。如果您正苦于以下问题:C# TimeSlice类的具体用法?C# TimeSlice怎么用?C# TimeSlice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TimeSlice类属于Opc.Ua.Server命名空间,在下文中一共展示了TimeSlice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputeValue

        /// <summary>
        /// Computes the value for the timeslice.
        /// </summary>
        protected override DataValue ComputeValue(TimeSlice slice)
        {
            uint? id = AggregateId.Identifier as uint?;

            if (id != null)
            {
                switch (id.Value)
                {
                    case Objects.AggregateFunction_StandardDeviationPopulation:
                    {
                        return ComputeStdDev(slice, false, 1);
                    }

                    case Objects.AggregateFunction_StandardDeviationSample:
                    {
                        return ComputeStdDev(slice, false, 2);
                    }

                    case Objects.AggregateFunction_VariancePopulation:
                    {
                        return ComputeStdDev(slice, true, 1);
                    }

                    case Objects.AggregateFunction_VarianceSample:
                    {
                        return ComputeStdDev(slice, true, 2);
                    }
                }
            }

            return base.ComputeValue(slice);
        }
开发者ID:yuriik83,项目名称:UA-.UWP-Universal-Windows-Platform,代码行数:35,代码来源:StdDevAggregateCalculator.cs

示例2: Compute

 public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
 {
     int numGood = 0;
     int numBad = 0;
     double total = 0.0;
     foreach (DataValue v in bucket.Values)
     {
         if (state.RawValueIsGood(v))
         {
             numGood += 1;
             total += Convert.ToDouble(v.Value, CultureInfo.InvariantCulture);
         }
         else
         {
             numBad += 1;
         }
     }
     DataValue retval = new DataValue { SourceTimestamp = bucket.From };
     StatusCode code = ComputeStatus(context, numGood, numBad, bucket).Code;
     code.AggregateBits = AggregateBits.Calculated;
     if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
     if (StatusCode.IsNotBad(code))
         retval.Value = total;
     retval.StatusCode = code;
     GoodDataCount = numGood;
     return retval;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:27,代码来源:TotalAggregate.cs

示例3: ComputeStatus

 protected override StatusCode ComputeStatus(IAggregationContext context, int numGood, int numBad, TimeSlice bucket)
 {
     StatusCode code = base.ComputeStatus(context, numGood, numBad, bucket);
     if (code.CodeBits == StatusCodes.GoodNoData)    // can be removed if GoodNoData is used.
         code = StatusCodes.Good;
     return code;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:7,代码来源:CountAggregate.cs

示例4: ComputeStatus

 protected override StatusCode ComputeStatus(IAggregationContext context, int numGood, int numBad, TimeSlice bucket)
 {
     StatusCode code = base.ComputeStatus(context, numGood, numBad, bucket);
     if (bucket.EarlyBound.Value == null || StatusCode.IsNotGood(bucket.EarlyBound.Value.StatusCode))
         code = StatusCodes.Uncertain;
     return code;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:7,代码来源:DurationInState0Aggregate.cs

示例5: Compute

        public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
        {
            int numGood = 0;
            int numBad = 0;
            DataValue previous = RightState(bucket.EarlyBound.Value) ? bucket.EarlyBound.Value : null;
            double total = 0.0;

            DataValue retval = new DataValue { SourceTimestamp = bucket.From };
            StatusCode code = StatusCodes.BadNoData;

            foreach (DataValue v in bucket.Values)
            {
                if (state.RawValueIsGood(v))
                {
                    numGood += 1;
                    if (previous != null)
                        total += (v.SourceTimestamp - previous.SourceTimestamp).TotalMilliseconds;
                    previous = RightState(v) ? v : null;
                }
                else
                {
                    numBad += 1;
                }
            }
            if (previous != null)
                total += (bucket.LateBound.Value.SourceTimestamp - previous.SourceTimestamp).TotalMilliseconds;
            retval.Value = total;
            code = ComputeStatus(context, numGood, numBad, bucket).Code;
            code.AggregateBits = AggregateBits.Calculated;
            if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
            retval.StatusCode = code;
            return retval;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:33,代码来源:DurationInState0Aggregate.cs

示例6: Compute

 public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
 {
     DataValue initValue = bucket.EarlyBound.Value, finalValue = bucket.LateBound.Value;
     IEnumerator<DataValue> enumerator = bucket.Values.GetEnumerator();
     if (initValue == null && enumerator.MoveNext()) // first element
     {
         initValue = enumerator.Current;
         bucket.Incomplete = true;
     }
     if (finalValue == null)
     {
         while (enumerator.MoveNext())
         {
             finalValue = enumerator.Current;
         }
         bucket.Incomplete = true;
     }
     DataValue retVal = base.Compute(context, bucket, state);
     if (retVal.StatusCode.CodeBits == StatusCodes.BadNoData)
         retVal.Value = null;
     else
         retVal.Value = Convert.ToDouble(retVal.Value) / 
             Math.Abs((finalValue.SourceTimestamp - initValue.SourceTimestamp).TotalMilliseconds); // revisit
     return retVal;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:25,代码来源:TimeAverageAggregate.cs

示例7: Compute

        public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
        {
            List<DataValue> l = new List<DataValue>(bucket.Values);
            DataValue dv = l.Count > 0 ? GetDataValue(l) : null;
            if (SteppedVariable && dv == null)
                dv = bucket.LateBound.Value;

            DataValue retval = new DataValue();
            StatusCode code = StatusCodes.BadNoData;
            if (dv != null)
            {
                code = StatusCode.IsNotGood(dv.StatusCode)
                    ? StatusCodes.UncertainDataSubNormal
                    : StatusCodes.Good;
                retval.SourceTimestamp = dv.SourceTimestamp;
                retval.Value = dv.Value;
                code.AggregateBits = AggregateBits.Raw;
                if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
            }
            else
            {
                retval.SourceTimestamp = bucket.From;
            }
            retval.StatusCode = code;
            return retval;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:26,代码来源:EndAggregate.cs

示例8: Compute

 public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
 {
     DataValue dv = base.Compute(context, bucket, state);
     double duration = Convert.ToDouble(dv.Value) / Math.Abs((bucket.To - bucket.From).TotalMilliseconds) * 100;
     dv.Value = duration;
     return dv;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:7,代码来源:PercentGoodAggregate.cs

示例9: ComputeStatus

 protected override StatusCode ComputeStatus(IAggregationContext context, int numGood, int numBad, TimeSlice bucket)
 {
     if (numGood + numBad == 0)
         return StatusCodes.GoodNoData;
     if (numGood == 0 && numBad > 0)
         return StatusCodes.Bad;
     return base.ComputeStatus(context, numGood, numBad, bucket);
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:8,代码来源:TotalAggregate.cs

示例10: Compute

 public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
 {
     DataValue dv = base.Compute(context, bucket, state);
     if (dv.SourceTimestamp != bucket.From)
     {
         dv.SourceTimestamp = bucket.From;
         StatusCode code = dv.StatusCode;
         code.AggregateBits |= AggregateBits.Calculated;
         dv.StatusCode = code;
     }
     return dv;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:12,代码来源:MinimumAggregate.cs

示例11: Compute

        public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
        {
            int numGood = 0;
            int numBad = 0;
            DataValue firstGoodDv = null;
            DataValue lastGoodDv = null;
            DataValue lastDv = null;
            bool uncertainDataSubNormal = false;
            double delta = double.NaN;
            
            foreach (DataValue dv in bucket.Values)
            {
                if (state.RawValueIsGood(dv))
                {
                    if (firstGoodDv == null)
                    {
                        firstGoodDv = dv;
                    }
                    lastGoodDv = dv;                   
                    numGood++;
                }
                else
                {
                    // check for non-good value occuring before first good value
                    if (firstGoodDv == null)
                        uncertainDataSubNormal = true;
                    numBad++;
                }
                lastDv = dv;
            }
            if (firstGoodDv != null)
            {
                double fv = Convert.ToDouble(firstGoodDv.Value);
                double lv = Convert.ToDouble(lastGoodDv.Value);
                delta = lv - fv;
            }
            
            // check for non-good value occuring after latest good value
            if (!uncertainDataSubNormal && lastGoodDv != null && lastGoodDv.SourceTimestamp < lastDv.SourceTimestamp)
                uncertainDataSubNormal = true;

            StatusCode code = (uncertainDataSubNormal)
                ? StatusCodes.UncertainDataSubNormal
                : (numGood > 0) ? StatusCodes.Good : StatusCodes.BadNoData;
            DataValue retval = new DataValue { SourceTimestamp = bucket.From };
            if (!double.IsNaN(delta))
                retval.Value = delta;
            code.AggregateBits = AggregateBits.Calculated;
            if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
            retval.StatusCode = code;
            return retval;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:52,代码来源:DeltaAggregate.cs

示例12: Comparison

        protected abstract bool Comparison(DataValue value1, DataValue value2); // true if keep value1.

        public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
        {
            int numGood = 0;
            int numBad = 0;
            DataValue valueToKeep = new DataValue() { SourceTimestamp = bucket.From, StatusCode = StatusCodes.BadNoData };
            bool moreData = false;
            bool hasGoodData = false;
            foreach (DataValue dv in bucket.Values)
            {
                if (state.RawValueIsGood(dv))
                {
                    hasGoodData = true;
                    if (valueToKeep.StatusCode == StatusCodes.BadNoData)
                    {
                        valueToKeep = dv;
                    }
                    else
                    {
                        moreData = valueToKeep == dv;
                        if (Comparison(dv, valueToKeep))
                        {
                            valueToKeep = dv;
                        }
                    }
                    numGood++;
                }
                else
                {
                    numBad++;
                    if (!hasGoodData)
                        valueToKeep = dv;
                }
            }
            DataValue retval = valueToKeep.StatusCode == StatusCodes.BadNoData ? valueToKeep : (DataValue)valueToKeep.Clone();
            if (hasGoodData)
            {
                StatusCode code = StatusCodes.Good;
                code = ComputeStatus(context, numGood, numBad, bucket).Code;
                code.AggregateBits = moreData ? AggregateBits.ExtraData : AggregateBits.Raw;
                if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
                retval.StatusCode = code;
            } // numGood = 0, hasGoodData = false beyond this point, i.e., no good data
            else if(numBad > 0)
            {
                retval.Value = null;
                retval.StatusCode = StatusCodes.Bad;
                retval.StatusCode = retval.StatusCode.SetAggregateBits(AggregateBits.Raw);
            }
            return retval;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:52,代码来源:MinimumActualTimeAggregate.cs

示例13: Compute

 public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
 {
     DataValue retval = new DataValue { SourceTimestamp = bucket.From };
     StatusCode code = StatusCodes.BadNoData;
     DataValue boundValue = context.IsReverseAggregation ? bucket.LateBound.Value : bucket.EarlyBound.Value;
     if (boundValue != null)
     {
         code = bucket.EarlyBound.Value.StatusCode.Code;
         code.AggregateBits = bucket.EarlyBound.Value.StatusCode.AggregateBits;
         retval.Value = Convert.ToDouble(bucket.EarlyBound.Value.Value, CultureInfo.InvariantCulture);
     }
     if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
     retval.StatusCode = code;
     return retval;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:15,代码来源:InterpolativeAggregate.cs

示例14: Compute

 public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
 {
     DataValue initValue = bucket.EarlyBound.Value;
     IEnumerator<DataValue> enumerator = bucket.Values.GetEnumerator();
     if (enumerator.MoveNext()) // first element
     {
         if(initValue == null && bucket.From != enumerator.Current.SourceTimestamp)
             bucket.Incomplete = true;
     }
     DataValue retVal = base.Compute(context, bucket, state);
     if (GoodDataCount > 0)
         retVal.Value = Convert.ToDouble(retVal.Value) / GoodDataCount;
     else
         retVal.Value = null;
     return retVal;
 }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:16,代码来源:AverageAggregate.cs

示例15: Compute

        public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
        {
            int numGood = 0;
            int numBad = 0;
            double minV = double.MaxValue;
            double maxV = double.MinValue;
            bool uncertainDataSubNormal = false;
            double range = double.NaN;

            foreach (DataValue dv in bucket.Values)
            {
                if (state.RawValueIsGood(dv))
                {
                    double v = Convert.ToDouble(dv.Value);
                    if (minV > v)
                    {
                        minV = v;
                    }
                    if (maxV < v)
                    {
                        maxV = v;
                    }
                    numGood++;
                }
                else
                {
                    uncertainDataSubNormal = true;
                    numBad++;
                }
            }
            if (minV != double.MaxValue && maxV != double.MinValue)
            {
                range = Math.Abs(maxV - minV);
            }

            StatusCode code = (uncertainDataSubNormal)
                ? StatusCodes.UncertainDataSubNormal
                : StatusCodes.Good;
            if (numGood + numBad == 0) code = StatusCodes.BadNoData;
            DataValue retval = new DataValue { SourceTimestamp = bucket.From };
            if (!double.IsNaN(range))
                retval.Value = range;
            code.AggregateBits = AggregateBits.Calculated;
            if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
            retval.StatusCode = code;
            return retval;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:47,代码来源:RangeAggregate.cs


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