Opc.Ua.Server.StartEndAggregateCalculator.ComputeStartEnd2 C# (CSharp) Method

ComputeStartEnd2() protected method

Calculate the Start2 and End2 aggregates for the timeslice.
protected ComputeStartEnd2 ( Opc.Ua.Server.TimeSlice slice, bool returnEnd ) : DataValue
slice Opc.Ua.Server.TimeSlice
returnEnd bool
return DataValue
        protected DataValue ComputeStartEnd2(TimeSlice slice, bool returnEnd)
        {
            // get the values in the slice.
            List<DataValue> values = GetValuesWithSimpleBounds(slice);

            // check for empty slice.
            if (values == null || values.Count == 0)
            {
                return GetNoDataValue(slice);
            }

            DataValue value = null;

            // return start bound.
            if ((!returnEnd && !TimeFlowsBackward) || (returnEnd && TimeFlowsBackward))
            {
                value = values[0];
            }

            // return end bound.
            else
            {
                value = values[values.Count - 1];
            }

            if (returnEnd)
            {
                value.SourceTimestamp = GetTimestamp(slice);
                value.ServerTimestamp = GetTimestamp(slice);

                if (StatusCode.IsNotBad(value.StatusCode))
                {
                    value.StatusCode = value.StatusCode.SetAggregateBits(AggregateBits.Calculated);
                }
            }

            return value;
        }