Пример #1
0
        /// <summary>
        /// Indicates, for each time interval in a given Tnum, whether the Tbool
        /// is ever true during that interval.
        /// </summary>
        public Tbool EverPer(Tnum intervals)
        {
            // If the interval Tnum is eternally unknown, return unknown
            if (intervals.IntervalValues.Count == 1 &&
                !intervals.FirstValue.IsKnown)
            {
                return(new Tbool(intervals.FirstValue));
            }

            Tbool result = new Tbool();

            IList <DateTime> tPoints = intervals.TimePoints();

            // Check each time interval to see if condition is true
            for (int i = 0; i < tPoints.Count - 1; i++)
            {
                Hval isEverTrue = this.IsEverTrue(tPoints[i], tPoints[i + 1]).FirstValue;
                result.AddState(tPoints[i], isEverTrue);
            }

            // This doesn't use .Lean because the output of EverPer() is often
            // the input to a function that counts the number of discrete
            // intervals.  If you want a "lean" result, append .Lean when using
            // this function.
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Indicates, for each time interval in a given Tnum, whether the Tbool
        /// is always true during that interval.
        /// </summary>
        public Tbool AlwaysPer(Tnum intervals)
        {
            // If the interval Tnum is eternally unknown, return unknown
            if (intervals.IntervalValues.Count == 1 &&
                !intervals.FirstValue.IsKnown)
            {
                return(new Tbool(intervals.FirstValue));
            }

            Tbool result = new Tbool();

            IList <DateTime> tPoints = intervals.TimePoints();

            // Foreach interval in intervals
            for (int i = 0; i < tPoints.Count - 1; i++)
            {
                Hval isAlwaysTrue = this.IsAlwaysTrue(tPoints[i], tPoints[i + 1]).FirstValue;
                result.AddState(tPoints[i], isAlwaysTrue);
            }

            // Doesn't use .Lean.  See explanation in EverPer() above.
            return(result);
        }