示例#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;
                }
            }
        }
示例#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;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Checks which robot is the closest to the rack and gives the task to the closest robot.
        /// </summary>
        public void giveTask()
        {
            if (_Inventory.Tasks.Count != 0)
            {
                //Sets for every robot the distance to the rack
                foreach (Model3D model3d in worldObjects)
                {
                    if (model3d is Robots)
                    {
                        Robots robot      = (Robots)model3d;
                        double closestToX = robot.x - _Inventory.Tasks.First().getRack.x;
                        double closestToZ = robot.z - _Inventory.Tasks.First().getRack.z;
                        robot.closestTo = Math.Sqrt(Math.Pow(closestToX, 2) + Math.Pow(closestToZ, 2));
                    }
                }

                //Checking which robot is the closest
                foreach (Model3D model3d in worldObjects)
                {
                    if (model3d is Robots)
                    {
                        Robots robot = (Robots)model3d;
                        if (robot.closestTo < this.closestTo || robot.closestTo == this.closestTo)
                        {
                            this.closestTo = robot.closestTo;
                            destined       = robot;
                        }
                    }
                }

                //Is giving the robot the task
                if (robotMove == null && destined == this && !_Inventory.Tasks.First().getRack.moving)
                {
                    robotMove = new RobotMove(_Inventory.Tasks.First(), this, Grid);
                    _Inventory.Tasks.RemoveAt(0);
                }
                destined = null;
            }
        }
示例#4
0
        /// <summary>
        /// Overrides the methode Update from the class Model3D.
        /// </summary>
        /// <param name="tick">Over how many milliseconds it has to check itself</param>
        /// <returns>true or false</returns>
        public override bool Update(int tick)
        {
            giveTask();

            if (robotMove != null)
            {
                if (robotMove.TaskComplete(this))
                {
                    Console.WriteLine("override bool update");

                    robotMove = null;
                    return(false);
                }
                else if (!robotMove.TaskComplete(this))
                {
                    robotMove.StartTask(this);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
 private void SetTasks()
 {
     IRobotTask rt = new RobotMove();
 }