Ejemplo n.º 1
0
            public IReadOnlyDictionary <Item, TransferData> GetTransfers(RootTask task)
            {
                if (task.Vehicle.Route != route)
                {
                    throw new ArgumentException("Wrong route in the tasks vehicle", "task");
                }
                IReadOnlyDictionary <Item, TransferData> result;

                if (!_transfers.TryGetValue(task.GetIndex(), out result))
                {
                    result = Manager <VehicleScheduleDataManager> .Current[task.Vehicle]?.Capacity.GetRouteTaskTransfers(task);
                    _transfers.Add(task.GetIndex(), result);
                }
                return(result);
            }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
0
        public IReadOnlyDictionary <Item, TransferData> GetRouteTaskTransfers(RootTask task, bool skipForOnlyOneVehicle = true)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task");
            }
            if (!HasValidData || VehicleSchedule.Vehicle.Route != null)
            {
                TaskTransfers routeTransfers = new TaskTransfers();
                VehicleRoute  route          = VehicleSchedule.Vehicle.Route;
                if (skipForOnlyOneVehicle && route.Vehicles.Count == 1)
                {
                    return(null);
                }
                int taskIndex = task.GetIndex();
                foreach (Vehicle vehicle in route.Vehicles.ToArray())
                {
                    if (vehicle.IsEnabled)
                    {
                        VehicleScheduleData vehicleData = VehicleScheduleDataManager.Current[vehicle];
                        float?mult;
                        if (vehicleData == null || !vehicleData.Capacity.HasValidData || (mult = vehicleData.ScheduleMonthlyMultiplier) == null)
                        {
                            return(null);
                        }

                        IReadOnlyDictionary <Item, TransferData> transfers = vehicleData.Capacity.GetTransfers(vehicle.Schedule.GetTasks()[taskIndex]);
                        if (transfers != null)
                        {
                            routeTransfers.Add(transfers, mult, vehicleData.ScheduleAvereageDuration.Estimated);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }

                return(routeTransfers.Transfers);
            }
            return(null);
        }