Opc.Ua.Server.AggregateCalculator.CreateSlice C# (CSharp) Méthode

CreateSlice() protected méthode

Creates a new time slice to process.
protected CreateSlice ( Opc.Ua.Server.TimeSlice previousSlice ) : Opc.Ua.Server.TimeSlice
previousSlice Opc.Ua.Server.TimeSlice The previous processed slice.
Résultat Opc.Ua.Server.TimeSlice
        protected TimeSlice CreateSlice(TimeSlice previousSlice)
        {
            TimeSlice slice = new TimeSlice();

            // ensure slice is oriented from past to future even if request is going backwards.
            if (TimeFlowsBackward)
            {
                if (previousSlice == null)
                {
                    slice.EndTime = StartTime;
                }
                else
                {
                    slice.EndTime = previousSlice.StartTime;
                }

                slice.StartTime = slice.EndTime.AddMilliseconds(-ProcessingInterval);

                // check for end of request.
                if (slice.StartTime < EndTime)
                {
                    slice.StartTime = EndTime;
                    slice.Partial = true;
                }
            }
            else
            {
                if (previousSlice == null)
                {
                    slice.StartTime = StartTime;
                }
                else
                {
                    slice.StartTime = previousSlice.EndTime;
                }

                slice.EndTime = slice.StartTime.AddMilliseconds(ProcessingInterval);

                // check for end of request.
                if (slice.EndTime > EndTime)
                {
                    slice.EndTime = EndTime;
                    slice.Partial = true;
                }
            }

            // update the slice with current data.
            UpdateSlice(slice);
            return slice;
        }