Exemplo n.º 1
0
        private void GoToStation(int stationId, TrainStatus trainStatus)
        {
            // find destination station
            var station = _network.GetStationById(stationId);

            _log.Feed(_infoPin, $"Planning route to station {station.Name}");

            // FIXME: wrong! correct to set this _only_ after arrival confirmation!
            _lastStationGoneTo = stationId;

            // FIXME: at the moment, this will only try the first stop of the station
            foreach (var stop in station.Stops)
            {
                int   destinationSegmentId = stop.SegmentId;
                float destinationT         = stop.T;

                var result = _routePlanner.PlanRoute(trainStatus.SegmentId, trainStatus.T, trainStatus.Dir, destinationSegmentId, destinationT);

                if (result != null)
                {
                    var currentSegmentLength = _network.GetSegmentById(trainStatus.SegmentId).GetLength();

                    _currentPlanForStationId = stationId;
                    _currentPlanCommand      = new TractionControllerCommand {
                        segmentsToFollow = new (int, SegmentEndpoint, float, float)[1 + result.route.Length]
Exemplo n.º 2
0
 private void HandleArrival()
 {
     if (CurrentOrder != null)
     {
         CurrentRoute !.Destination.DeliverOrder(CurrentOrder);
     }
     CurrentOrder    = null;
     CurrentLocation = CurrentRoute !.Destination;
     if (IsAtHome)
     {
         SetRoute(null);
     }
     else
     {
         var routeBackHome = routePlanner.PlanRoute(CurrentLocation.Name, HomeLocation.Name);
         SetRoute(routeBackHome);
     }
 }