예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="days"></param>
 /// <returns></returns>
 public static TimeLength fromDays(long days)
 {
     return(TimeLength.fromHours(days * 24));
 }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <returns></returns>
 public static TimeLength random(TimeLength min, TimeLength max)
 {
     return(new TimeLength((long)
                           (rnd.NextDouble() * (max.totalMinutes - min.totalMinutes) + min.totalMinutes)));
 }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_clock"></param>
 /// <param name="_handler"></param>
 /// <param name="first"></param>
 /// <param name="_interval"></param>
 public RepeatedTimer(Clock _clock, ClockHandler _handler, TimeLength first, TimeLength _interval)
 {
     this.clock    = _clock;
     this.handler  = _handler;
     this.interval = _interval;
     clock.registerOneShot(new ClockHandler(onClock), first);
 }
예제 #4
0
 /// <summary>
 /// Registers a repeated-timer, which will be fired
 /// periodically for every specified interval.
 ///
 /// The first clock notification will be sent also after the
 /// specified minutes.
 /// </summary>
 /// <returns>
 /// The cookie, which shall be then used to unregister the timer.
 /// </returns>
 public ClockHandler registerRepeated(ClockHandler handler, TimeLength time)
 {
     return(registerRepeated(handler, time, time));
 }
예제 #5
0
 /// <summary>
 /// Registers an one-shot timer, which will be fired after
 /// the specified time span.
 /// </summary>
 public void registerOneShot(ClockHandler handler, TimeLength time)
 {
     Debug.Assert(time.totalMinutes > 0);
     queue.insert(currentTime + time.totalMinutes, handler);
 }
예제 #6
0
파일: Time.cs 프로젝트: wcp16/FreeTrainSDL
 /// <summary>
 ///
 /// </summary>
 /// <param name="ta"></param>
 /// <param name="tb"></param>
 /// <returns></returns>
 public static TimeLength operator -(Time ta, Time tb)
 {
     return(TimeLength.fromMinutes(ta.currentTime - tb.currentTime));
 }
예제 #7
0
        private void registerTimer()
        {
            int min = FLASH_FREQUENCY - (WorldDefinition.World.Clock.minutes % FLASH_FREQUENCY);

            if (min == 0)
            {
                min = FLASH_FREQUENCY;
            }

            if (currentState != State.Open)             // register the handler while the Xing is closed.
            {
                WorldDefinition.World.Clock.registerOneShot(new ClockHandler(followUp), TimeLength.fromMinutes(min));
            }
        }