Пример #1
0
 public StationCall(StationTrack track, Time arrival, Time departure, bool isStop)
 {
     Track = track ?? throw new ArgumentNullException(nameof(track));
     Track.Add(this);
     Arrival   = arrival ?? throw new ArgumentNullException(nameof(arrival), string.Format(CultureInfo.CurrentCulture, "At {0}", track.Station));
     Departure = departure ?? throw new ArgumentNullException(nameof(departure), string.Format(CultureInfo.CurrentCulture, "At {0}", track.Station));
     IsStop    = isStop;
     Notes     = new List <StationCallNote>();
 }
Пример #2
0
 public void Add(StationTrack track)
 {
     if (track == null)
     {
         throw new ArgumentNullException(nameof(track));
     }
     track.Station = this;
     Tracks.Add(track);
 }
        internal static (bool, IEnumerable <StationCall>) GetConflicts(this StationTrack me, StationCall call, IEnumerable <StationCall> withCalls, IEnumerable <VehicleSchedule> locos)
        {
            if (me.Calls.Count == 0)
            {
                return(false, null);
            }
            var conflictingCalls = withCalls
                                   .Where(c => !locos.HasSameLoco(call, c) && (
                                              (call.Departure > c.Arrival && call.Departure <= c.Departure) ||
                                              (call.Arrival >= c.Arrival && call.Arrival < c.Departure)));

            if (conflictingCalls.Any())
            {
                return(true, conflictingCalls);
            }
            return(false, null);
        }
Пример #4
0
        }                         // For deserialization.

        public StationCall(StationTrack track, Time arrival, Time departure) : this(track, arrival, departure, true)
        {
        }
 public StationTrack StationTrack(StationTrack value) => StationTracks.Single(t => t.Equals(value));
 public bool HasTrack(StationTrack track) => StationTracks.Any(t => t.Equals(track));
        private static IEnumerable <(StationCall one, StationCall another)> GetConflicts(this StationTrack me, IEnumerable <VehicleSchedule> locos)
        {
            if (me.Calls.Count < 2)
            {
                return(Array.Empty <(StationCall, StationCall)>());
            }
            var result = GetConflicts(me.Calls.First(), me.Calls.Skip(1), locos);

            return(result.Distinct());
        }
 internal static IEnumerable <Message> GetValidationErrors(this StationTrack me, IEnumerable <VehicleSchedule> locos)
 {
     return(me.GetConflicts(locos).Select(c => Message.Warning(string.Format(CultureInfo.CurrentCulture, Resources.Strings.CallAtStationHasConflictsWithOtherCall, c.one.Train, c.one, c.another.Train, c.another))));
 }