Example #1
0
 public void DepartureRobot(Robot iRobot)
 {
     Console.WriteLine(string.Format(" Robot:{0} , Leaving  Station{1}", iRobot.idRobot.ToString(), idStation.ToString()));
     StationActivity(this,false);
     RobotActivity(iRobot, false);
     Console.WriteLine(string.Format(" Avalible spaces on Station!{0} : {1}", idStation.ToString(), MaxNBoxes.ToString()));
 }
Example #2
0
        public void ArriveRobot(Robot iRobot)
        {
            Console.WriteLine(string.Format(" Robot:{0} ,Arrive on Station!{1}", iRobot.idRobot.ToString(), idStation.ToString()));
            StationActivity(this, true);
            RobotActivity(iRobot, true);
            do
                {
                if (MaxNBoxes >= 1)
                    {
                    LeaveBox(iRobot);
                    }
                } while (iRobot.NBoxes >= 1);

            DepartureRobot(iRobot);
        }
Example #3
0
        /// <summary>
        /// Executes Program
        /// </summary>
        /// <returns></returns>
        public ErrorProduccion Start()
        {
            ErrorProduccion ER = CrearProduccion(Robots, Stations, BoxperRobot, BoxLimitsStation, StockWharehouse);

            Console.WriteLine(ER.Reason);
            if (ER.Pass)
                {
                do
                    {
                    //Console.WriteLine(string.Format("Number of Boxes {0}", StockWharehouse.ToString()));
                    //Console.WriteLine(string.Format("Number of Avalible Robots {0}", LRobots.Where(x => x.Busy == false && x.NBoxes >= 1).Count().ToString()));
                    //Console.WriteLine(string.Format("Number of Avalible Stations {0} ", LStations.Where(x => x.Occupy == false && x.MaxNBoxes >= 1).Count().ToString()));
                    //Console.WriteLine(string.Format("Number of Avalible Lines {0}", LimitMaxonLine.ToString()));

                    if (LRobots.Where(x => x.Busy == false && x.NBoxes >= 1).ToList().Count >= 1 ? true : false)
                        {
                        foreach (var iRobot in LRobots.Where(x => x.Busy == false && x.NBoxes >= 1).ToList())
                            {
                            Robot tempRob = new Robot() { Busy = iRobot.Busy, idRobot = iRobot.idRobot, NBoxes = iRobot.NBoxes, NSiguientePosicion = iRobot.NSiguientePosicion };

                            Console.WriteLine(string.Format("Send Robot:{0} ", tempRob.idRobot.ToString()));
                            ///Code SendRobot
                            Station iStation = LStations.Where(x => x.Occupy == false && x.MaxNBoxes >= 1).FirstOrDefault();
                            Station tempStation = new Station() { Occupy = iStation.Occupy, idStation = iStation.idStation, MaxNBoxes = iStation.MaxNBoxes };

                            iRobot.NSiguientePosicion = tempStation.idStation;
                            tempStation.RobotActivity += new Station.delRobot(NotificarArriveRobot);
                            tempStation.StationActivity += new Station.delStation(NotificarSpotAvalible);
                            ///
                            Thread T = new Thread(() =>  tempStation.ArriveRobot(iRobot));
                            T.Start();
                           T.Join();
                            }
                        }// Thread.Sleep(2000);
                    } while (AvalibleSpace() == true && AvalibleStationsAndRobots() == true);
                }

            //Thread.Sleep(2000);
            Console.WriteLine(string.Format("Number of Avalible Stock {0}", StockWharehouse.ToString()));
            Console.WriteLine(string.Format("Number of Avalible Robots {0}", LRobots.Where(x => x.Busy == false && x.NBoxes >= 1).Count().ToString()));
            Console.WriteLine(string.Format("Number of Avalible Stations {0} ", LStations.Where(x => x.Occupy == false && x.MaxNBoxes >= 1).Count().ToString()));
            Console.WriteLine(string.Format("Number of Avalible Lines {0}", LimitMaxonLine.ToString()));
            Console.WriteLine(string.Format("Process Finished, Total Emty spaces on Stations {0}.", LStations.Select(x => x.MaxNBoxes).Sum().ToString()));
            Console.Read();
            return ER;
        }
Example #4
0
 public void LeaveBox(Robot iRobot)
 {
     Console.WriteLine(string.Format(" Robot:{0} , Droping Box on Station:{1}", iRobot.idRobot.ToString(), idStation.ToString()));
     iRobot.NBoxes = iRobot.NBoxes - 1;
     MaxNBoxes = MaxNBoxes - 1;
     //Thread.Sleep(2000);
 }
Example #5
0
        /// <summary>
        /// Send CUrrent Robot to look For an avalible Station.
        /// </summary>
        /// <param name="iRobot"></param>
        private void SendNewRobot(Robot iRobot)
        {
            do
                {
                Station iStation = LStations.Where(x => x.Occupy == false && x.MaxNBoxes >= 1).FirstOrDefault();
                Station tempStation = new Station() { Occupy = iStation.Occupy, idStation = iStation.idStation, MaxNBoxes = iStation.MaxNBoxes };

                iRobot.NSiguientePosicion = tempStation.idStation;
                tempStation.RobotActivity += new Station.delRobot(NotificarArriveRobot);
                tempStation.StationActivity += new Station.delStation(NotificarSpotAvalible);
                tempStation.ArriveRobot(iRobot);
                } while (AvalibleBoxes(iRobot));
        }
Example #6
0
 /// <summary>
 /// wait event answer Robot Disponibility
 /// </summary>
 /// <param name="iRobot"></param>
 /// <param name="pOccupy"></param>
 private void NotificarArriveRobot(Robot iRobot, bool pOccupy)
 {
     Robot Rin = LRobots.Where(x => x.idRobot == iRobot.idRobot).FirstOrDefault();
     Rin.Busy = pOccupy;
     Rin.NBoxes = iRobot.NBoxes;
     if (pOccupy == true)
         {
         Console.WriteLine(string.Format(" Robot:{0} Bussy!", Rin.idRobot.ToString()));
         }
     else
         {
         Console.WriteLine(string.Format(" Robot:{0} Free!", Rin.idRobot.ToString()));
         }
 }
Example #7
0
 /// <summary>
 /// return if the Robot Contains more Boxes
 /// </summary>
 /// <param name="iRobot"></param>
 /// <returns></returns>
 private bool AvalibleBoxes(Robot iRobot)
 {
     return iRobot.NBoxes >= 1 ? true : false;
 }