コード例 #1
0
        private static Model.FoundServiceItem MapResolvedStop(Timetable.CifSchedule schedule = null,
                                                              Timetable.Station at           = null,
                                                              Time?time = null,
                                                              Timetable.Station from = null,
                                                              Timetable.Station to   = null,
                                                              string via             = "")
        {
            schedule = schedule ?? TestSchedules.CreateScheduleWithService();
            at       = at ?? TestStations.Surbiton;
            time     = time ?? TestSchedules.Ten;
            var find = new StopSpecification(at, time.Value, TestDate, TimesToUse.Departures);

            var resolved = new ResolvedService(schedule, TestDate, false);

            resolved.TryFindStop(find, out var stop);
            if (to != null)
            {
                stop.GoesTo(to);
            }
            if (from != null)
            {
                stop.ComesFrom(from);
            }
            stop.AsDynamic().ViaText = via;
            var mapper = ToViewProfileConfiguration.CreateMapper();

            return(mapper.Map <Timetable.ResolvedServiceStop, Model.FoundServiceItem>(stop, opts => opts.Items["On"] = stop.On));
        }
コード例 #2
0
 /// <summary>
 /// Create a new charging tariff restrictions.
 /// </summary>
 /// <param name="StartTime">Start time of day, for example "13:30", valid from this time of the day.</param>
 /// <param name="EndTime">End time of day, for example "19:45", valid from this time of the day.</param>
 /// <param name="StartDate">Start date, for example: 2015-12-24, valid from this day until that day (excluding that day).</param>
 /// <param name="EndDate">End date, for example: 2015-12-24, valid from this day until that day (excluding that day).</param>
 /// <param name="MinkWh">Minimum consumed energy in kWh, for example 20, valid from this amount of energy (inclusive) being used.</param>
 /// <param name="MaxkWh">Maximum consumed energy in kWh, for example 50, valid until this amount of energy (exclusive) being used.</param>
 /// <param name="MinCurrent">Sum of the minimum current (in Amperes) over all phases, for example 5.</param>
 /// <param name="MaxCurrent">Sum of the maximum current (in Amperes) over all phases, for example 20.</param>
 /// <param name="MinPower">Minimum power in kW, for example 5.</param>
 /// <param name="MaxPower">Maximum power in kW, for example 20.</param>
 /// <param name="MinDuration">Minimum duration in seconds the charging session MUST last (inclusive).</param>
 /// <param name="MaxDuration">Maximum duration in seconds the charging session MUST last (exclusive).</param>
 /// <param name="DayOfWeek">Which day(s) of the week this tariff element is active.</param>
 /// <param name="Reservation"> When this field is present, the tariff element describes reservation costs.</param>
 public TariffRestrictions(Time?StartTime       = null,
                           Time?EndTime         = null,
                           DateTime?StartDate   = null,
                           DateTime?EndDate     = null,
                           Decimal?MinkWh       = null,
                           Decimal?MaxkWh       = null,
                           Decimal?MinCurrent   = null,
                           Decimal?MaxCurrent   = null,
                           Decimal?MinPower     = null,
                           Decimal?MaxPower     = null,
                           TimeSpan?MinDuration = null,
                           TimeSpan?MaxDuration = null,
                           IEnumerable <DayOfWeek> DayOfWeek       = null,
                           ReservationRestrictionTypes?Reservation = null)
 {
     this.StartTime   = StartTime;
     this.EndTime     = EndTime;
     this.StartDate   = StartDate;
     this.EndDate     = EndDate;
     this.MinkWh      = MinkWh;
     this.MaxkWh      = MaxkWh;
     this.MinCurrent  = MinCurrent;
     this.MaxCurrent  = MaxCurrent;
     this.MinPower    = MinPower;
     this.MaxPower    = MaxPower;
     this.MinDuration = MinDuration;
     this.MaxDuration = MaxDuration;
     this.DayOfWeek   = DayOfWeek?.Distinct() ?? new DayOfWeek[0];
     this.Reservation = Reservation;
 }
