public void PeriodLimitsSubtractTest() {
            var test = new DateTime(2011, 4, 30);

            var timeRange1 = new TimeRange(new DateTime(2011, 4, 20), new DateTime(2011, 4, 25));
            var timeRange2 = new TimeRange(DateTime.MinValue, new DateTime(2011, 4, 6));

            var calendarDateAdd = new CalendarDateAdd();

            // 예외 기간을 설정합니다. 4월 10일 이전, 4월20일 ~ 4월25일
            //
            calendarDateAdd.ExcludePeriods.Add(timeRange1);
            calendarDateAdd.ExcludePeriods.Add(timeRange2);

            calendarDateAdd.Subtract(test, DurationUtil.Days(1)).Should().Be(test.Subtract(DurationUtil.Days(1)));

            //! 4월 30일로부터 5일전이면 4월25일이지만, 예외기간이 4월20일~4월25일이므로, 4월20일을 반환합니다.
            //
            calendarDateAdd.Subtract(test, DurationUtil.Days(5)).Should().Be(timeRange1.Start);

            //! 4월 30일로부터 20일전이면, 4월10일 이지만 예외기간이 4월20일~4월25일이 있어 4월 5일이 되지만 4월 6일 이전은 예외기간이라 null을 반환합니다.
            //
            calendarDateAdd.Subtract(test, DurationUtil.Days(20)).HasValue.Should().Be.False();

            calendarDateAdd.Add(test, DurationUtil.Days(3)).Should().Be(test.Add(DurationUtil.Days(3)));
        }
 public TimedColourRangeSet(TimeRange timeRange, DualColour start, DualColour mid, DualColour end)
 {
     this.timeRange = timeRange;
     this.start = start;
     this.mid = mid;
     this.end = end;
 }
Example #3
0
        public void HasStartTest() {
            //현재부터 ~ 쭉
            var timeRange = new TimeRange(ClockProxy.Clock.Now, null);

            timeRange.HasStart.Should().Be.True();
            timeRange.HasEnd.Should().Be.False();
        }
 public void MomentTest() {
     var period = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 1));
     var periodCombiner = new TimePeriodCombiner<TimeRange>();
     var periods = periodCombiner.CombinePeriods(new TimePeriodCollection { period });
     periods.Count.Should().Be(1);
     Assert.IsTrue(periods[0].IsSamePeriod(period));
 }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocationWorkHour"/> class.
        /// </summary>
        /// <param name="dayOfWeek">The day of week.</param>
        /// <param name="workHourTimeRange">The work hour time range.</param>
        public LocationWorkHour(DayOfWeek dayOfWeek, TimeRange workHourTimeRange)
        {
            Check.IsNotNull(dayOfWeek, () => DayOfWeek);

            _dayOfWeek = dayOfWeek;
            _workHourTimeRange = workHourTimeRange;
        }
Example #6
0
        public SampleCombiner(DataSample sample)
        {
            if (sample == null)
            {
                throw new ArgumentNullException("sample");
            }

            // validate that this sampletype is acceptable
            switch (sample.SampleType)
            {
            case DataSampleType.Average:
            case DataSampleType.Histogram:
            case DataSampleType.HitCount:
            case DataSampleType.Maximum:
            case DataSampleType.Minimum:
                break;

            default:
                throw new ArgumentException("Cannot combine samples for percentiles or other types");
            }

            this.internalSample = new DataSample
                                  {
                                      SampleType = sample.SampleType,
                                      Dimensions = sample.Dimensions,
                                      Name = sample.Name
                                  };

            this.AddData(sample);
            this.timeRange = new TimeRange(sample.StartTime, sample.EndTime);
            this.hasUpdatedTimeRange = true;
        }
