/// <summary> /// Provides a running count of how many intervals (years, days, etc.) a Tbool /// has been true within some sliding window of time. At the end of that sliding /// window, this function returns the amount of time that has elapsed within the /// window during which the Tbool was true. /// </summary> /// <remarks> /// Example: For a given Tbool, at any given point in time, for how many days during the /// previous 3 days is the Tbool true? /// /// tb = <FTTTFTTTFFFF> /// tb.SEI(3, TheDay) = <001232223210> /// </remarks> public Tnum SlidingElapsedIntervals(Tnum interval, Tnum windowSize) { // If a Tbool is eternally true, return windowSize if (this.IsTrue) { return(windowSize); } // The number of true intervals in a sliding window of time equals // the running count as of time1 minus the running count as of time0. Tnum r = this.RunningElapsedIntervals(interval); int size = Convert.ToInt32(windowSize.FirstValue.Val) * -1; // Counts the current inerval return(r - r.Shift(size, interval)); }