Exemplo n.º 1
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));
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Waits Event Answer Station Disponibility
        /// </summary>
        /// <param name="pOccupy"></param>
        private void NotificarSpotAvalible(Station istation, bool pOccupy)
        {
            Station Sin = LStations.Where(x => x.idStation == istation.idStation).FirstOrDefault();
            Sin.Occupy = pOccupy;
            Sin.MaxNBoxes = istation.MaxNBoxes;

            if (pOccupy == true)
                {
                LimitMaxonLine = LimitMaxonLine - 1;
                Console.WriteLine(string.Format(" Station:{0} Bussy!", Sin.idStation.ToString()));
                }
            else
                {
                LimitMaxonLine = LimitMaxonLine + 1;
                Console.WriteLine(string.Format(" Station:{0} Free!", Sin.idStation.ToString()));
                }
        }