Example #7
0
        public void AsStringTest() {
            var period = new TimeRange(testTime, nowTime);
            var periodString = TimeTool.AsString(period);

            Console.WriteLine("periodString=" + periodString);
            periodString.Should().Not.Be.Empty();
        }
        /// <summary>
        /// Create a new tariff restrictions class.
        /// </summary>
        /// <param name="Time">Start/end time of day, for example "13:30 - 19:45", valid from this time of the day.</param>
        /// <param name="Date">Start/end date, for example: 2015-12-24, valid from this day until that day (excluding that day).</param>
        /// <param name="kWh">Minimum/Maximum used energy in kWh, for example 20, valid from this amount of energy is used.</param>
        /// <param name="Power">Minimum/Maximum power in kW, for example 0, valid from this charging speed.</param>
        /// <param name="Duration">Minimum/Maximum duration in seconds, valid for a duration from x seconds.</param>
        /// <param name="DayOfWeek">Minimum/Maximum duration in seconds, valid for a duration from x seconds.</param>
        public TariffRestriction(TimeRange?              Time       = null,
                                 StartEndDateTime?       Date       = null,
                                 DecimalMinMax?          kWh        = null,
                                 DecimalMinMax?          Power      = null,
                                 TimeSpanMinMax?         Duration   = null,
                                 IEnumerable<DayOfWeek>  DayOfWeek  = null)
        {
            #region Initial checks

            if (!Time.   HasValue &&
                !Date.   HasValue &&
                !kWh.    HasValue &&
                Power.   HasValue &&
                Duration.HasValue &&
                DayOfWeek == null)
                throw new ArgumentNullException("All given parameter equals null is invalid!");

            #endregion

            this.Time       = Time;
            this.Date       = Date;
            this.kWh        = kWh;
            this.Power      = Power;
            this.Duration   = Duration;
            this.DayOfWeek  = DayOfWeek != null ? DayOfWeek.Distinct() : new DayOfWeek[0];
        }
        public void PeriodLimitsAddTest() {
            var test = new DateTime(2011, 4, 12);

            var timeRange1 = new TimeRange(new DateTime(2011, 4, 20), new DateTime(2011, 4, 25)); // 4월 20일~4월25일
            var timeRange2 = new TimeRange(new DateTime(2011, 4, 30), null); // 4월 30일 이후 

            var calendarDateAdd = new CalendarDateAdd();

            // 예외 기간을 설정합니다. 4월20일 ~ 4월25일, 4월30일 이후
            //
            calendarDateAdd.ExcludePeriods.Add(timeRange1);
            calendarDateAdd.ExcludePeriods.Add(timeRange2);

            calendarDateAdd.Add(test, DurationUtil.Day).Should().Be(test.Add(DurationUtil.Day));

            //! 4월 12일에 8일을 더하면 4월 20일이지만, 20~25일까지 제외되므로, 4월 25일이 된다.
            //
            calendarDateAdd.Add(test, DurationUtil.Days(8)).Should().Be(timeRange1.End);

            //! 4월 20일에 20일을 더하면, 4월 20~25일 제외 후를 계산하면 4월 30일 이후가 된다. 하지만 4월 30일 이후는 제외가 되므로, 결과값은 null이 된다.
            //
            calendarDateAdd.Add(test, DurationUtil.Days(20)).HasValue.Should().Be.False();

            calendarDateAdd.Subtract(test, DurationUtil.Days(3)).Should().Be(test.Subtract(DurationUtil.Days(3)));
        }
Example #10
0
        public void TimeRangeCalendarTimeRangeTest() {
            var now = ClockProxy.Clock.Now;

            for(var i = 0; i < 500; i += 10) {
                //var fiveSeconds = new TimeRange(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 15, 0),
                //                                      new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 20, 0));

                var current = now.AddDays(i);
                var currentFiveSeconds = new TimeRange(current.TrimToSecond(15), current.TrimToSecond(20));

                new YearRange(current).HasInside(currentFiveSeconds).Should().Be.True();
                new HalfyearRange(current).HasInside(currentFiveSeconds).Should().Be.True();
                new QuarterRange(current).HasInside(currentFiveSeconds).Should().Be.True();
                new MonthRange(current).HasInside(currentFiveSeconds).Should().Be.True();
                new WeekRange(current).HasInside(currentFiveSeconds).Should().Be.True();
                new DayRange(current).HasInside(currentFiveSeconds).Should().Be.True();
                new HourRange(current).HasInside(currentFiveSeconds).Should().Be.True();
                new MinuteRange(current).HasInside(currentFiveSeconds).Should().Be.True();
            }


            TimeRange anytime = new TimeRange();

            new YearRange().HasInside(anytime).Should().Be.False();
            new HalfyearRange().HasInside(anytime).Should().Be.False();
            new QuarterRange().HasInside(anytime).Should().Be.False();
            new MonthRange().HasInside(anytime).Should().Be.False();
            new WeekRange().HasInside(anytime).Should().Be.False();
            new DayRange().HasInside(anytime).Should().Be.False();
            new HourRange().HasInside(anytime).Should().Be.False();
            new MinuteRange().HasInside(anytime).Should().Be.False();
        }
 public void TwoPeriodsOverlap1Test() {
     var period1 = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 15));
     var period2 = new TimeRange(new DateTime(2011, 3, 10), new DateTime(2011, 3, 20));
     var periodCombiner = new TimePeriodCombiner<TimeRange>();
     var periods = periodCombiner.CombinePeriods(period1, period2);
     periods.Count.Should().Be(1);
     Assert.IsTrue(periods[0].IsSamePeriod(new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 20))));
 }
