internal void OnScheduleChanged(RootTask task, bool minorChange) { Snapshot newSnapshot = new Snapshot(Vehicle.Schedule); SnapshotComparsion comparsion = _lastSnapshot.CompareWithNewer(newSnapshot); bool isChanged = comparsion.IsDifference || _lastSnapshot.Count != newSnapshot.Count; if (isChanged) { if (_durationPerStation == null) { _durationPerStation = new DurationsPerStationsContainer(this); } else { _durationPerStation.NewTimes(this); } Manager <VehicleScheduleDataManager> .Current.InvalidateDurationPerStation(); } if (comparsion.IsDifference) //in comparsion there aren't any new tasks, it is only difference in old tasks { var invalidateMeasurement = false; foreach (var removedTask in comparsion.removed) { _travelData.Remove(removedTask); _stationLoadingData.Remove(removedTask); if (_measurement != null && _measurement.Task == removedTask) { invalidateMeasurement = true; } } foreach (var changedTask in comparsion.changed) { _stationLoadingData.MarkForOverwrite(changedTask); if (_measurement is StationLoadingMeasurement measurement && measurement.Task == changedTask) { invalidateMeasurement = true; } } foreach (var travelChangedTask in comparsion.incomingRouteChange) { _travelData.Clear(travelChangedTask); if (_measurement is TravelMeasurement) { invalidateMeasurement = true; } } if (invalidateMeasurement) { OnMeasurementInvalidated(); } } _lastSnapshot = newSnapshot; if (isChanged) { FillUnknownTimes(); } _capacity?.MarkDirty(); OnDataChanged(task, false); //do not notify route - when schedule is changed, OnScheduleChanged event will be called for each vehicle in the route }
internal void InvalidateDurationPerStation(bool forceReload = false) { DateTime actTime = TimeManager.Current.DateTime; if (_durationPerStation == null || _actualTimeOfDurationPerSt == null || (actTime - _actualTimeOfDurationPerSt.Value).TotalDays > DURATION_PER_STATION_RENEW_TIME_DAYS || (forceReload && actTime != _actualTimeOfDurationPerSt)) { _actualTimeOfDurationPerSt = actTime; if (_durationPerStation == null) { _durationPerStation = new DurationsPerStationsContainer(); } _durationPerStation.MarkForOverwrite(); foreach (VehicleScheduleData scheduleData in _vehiclesData.Values) { _durationPerStation.AddTimes(scheduleData); } } }