/// <summary>
        /// Default ctor
        /// </summary>
        public AutomaticLocController(IRailwayState railwayState)
        {
            this.railwayState = railwayState;
            var dispatcher = railwayState.Dispatcher;

            locHasNoRouteSince      = new Dictionary <ILocState, DateTime>();
            routeAvailabilityTester = new LiveRouteAvailabilityTester(railwayState);
            enabled   = new StateProperty <bool>(null, false, null, OnRequestedEnabledChanged, null);
            heartBeat = new HeartBeat(this, dispatcher);

            // Register on all state change events.
            foreach (var iterator in railwayState.LocStates)
            {
                var loc = iterator;
                loc.ControlledAutomatically.RequestedChanged += (s, x) => dispatcher.PostAction(() => OnLocControlledAutomaticallyChanged(loc, false, false));
                loc.BeforeReset += (s, x) => dispatcher.PostAction(() => OnLocControlledAutomaticallyChanged(loc, false, true));
                loc.AfterReset  += (s, x) => dispatcher.PostAction(() => OnAfterResetLoc(loc));
            }
            foreach (var iterator in railwayState.SensorStates)
            {
                var sensor = iterator;
                sensor.Active.ActualChanged += (s, x) => dispatcher.PostAction(() => OnSensorActiveChanged(sensor));
            }
            foreach (var iterator in railwayState.JunctionStates.OfType <ISwitchState>())
            {
                var @switch = iterator;
                @switch.Direction.ActualChanged += (s, x) => RequestUpdate();
            }
            signals.AddRange(railwayState.SignalStates);
        }
            /// <summary>
            /// Default ctor
            /// </summary>
            public FutureAlternativeSet(LiveRouteAvailabilityTester live, IRouteState route, ILocState loc)
            {
                this.testLoc   = loc;
                minGenerations = live.railwayState.BlockStates.Count;
                var tester = new FutureRouteAvailabilityTester(live.railwayState);

                tester.TakeRoute(route, loc);
                alternatives.Add(new FutureAlternative(tester, 0));
                autoLocs = live.railwayState.LocStates.Where(x => x.ControlledAutomatically.Actual && (x.CurrentBlock.Actual != null)).ToList();
            }