コード例 #3
0
        private void DailyInitRecurring(ref int schInterval, ref DailyIntervalUnit schIntervalUnit, ref Time?schStartAt,
                                        ref Time?schEndAt, ref ScheduleType schType, ref TimeSpan spanStart, ref TimeSpan spanEnd,
                                        DailyIntervalUnit intervalUnit, int interval, Time?startAt, Time?endAt,
                                        bool enabled, string description)
        {
            if (startAt.HasValue && endAt.HasValue)
            {
                if (startAt.Value >= endAt.Value)
                {
                    throw new ArgumentException("Argument endAt must be greater than argument startAt.");
                }
            }

            if (interval <= 0)
            {
                throw new ArgumentException("Argument interval must be greater than 0.");
            }

            Init(enabled, description);

            schInterval     = interval;
            schIntervalUnit = intervalUnit;
            schStartAt      = startAt;
            schEndAt        = endAt;
            schType         = ScheduleType.Recurring;

            spanStart = GetTimeSpan(startAt, 0, 0, 0);
            spanEnd   = GetTimeSpan(endAt, 23, 59, 59);
        }
コード例 #4
0
 /// <summary>
 /// The deserialization information for the current model
 /// </summary>
 public IDictionary <string, Action <IParseNode> > GetFieldDeserializers()
 {
     return(new Dictionary <string, Action <IParseNode> > {
         { "endTime", n => { EndTime = n.GetTimeValue(); } },
         { "startTime", n => { StartTime = n.GetTimeValue(); } },
     });
 }
コード例 #5
0
        public void StartSelecting()
        {
            commandcenter.StartSelection();

            time      = Time.Zero;
            time_mode = CaretMode.Delta;
        }
コード例 #6
0
        public void FinishSelecting()
        {
            commandcenter.FinishSelection();

            time      = null;
            time_mode = null;
        }
コード例 #7
0
        public void CancelTime()
        {
            commandcenter.ResetTime();

            time      = null;
            time_mode = null;
        }
コード例 #8
0
 private void DailyInitOnce(ref Time?occursOnce, ref ScheduleType type,
                            Time?occursOnceAt, bool enabled, string description)
 {
     Init(enabled, description);
     occursOnce = occursOnceAt;
     type       = ScheduleType.Once;
 }
コード例 #9
0
ファイル: TimerBase.cs プロジェクト: Shamar/FunnyHacks
 protected TimerBase(SerializationInfo info, StreamingContext context)
 {
     _id = (TimerId)info.GetValue("id", typeof(TimerId));
     _startTime = (Time?)info.GetValue("t", typeof(Time?));
     _interval = (Minute)info.GetValue("i", typeof(Minute));
     _schedules = (Dictionary<Minute, Action>)info.GetValue("s", typeof(Dictionary<Minute, Action>));
     _timerDelegate = new TimerCallback(this.Execute);
 }
コード例 #10
0
        public void FinishDrawingNote()
        {
            commandcenter.FinishNotePlacement();

            time      = null;
            time_mode = null;
            tone      = null;
            tone_mode = null;
        }
コード例 #11
0
        public void StartDrawingNote()
        {
            commandcenter.StartNotePlacement();

            time      = Time.Zero;
            time_mode = CaretMode.Delta;

            tone      = 0;
            tone_mode = CaretMode.Delta;
        }
コード例 #12
0
        public void FinishTime()
        {
            if (time.HasValue)
            {
                commandcenter.ChangeTime(time.Value, time_mode.Value);

                time      = null;
                time_mode = null;
            }
        }
コード例 #13
0
        public override bool Equals(object?obj)
        {
            Time?time = obj as Time;

            if (time is null)
            {
                return(false);
            }

            return(this._totalSecond.Equals(time._totalSecond));
        }
コード例 #14
0
 private TimeSpan GetTimeSpan(Time?time, int defaultHour, int defaultMinute, int defaultSecond)
 {
     if (!time.HasValue)
     {
         return(new TimeSpan(defaultHour, defaultMinute, defaultSecond));
     }
     else
     {
         return(time.Value.GetCurrentValue());
     }
 }
コード例 #15
0
        public Intervall(string s)
        {
            var arr = s.Split('-', 'p'); // arr[0] = "09:10" arr[1] = "14:45"

            _from = new Helpers.Time(arr[0]);
            _to   = null;
            if (!string.IsNullOrEmpty(arr[1]))
            {
                _to = new Helpers.Time(arr[1]);
            }
        }