Example #12
0
        protected override IColorEffect ApplyCycle(TimeRange range, LEDNode ledNode)
        {
            double pos = Tween.GetValue(range.Current);

            if (Ordering.GetLEDPosition(ledNode) <= pos)
                return _endColorEffect;

            return _startColorEffect;
        }
Example #13
0
        public void WhenResetCellularDataBlackoutThenGetCellularDataBlackoutShouldReturnNull()
        {
            TimeRange range = new TimeRange(new Time(11, 00), new Time(12, 01));
            this.Preferences.ResetCellularDataBlackout();

            TimeRange timeRange = Preferences.CellularDataBlackout;

            Assert.Null(timeRange);
        }
Example #14
0
        public GenericStockChartViewModel( Settings settings )
        {
            mySettings = settings;

            myCurves = new List<Curve>();
            Signals = SignalCurve.Empty;

            myViewPort = TimeRange.All;
        }
        public void NoPeriodsTest() {
            var limits = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 5));
            var gapCalculator = new TimeGapCalculator<TimeRange>();

            var gaps = gapCalculator.GetGaps(new TimePeriodCollection(), limits);

            gaps.Count.Should().Be(1);
            gaps[0].IsSamePeriod(limits).Should().Be.True();
        }
 public static GetEventsResult GetActiveEventsAroundPOI(LocationPoint PointOfInterest, TimeRange When)
 {
     BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
     EndpointAddress endpointAddress = new EndpointAddress("http://localhost:56071/CaloomMainService.svc");
     ICaloomMainService service =
         new ChannelFactory< ICaloomMainService >(basicHttpBinding, endpointAddress).CreateChannel();
     var serviceResponse = service.GetActiveEventsAroundPOI(PointOfInterest, When);
     return serviceResponse;
 }
Example #17
0
 public ReadingRangeAggregate(
     TimeRange timeStamp,
     ReadingValuesRange ranges
 )
     : base(ranges)
 {
     TimeStamp = new TimeRange(timeStamp);
     _min = _max = null;
 }
Example #18
0
        public void WhenGetCellularDataBlackoutAndNotCorrectlySavedShouldReturnNull()
        {
            TimeRange range = new TimeRange(new Time(11, 00), new Time(12, 01));
            this.Preferences.SetCellularDataBlackout(range);
            DeleteRegistryValue("DataBlackout:From");

            TimeRange timeRange = Preferences.CellularDataBlackout;

            Assert.Null(timeRange);
        }
Example #19
0
        public Color SetColor(TimeRange range, double position, LEDNode led)
        {
            double pct = range.Portion * (Colors.Count-1);
            int start = (int)Math.Floor(pct);
            int end = (int) Math.Ceiling(pct);
            double diff = pct - start;
            Color color = ColorUtil.Interpolate(Colors[start], Colors[end], diff);

            return color;
        }
Example #20
0
 public TimeRangeStepper(ChartModel chart)
 {
     TimeRange = chart.TimeRange;
     StartDate = chart.StartDate;
     EndDate = IncrementByGranularity(StartDate, TimeRange);
     Granularity = chart.Granularity;
     CurrentStartDate = StartDate;
     CurrentEndDate = incrementByGranularity(StartDate);
     StepCount = 0;
 }
Example #21
0
        public void WhenSettingCellularDataBlackoutThenGetCellularDataBlackoutShouldReturnExpected()
        {
            TimeRange range = new TimeRange(new Time(11, 00), new Time(12, 01));
            this.Preferences.SetCellularDataBlackout(range);
            
            TimeRange timeRange = Preferences.CellularDataBlackout;

            Assert.Equal(range.From.MinuteOfDay, timeRange.From.MinuteOfDay);
            Assert.Equal(range.To.MinuteOfDay, timeRange.To.MinuteOfDay);
        }
