Esempio n. 1
0
        private HashSet <RouteBetweenCoords> GetRoutesBetweenSlots(List <PickingSlot> pickingSlots)
        {
            var coordsSet = new HashSet <Coord>(pickingSlots.Select(x => x.Position))
            {
                _warehouseLayout.GetPickingEndPosition(),
                _warehouseLayout.GetPickingStartPosition(),
            };
            var coords = coordsSet.ToArray();

            var collection = new ConcurrentDictionary <RouteBetweenCoords, byte>();
            int done       = 1;
            int todo       = coords.Length;
            var sw         = new Stopwatch();

            sw.Start();
            Parallel.For(0, coords.Length, startIndex =>
            {
                var coord1 = coords[startIndex];

                for (var endIndex = 0; endIndex < pickingSlots.Count; endIndex++)
                {
                    var coord2 = coords[endIndex];
                    var result = _pathSolver.FindPath(new TravelStep(coord1), new TravelStep(coord2), false);
                    if (result.Success)
                    {
                        //Debug.WriteLine($"Sprawdzono {coord1} - {coord2}");
                        var route = new RouteBetweenCoords(coord1, coord2);
                        route.ReadTravelsteps(result.Steps);
                        collection.AddOrUpdate(route, x => 0, (x, b) => 0);
                    }
                }

                done += 1;
                //PickingRoutesCalculationProgress?.Invoke(null, new CalculatePickingRouteProgressEventArgs()
                //{
                //	Done = done,
                //	IterationIndex = startIndex,
                //	Todo = todo,
                //	Elapsed = sw.Elapsed,
                //	CheckeCoord = coord1
                //});
            });
            var pickingSlotRoutes = new HashSet <RouteBetweenCoords>(collection.Keys);

            return(pickingSlotRoutes);
        }
Esempio n. 2
0
        public void CalculatePickingRoutes(PathSolver solver)
        {
            var coordsSet = new HashSet <Coord>(PickingSlots.Select(x => x.Value.Position))
            {
                GetPickingStartPosition(),
                GetPickingEndPosition()
            };
            var coords = coordsSet.ToArray();

            var collection = new ConcurrentDictionary <RouteBetweenCoords, byte>();
            int done       = 1;
            int todo       = coords.Length;
            var sw         = new Stopwatch();

            sw.Start();
            Parallel.For(0, coords.Length, startIndex =>
            {
                var coord1 = coords[startIndex];

                for (var endIndex = startIndex + 1; endIndex < PickingSlots.Count; endIndex++)
                {
                    var coord2 = coords[endIndex];
                    var result = solver.FindPath(new TravelStep(coord1), new TravelStep(coord2), false);
                    if (result.Success)
                    {
                        //Debug.WriteLine($"Sprawdzono {coord1} - {coord2}");
                        var route = new RouteBetweenCoords(coord1, coord2);
                        route.ReadTravelsteps(result.Steps);
                        collection.AddOrUpdate(route, x => 0, (x, b) => 0);
                    }
                }

                done += 1;
                PickingRoutesCalculationProgress?.Invoke(null, new CalculatePickingRouteProgressEventArgs()
                {
                    Done           = done,
                    IterationIndex = startIndex,
                    Todo           = todo,
                    Elapsed        = sw.Elapsed,
                    CheckeCoord    = coord1
                });
            });
            PickingSlotRoutes = new HashSet <RouteBetweenCoords>(collection.Keys);
        }