コード例 #16
0
            public void NullTime_ShouldReturnNull()
            {
                // arrange
                Time?time = null;

                // act
                var result = -time;

                // assert
                result.Should().BeNull();
            }
コード例 #17
0
            public void NullNominatorAndDenominator_ShouldThrow()
            {
                // arrange
                Energy?nominator   = null;
                Time?  denominator = null;

                // act
                Func <Power?> result = () => nominator / denominator;

                // assert
                result.Should().Throw <DivideByZeroException>();
            }
コード例 #18
0
        public void SetTime(Time value)
        {
            if (time_mode == null)
            {
                commandcenter.StartTime();
            }

            time_mode = CaretMode.Absolute;
            time      = value;

            commandcenter.ChangeTime_Preview(time.Value, time_mode.Value);
        }
コード例 #19
0
            public void NullTimes_ShouldReturnNull()
            {
                // arrange
                Time?nullTime1 = null;
                Time?nullTime2 = null;

                // act
                var result = nullTime1 + nullTime2;

                // assert
                result.Should().BeNull();
            }
コード例 #20
0
            public void DivideByNull_ShouldThrow()
            {
                // arrange
                var  time        = CreateTime();
                Time?denominator = null;

                // act
                Func <number> divideByZero = () => time / denominator;

                // assert
                divideByZero.Should().Throw <DivideByZeroException>();
            }
コード例 #21
0
 public StrategyState With(
     Time?BackoffAmount            = null,
     int?Failures                  = null,
     DateTime?LastFailure          = null,
     Map <string, object> Metadata = null
     ) =>
 new StrategyState(
     BackoffAmount ?? this.BackoffAmount,
     Failures ?? this.Failures,
     LastFailure ?? this.LastFailure,
     Metadata ?? this.Metadata
     );
コード例 #22
0
            public void NullArgumentAndFactor_ShouldReturnNull()
            {
                // arrange
                Power?argument = null;
                Time? factor   = null;

                // act
                var result = argument * factor;

                // assert
                result.Should().BeNull();
            }
コード例 #23
0
            public void NullDenominator_ShouldThrow()
            {
                // arrange
                var  nominator   = CreateEnergyInUnitOtherThan(EnergyUnit.Joule);
                Time?denominator = null;

                // act
                Func <Power?> result = () => nominator / denominator;

                // assert
                result.Should().Throw <DivideByZeroException>();
            }
コード例 #24
0
            public void DivideByNull_ShouldThrow()
            {
                // arrange
                var  length      = CreateLengthInUnitOtherThan(LengthUnit.Metre);
                Time?denominator = null;

                // act
                Func <Speed> divideByZero = () => length / denominator;

                // assert
                divideByZero.Should().Throw <DivideByZeroException>();
            }
コード例 #25
0
            public void NullFactor_ShouldTreatNullAsDefault()
            {
                // arrange
                var  argument       = CreatePowerInUnitOtherThan(PowerUnit.Watt);
                Time?factor         = null;
                var  expectedResult = argument * default(Time);

                // act
                var result = argument * factor;

                // assert
                result.Should().Be(expectedResult);
            }
コード例 #26
0
            public void NullTime_ShouldTreatNullAsDefault()
            {
                // arrange
                Time?  nullTime       = null;
                number factor         = Fixture.Create <number>();
                var    expectedResult = default(Time) * factor;

                // act
                var result = nullTime * factor;

                // assert
                result.Should().NotBeNull();
                result.Value.Should().Be(expectedResult);
            }
コード例 #27
0
            public void NullTime_ShouldTreatNullAsDefault()
            {
                // arrange
                Time?  nullTime       = null;
                number denominator    = Fixture.CreateNonZeroNumber();
                var    expectedResult = default(Time) / denominator;

                // act
                var result = nullTime * denominator;

                // assert
                result.Should().NotBeNull();
                result.Value.Should().Be(expectedResult);
            }