Example #22
0
        public void WhenTimeIsNotWithinRangeContainsShouldReturnFalse()
        {
            Time time = new Time(12, 02);
            TimeRange range = new TimeRange(new Time(11, 00), new Time(12, 01));
            Assert.False(range.Contains(time));

            time = new Time(19, 58);
            range = new TimeRange(new Time(19, 59), new Time(19, 57));
            Assert.False(range.Contains(time));
        }
        public void PeriodEqualsLimitsTest() {
            var limits = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 5));
            var gapCalculator = new TimeGapCalculator<TimeRange>();

            var excludePeriods = new TimePeriodCollection { limits };

            var gaps = gapCalculator.GetGaps(excludePeriods, limits);

            gaps.Count.Should().Be(0);
        }
        public Color SetColor(TimeRange range, double position, LEDNode led)
        {
            //get our position in space
            double posOffset = position*Width;
            //get our position in time
            double timeOffset = range.PortionTotal*_ref.Width - range.PortionTotal*Width;
            double xPosition = (posOffset + timeOffset)/_ref.Width;
            double yPosition = Ordering.GetAngle(led);

            return _ref.GetValueAt(xPosition,yPosition);
        }
Example #25
0
        private void bandedGridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (!_columns.ContainsKey(e.Column)) return;
            TimeRange[] range = new TimeRange[2];
            range[0] = new TimeRange(660, 1080, Color.Red, Color.Purple); 
            range[1] = new TimeRange(660, 1080, Color.Red, Color.Purple);

            DrawTimeRange dr = new DrawTimeRange();
            dr.Draw(e.Graphics, e.Bounds, range);
            e.Handled = true;
        }
Example #26
0
        private void bandedGridView1_CalcRowHeight(object sender, DevExpress.XtraGrid.Views.Grid.RowHeightEventArgs e)
        {
            TimeRange[] range = new TimeRange[2];
            range[0] = new TimeRange(660, 1080, Color.Red, Color.Purple); 
            range[1] = new TimeRange(660, 1080, Color.Red, Color.Purple);

            DrawTimeRange dr = new DrawTimeRange();
            
            e.RowHeight = 40;

        }
Example #27
0
        public OperatingHours AddRange(string from, string to)
        {
            var range = new TimeRange
            {
                From = DateTime.Parse(from),
                To = DateTime.Parse(to)
            };

            this.ranges.Add(range);

            return this;
        }
Example #28
0
        public void MomentTest() {
            var moment = ClockProxy.Clock.Now;
            var timeRange = new TimeRange(moment);

            timeRange.Start.Should().Be(moment);
            timeRange.End.Should().Be(moment);
            timeRange.Duration.Should().Be(TimeSpec.MinPeriodDuration);

            timeRange.IsAnytime.Should().Be.False();
            timeRange.IsMoment.Should().Be.True();
            timeRange.HasPeriod.Should().Be.True();
        }
 public void TwoPeriodsTouchingTest() {
     var period1 = new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 10));
     var period2 = new TimeRange(new DateTime(2011, 3, 10), new DateTime(2011, 3, 20));
     var periodCombiner = new TimePeriodCombiner<TimeRange>();
     var periods = periodCombiner.CombinePeriods(new TimePeriodCollection
                                                 {
                                                     period1,
                                                     period2
                                                 });
     periods.Count.Should().Be(1);
     Assert.IsTrue(periods[0].IsSamePeriod(new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 20))));
 }
Example #30
0
        protected override IColorEffect ApplyCycle(TimeRange range, LEDNode ledNode)
        {
            double pos = Tween.GetValue(range.Current);

            double rangeStart = pos - _width/2;
            double rangeEnd = pos + _width/2;
            double ledPos = Ordering.GetLEDPosition(ledNode);

            if(ledPos < rangeStart || ledPos > rangeEnd)
                return _backgroundColor;

            return _pulseColor;
        }
 /// <inheritdoc />
 public IEnumerable <string> Query(TimeRange readTime = null, TimeRange saveTime = null)
 {
     return(new string[0]);
 }
Example #32
0
 /// <summary>
 /// Sets the end time to the the current time if it is undefined.
 /// </summary>
 private void DefineEndTime(ref TimeRange timeRange)
 {
     if (timeRange.EndTime == DateTime.MinValue)
         timeRange.EndTime = DateTime.UtcNow;
 }
            private void RenderTab(string tabTitle, TimeRange viewPort, bool isActive = false)
            {
                var imgSrc = RenderImage(tabTitle, viewPort);

                AddTab(tabTitle, imgSrc, isActive);
            }