Пример #1
0
 /** tries to fill unknown travel and station loading times from own old values / another schedule part or from global values based on station locations */
 private void FillUnknownTimes()
 {
     foreach ((RootTask endStationTask, VehicleStationLocation startStation, VehicleStationLocation endStation, List <VehicleStationLocation> nonstopStations) in this.GetNonNonstopScheduleParts())
     {
         VehicleScheduleDataManager manager = Manager <VehicleScheduleDataManager> .Current;
         if (GetAverageTravelDuration(endStationTask) == null)
         {
             TimeSpan?duration = _durationPerStation?.GetTravelTime(startStation, endStation, nonstopStations);
             if (duration == null)
             {
                 duration = manager.GetGlobalTravelDuration(startStation, endStation, nonstopStations);
             }
             if (duration != null)
             {
                 _travelData.Add(endStationTask, duration.Value);
                 _travelData.MarkForOverwrite(endStationTask);
             }
         }
         if (GetAverageStationLoadingDuration(endStationTask) == null)
         {
             TimeSpan?duration = _durationPerStation?.GetStationTime(endStation);
             if (duration == null)
             {
                 duration = manager.GetGlobalStationDuration(endStation);
             }
             if (duration != null)
             {
                 _stationLoadingData.Add(endStationTask, duration.Value);
                 _stationLoadingData.MarkForOverwrite(endStationTask);
             }
         }
     }
 }
Пример #2
0
            public CacheData(VehicleRoute route)
            {
                VehicleScheduleDataManager manager = Manager <VehicleScheduleDataManager> .Current;

                this.route = route;
                foreach (Vehicle vehicle in route.Vehicles.ToArray())
                {
                    manager.GetOrCreateVehicleScheduleData(vehicle).SubscribeOwnDataChanged(OnVehicleDataChanged);
                }
            }
Пример #3
0
            public void OnRouteDataRemove()
            {
                VehicleScheduleDataManager manager = Manager <VehicleScheduleDataManager> .Current;

                if (manager != null)
                {
                    foreach (Vehicle vehicle in route.Vehicles.ToArray())
                    {
                        manager[vehicle]?.UnsubscribeOwnDataChanged(OnVehicleDataChanged);
                    }
                }
            }
Пример #4
0
        //called only when route has more than one vehicle
        public void CallDataChangedEventsForRoute(RootTask task)
        {
            VehicleRoute route = Vehicle.Route;

            if (route?.Vehicles.Count > 1)
            {
                int?taskIndex = task?.GetIndex();
                VehicleScheduleDataManager manager = Manager <VehicleScheduleDataManager> .Current;
                foreach (Vehicle vehicle in route.Vehicles.ToArray())
                {
                    RootTask localTask = taskIndex != null?vehicle.Schedule.GetTasks()[taskIndex.Value] : null;

                    manager[vehicle]?.CallDataChangedEvents(localTask);
                }
            }
        }