/// <summary> /// Method to process when there is a multiple hour jump since last update /// </summary> /// <param name="time">Time of incoming data</param> /// <param name="lastEntryDif">Difference since last time updated</param> private void MultipleHourJump(DateTime time, TimeSpan lastEntryDif) { //Clear out enough items to just insert the empty hours while (hours.Count + lastEntryDif.Hours >= 24) { hours.Dequeue(); } for (var missingHour = lastDateTime.Hour; missingHour < time.Hour; missingHour++) { hours.Enqueue(new HourRecord(missingHour)); } lastHourRecord = new HourRecord(time.Hour); hours.Enqueue(lastHourRecord); }
/// <summary> /// Handling for a new hour /// </summary> /// <param name="time">The incoming data's time</param> private void NewHour(DateTime time) { var dataHourTime = time.Hour; var lastHourTime = lastHourRecord.Identifier; if (lastHourTime == dataHourTime) { return; } /* * Looping here is scary; but we need to ensure we trim to * limit we want to contain. */ while (hours.Count >= 24) //We've filled a day { hours.Dequeue(); //Remove the oldest } lastHourRecord.CompleteAdding(); lastHourRecord = new HourRecord(time.Hour); //Set the new 'last hour' hours.Enqueue(lastHourRecord); //Add the new HourRecord }
/// <summary> /// Encapsulates initialization of the class; or resetting. /// </summary> private void Initialize(int hour) { hours.Clear(); lastHourRecord = new HourRecord(hour); hours.Enqueue(lastHourRecord); }