/// <summary>
        /// Try to choose a next route, unless the target block of the current route
        /// is set to wait.
        /// </summary>
        /// <returns>True if a next route has been chosen.</returns>
        private bool ChooseNextRoute(ILocState loc)
        {
            // Should we wait in the destination block?
            var route = loc.CurrentRoute.Actual;

            if ((route == null) ||
                (loc.WaitAfterCurrentRoute.Actual) ||
                (loc.HasNextRoute()) ||
                !ShouldControlAutomatically(loc))
            {
                // No need to choose a next route
                return(false);
            }

            // The loc can continue (if a free route is found)
            var nextRoute = ChooseRoute(loc, route.Route.To, route.Route.ToBlockSide.Invert(), true, 0);

            if (nextRoute == null)
            {
                // No route available
                return(false);
            }

            // We have a next route
            nextRoute.Lock(loc);
            loc.NextRoute.Actual = nextRoute;

            // Set all junctions correct
            nextRoute.Prepare();
            return(true);
        }
        /// <summary>
        /// Loc is entering its destination.
        /// </summary>
        /// <returns>The timespan before this method wants to be called again.</returns>
        private TimeSpan OnEnteringDestination(ILocState loc)
        {
            // Check state
            var state = loc.AutomaticState.Actual;

            if (state != AutoLocState.EnteringDestination)
            {
                // Wrong state, no need to do anything
                return(TimeSpan.MaxValue);
            }

            // Log state
            log.Trace("OnEnteringDestination {0}", loc);

            // The loc can continue (if a free route is found)
            ChooseNextRoute(loc);
            if (loc.HasNextRoute() && loc.NextRoute.Actual.IsPrepared)
            {
                // We have a next route, so we can continue our speed
                loc.Speed.Requested = loc.GetMaximumSpeed(loc.NextRoute.Actual);
            }

            return(TimeSpan.MaxValue);
        }