private void RandomTimer_Tick(object sender, EventArgs e) { int n = 3; if (rnd.Next(1, 10) == n) { while (true) { int index = rnd.Next(0, wh.GetRackList().Count - 1); if (wh.GetRackList()[index].RackStock.Count == 0) { wh.GetRackList()[index].Available = false; busy = true; countBusy++; wh.GetRackList()[index].DrawRack(); pbMain.BackgroundImage = wh.DrawAreas(); pbMain.Invalidate(); break; } } } if (countBusy == 2) { RandomTimer.Enabled = false; } }
/// <summary> /// Calls the method that starts the simulation, changes the visible controls /// on the left panel to controls relevant to the running simulation. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStartSim_Click(object sender, EventArgs e) { stats.st = DateTime.Now; // Records the date and time when the simulation started stats.realst = wh.ListOrders.Min(a => a.TimeStamp); //Stores the earliest order TimeStamp stats.NrAgv = wh.AGVList.Count; stats.NrOrders = wh.ListOrders.Count(); DrawArea = new Bitmap(pbMain.Size.Width, pbMain.Size.Height); TabControlSettings.SelectedTab = TabPageDuringSimulation; //simControlPanel.OnStopSim += (s, ec) => OnStopSimulation(simControlPanel); wh.AGVList.ForEach(x => x.LoadImage()); AGVtimer.Enabled = true; TimeLineTimer.Enabled = true; VisualizeElapsedTime(); //wh.AGVList[0].ShortestPath(400, 500, "INBOUND"); foreach (var order in wh.AGVList[0].OrderList) { foreach (var item in order.ItemsList) { foreach (var x in wh.GetRackList()) { if (x.Product != null) { if (item.productItem.ID == x.Product.ID) { ShortestPath(x.Position.X, x.Position.Y - 22); if (order.Type == "Inbound") { ShortestPath(150, 500); } else { ShortestPath(550, 500); } } } } } } }