Esempio n. 1
0
        /// <summary>
        /// wanneer het magazijn moet worden hervuld wordt deze methode aangeroepen
        /// deze methode geeft ook alle taken aan alle robots
        /// </summary>
        public void FillStorage()
        {
            foreach (Node n in Punten)
            {
                if (n.Id.Length == 4)
                {
                    n.Shelf = NotAssignedShelfs[0];
                    NotAssignedShelfs[0].Move(n.X, 0, n.Z);
                    NotAssignedShelfs.RemoveAt(0);
                    n.ShelfStatus = true;
                }
            }

            foreach (Robot r in RobotList)
            {
                if (r.TaskCount() == 0)
                {
                    Node AvailableDockNode = null;
                    AvailableDockNode             = Punten.FirstOrDefault(i => i.Id.Length == 4 && i.ShelfStatus == true);
                    AvailableDockNode.ShelfStatus = false;

                    List <Node> RobotRouteHeenweg = Nodes.Shortest_path("HA", AvailableDockNode.Id);
                    RobotMove   move = new RobotMove(RobotRouteHeenweg);
                    r.AddTask(move);

                    RobotPickUp pickup = new RobotPickUp(AvailableDockNode);
                    r.AddTask(pickup);

                    List <Node> RobotStoreShelf = Nodes.Shortest_path(AvailableDockNode.Id, "HB");
                    RobotMove   storeshelf      = new RobotMove(RobotStoreShelf);
                    r.AddTask(storeshelf);

                    Node EmptyShelfNode = null;
                    EmptyShelfNode             = Punten.FirstOrDefault(i => i.Id.Length == 1 && i.ShelfStatus == false);
                    EmptyShelfNode.ShelfStatus = true;

                    List <Node> RobotRouteTerugweg = Nodes.Shortest_path("HB", EmptyShelfNode.Id);
                    RobotMove   terugweg           = new RobotMove(RobotRouteTerugweg);
                    r.AddTask(terugweg);

                    RobotDropDown dropdown = new RobotDropDown(EmptyShelfNode);
                    r.AddTask(dropdown);
                    ShelfList.Add(EmptyShelfNode);

                    List <Node> RobotRouteStartPositie = Nodes.Shortest_path(EmptyShelfNode.Id, "HA");
                    RobotMove   startpositie           = new RobotMove(RobotRouteStartPositie);
                    r.AddTask(startpositie);
                    move.StartTask(r);
                    r.RobotBusy = true;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// geeft alle taken aan alle robots in de wereld
        /// </summary>
        public void AssignRobot()
        {
            foreach (Robot r in RobotList)
            {
                if (r.TaskCount() == 0)
                {
                    Random rnd             = new Random();
                    int    ShelfListStatus = 0;
                    ShelfListStatus = ShelfList.Count(i => i.ShelfStatus == true);
                    int  random = rnd.Next(0, ShelfListStatus - 1);
                    Node punt1  = ShelfList[random];
                    punt1.ShelfStatus = false;
                    NotAssignedShelfs.Add(punt1.Shelf);
                    ShelfList.RemoveAt(random);

                    List <Node> RobotRouteHeenweg = Nodes.Shortest_path("HA", punt1.Id);
                    RobotMove   move = new RobotMove(RobotRouteHeenweg);
                    r.AddTask(move);

                    RobotPickUp pickup = new RobotPickUp(punt1);
                    r.AddTask(pickup);
                    //Robot is naar de shelf positie gestuurd en pakt deze shelf op.
                    punt1.ShelfStatus = false;
                    //Zorgt ervoor dat bij de volgende itteratie de robot niet naar dezelfde shelf gestuurd kan worden.

                    List <Node> RobotRouteTerugweg = Nodes.Shortest_path(punt1.Id, "HB");
                    RobotMove   terugweg           = new RobotMove(RobotRouteTerugweg);
                    r.AddTask(terugweg);

                    Node AvailableDockNode = null;
                    AvailableDockNode             = Punten.FirstOrDefault(i => i.Id.Length == 4 && i.ShelfStatus == false);
                    AvailableDockNode.ShelfStatus = true;
                    List <Node> RobotStoreShelf = Nodes.Shortest_path("HB", AvailableDockNode.Id);
                    RobotMove   storeshelf      = new RobotMove(RobotStoreShelf);
                    r.AddTask(storeshelf);

                    RobotDropDown dropdown = new RobotDropDown(AvailableDockNode);
                    r.AddTask(dropdown);

                    List <Node> RobotRouteStartPositie = Nodes.Shortest_path(AvailableDockNode.Id, "HA");
                    RobotMove   startpositie           = new RobotMove(RobotRouteStartPositie);
                    r.AddTask(startpositie);
                    move.StartTask(r);
                    r.RobotBusy   = true;
                    VullenStorage = false;
                }
            }
        }