コード例 #28
0
ファイル: InfoNodes.cs プロジェクト: velcrome/vvvv-Time
        #pragma warning restore 649

        #endregion fields & pins

        public void Evaluate(int SpreadMax)
        {
            if (currentTime == null || currentFrame != FHDEHost.FrameTime)
            {
                currentFrame = FHDEHost.FrameTime;
                currentTime = Time.CurrentTime();
            }

            FOutput.SliceCount = FDaylightSavingTime.SliceCount = 1;
            var dtwz = currentTime.Value;
            
            FOutput[0] = dtwz;
            FDaylightSavingTime[0] = dtwz.ZoneTime.IsDaylightSavingTime();
        }
コード例 #29
0
ファイル: InfoNodes.cs プロジェクト: intolight/vvvv-Time
        #pragma warning restore 649

        #endregion fields & pins

        public void Evaluate(int SpreadMax)
        {
            if (currentTime == null || currentFrame != FHDEHost.FrameTime)
            {
                currentFrame = FHDEHost.FrameTime;
                currentTime  = Time.CurrentTime();
            }

            FOutput.SliceCount = FDaylightSavingTime.SliceCount = 1;
            var dtwz = currentTime.Value;

            FOutput[0]             = dtwz;
            FDaylightSavingTime[0] = dtwz.ZoneTime.IsDaylightSavingTime();
        }
コード例 #30
0
 private static bool DoValuesMatch(GridRule rule, object cellValue)
 {
     if (rule.Value.GetType() == cellValue.GetType())
     {
         return(DovaluesMatchExactly(rule.Value, cellValue, rule.Operator));
     }
     else
     {
         Type t = cellValue.GetType();
         if (cellValue is string)
         {
             rule.Value = rule.Value.ToString();
             return(DoValuesMatch(rule, cellValue));
         }
         else if (cellValue is int)
         {
             int?nv = TryConvertToInt(rule.Value);
             if (nv == null)
             {
                 return(false);
             }
             rule.Value = nv;
             return(DoValuesMatch(rule, cellValue));
         }
         else if (cellValue is double)
         {
             double?nv = TryConvertToDouble(rule.Value);
             if (nv == null)
             {
                 return(false);
             }
             rule.Value = nv;
             return(DoValuesMatch(rule, cellValue));
         }
         else if (cellValue is Time)
         {
             Time?nv = TryConvertToTime(rule.Value);
             if (nv == null)
             {
                 return(false);
             }
             rule.Value = nv;
             return(DoValuesMatch(rule, cellValue));
         }
         else
         {
             throw new NotSupportedException("This datatype in data grid view column is not supported yet.");
         }
     }
 }
コード例 #31
0
ファイル: TimeRange.cs プロジェクト: lanicon/Styx
        /// <summary>
        /// Create a new time range having a start and end time.
        /// </summary>
        /// <param name="StartTime">The start time.</param>
        /// <param name="EndTime">The end time.</param>
        public TimeRange(Time?StartTime,
                         Time?EndTime)
        {
            #region Initial checks

            if (StartTime.HasValue && EndTime.HasValue && StartTime > EndTime)
            {
                throw new ArgumentException("The starting time of the time range must not be after the ending time!");
            }

            #endregion

            this.StartTime = StartTime;
            this.EndTime   = EndTime;
        }
コード例 #32
0
        protected void Initialize(bool executeNow, Time?activationTime, Action <DateTime> action)
        {
            action_        = action;
            ActivationTime = activationTime;
            NextExecution  = Reschedule();

            TimeSpan dueTime = executeNow ? TimeSpan.Zero : NextExecution - DateTime.Now;

            if (dueTime < TimeSpan.Zero)
            {
                return;
            }

            timer_ = new Timer(x => ExecuteAndReschedule(), null, dueTime, TimeSpan.Zero);
        }
コード例 #33
0
ファイル: TimerBase.cs プロジェクト: Shamar/FunnyHacks
 public void StartAt(Time time)
 {
     bool started = !_startTime.HasValue && time < Time.Now;
     _startTime = time;
     if(started)
     {
         StartSchedules();
         FireEvent(Started, time);
     }
 }
コード例 #34
0
ファイル: TimerBase.cs プロジェクト: Shamar/FunnyHacks
        public void StopAt(Time time)
        {
            if(_startTime.HasValue && _startTime.Value > time)
                throw new ArgumentOutOfRangeException("time");

            bool stopped = _startTime.HasValue;
            _startTime = null;
            if(stopped)
            {
                StopSchedules();
                FireEvent(Stopped, time);
            }
        }