Ejemplo n.º 1
0
        public static string AutoSelecSlotPallet(List <Pallet> listPallet)
        {
            string palletLocation = "NaNN";
            string AtBlock        = "D";

            int AtColumn = 6;
            int AtLevel  = 1;
            //Pallet pl = listPallet.Find(p=> pallet.AtBlock == AtBlock && pallet.AtColumn == AtColumn && pallet.AtLevel == AtLevel)
            //listPallet.Contains(p=> p.AtBlock == AtBlock && p.AtColumn == AtColumn && p.AtLevel == AtLevel)
            Pallet pallet = listPallet.Find(p => p.AtBlock == AtBlock && p.AtColumn == AtColumn && p.AtLevel == AtLevel);

            while (listPallet.FindIndex(p => p.AtBlock == AtBlock && p.AtColumn == AtColumn && p.AtLevel == AtLevel) != -1)
            {
                AtLevel += 1;
                if (AtLevel == 4)
                {
                    AtLevel   = 1;
                    AtColumn -= 1;
                    if (AtColumn == 0)
                    {
                        AtColumn = 6;

                        switch (AtBlock)
                        {
                        case "D":
                            AtBlock = "C";
                            break;

                        case "C":
                            AtBlock = "B";
                            break;

                        case "B":
                            AtBlock = "A";
                            break;

                        case "A":
                            AtBlock = "NaN";
                            break;
                        }
                    }
                }
            }
            palletLocation = AtBlock + "," + AtColumn.ToString() + "," + AtLevel.ToString();
            //palletLocation = "FullSlot";
            return(palletLocation);
        }
Ejemplo n.º 2
0
        public static void DeleteLabelPallet(Pallet pallet)
        {
            switch (pallet.AtBlock)
            {
            case "A":
                Display.ASlotLabel[pallet.AtColumn - 1, pallet.AtLevel - 1].BackColor = Color.Silver;
                break;

            case "B":
                Display.BSlotLabel[pallet.AtColumn - 1, pallet.AtLevel - 1].BackColor = Color.Silver;
                break;

            case "C":
                Display.CSlotLabel[pallet.AtColumn - 1, pallet.AtLevel - 1].BackColor = Color.Silver;
                break;

            case "D":
                Display.DSlotLabel[pallet.AtColumn - 1, pallet.AtLevel - 1].BackColor = Color.Silver;
                break;
            }
        }
Ejemplo n.º 3
0
        private void btnStore_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtPalletCode.Text) || String.IsNullOrEmpty(txtPalletName.Text) ||
                String.IsNullOrEmpty(cbbBlock.Text) || String.IsNullOrEmpty(cbbColumn.Text) || String.IsNullOrEmpty(cbbLevel.Text))
            {
                MessageBox.Show(" Please enter correct Pallet informarion !", "Pallet Information ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //int agvID = Task.AutoSelectAGV(AGV.SimListAGV, Input);
            int        agvID      = 1;
            RackColumn rack       = RackColumn.ListColumn.Find(c => c.Block == cbbBlock.Text && c.Number == Convert.ToInt32(cbbColumn.Text));
            string     palletcode = txtPalletCode.Text;
            string     palletName = txtPalletName.Text;
            int        pickNode   = Input;
            int        pickLevel  = 1;

            int dropNode  = rack.AtNode;
            int dropLevel = Convert.ToInt32(cbbLevel.Text);

            switch (Display.Mode)
            {
            case "Real Time":
                foreach (Pallet palet in Pallet.ListPallet)
                {
                    if (palet.Code.Trim() == txtPalletCode.Text)
                    {
                        MessageBox.Show("Pallet has stored in stock !", "Store Pallet Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (palet.AtBlock == cbbBlock.Text && palet.AtColumn == Convert.ToInt32(cbbColumn.Text) && palet.AtLevel == Convert.ToInt32(cbbLevel.Text))
                    {
                        MessageBox.Show("Slot is not available !", "Store Pallet Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                break;

            case "Simulation":
                foreach (Pallet palet in Pallet.SimListPallet)
                {
                    if (palet.Code.Trim() == txtPalletCode.Text)
                    {
                        MessageBox.Show("Pallet has stored in stock !", "Store Pallet Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (palet.AtBlock == cbbBlock.Text && palet.AtColumn == Convert.ToInt32(cbbColumn.Text) && palet.AtLevel == Convert.ToInt32(cbbLevel.Text))
                    {
                        MessageBox.Show("Slot is not available !", "Store Pallet Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                break;
            }


            Task task = new Task("Store1", "Store", palletcode, agvID,
                                 pickNode, dropNode, pickLevel, dropLevel
                                 , "Waiting");
            Pallet pallet = new Pallet(palletcode, palletName, true, "??", cbbBlock.Text, Convert.ToInt32(cbbColumn.Text), Convert.ToInt32(cbbLevel.Text));

            switch (Display.Mode)
            {
            case "Real Time":
                int AGVindex = AGV.ListAGV.FindIndex(a => { return(a.ID == agvID); });
                AGV.ListAGV[AGVindex].Tasks.Add(task);
                Task.ListTask.Add(task);
                Pallet.StorePallet.Add(pallet);
                break;

            case "Simulation":
                int SimAGVindex = AGV.SimListAGV.FindIndex(a => { return(a.ID == agvID); });
                AGV.SimListAGV[SimAGVindex].Tasks.Add(task);
                Task.SimListTask.Add(task);
                Pallet.SimStorePallet.Add(pallet);
                break;
            }
            ckbAutoSelectSlot.Checked = false;
            cbbBlock.Enabled          = true;
            cbbColumn.Enabled         = true;
            cbbLevel.Enabled          = true;
        }
Ejemplo n.º 4
0
        public static void SimUpdatePathFromTaskOfAGVs(AGV agv)
        {
            // Clear all path (this do not affect Task.SimListTask)
            //agv.Tasks.Clear();

            // Find all task of this AGV
            //agv.Tasks = Task.SimListTask.FindAll(t => t.AGVID == agv.ID);&& agv.Path.Count ==0

            // if not having task or path has been initialized, skip to next AGV
            if (agv.Tasks.Count != 0)
            {
                Task currentTask = agv.Tasks[0];

                //agv.Path.RemoveAt(0);agv.CurrentNode != currentTask.PickNode &&
                if (currentTask.Status == "Waiting")
                {
                    agv.Path.Clear();
                    agv.Path.Add(Algorithm.A_starFindPath(Node.ListNode, Node.MatrixNodeDistance, agv.CurrentNode, agv.Tasks[0].PickNode));
                    AGV.SimFullPathOfAGV[agv.ID] = Navigation.GetNavigationFrame(agv.Path[0], Node.MatrixNodeOrient);
                    agv.Tasks[0].Status          = "Doing";
                    agv.PathCopmpleted           = 0;
                    agv.Status = "Running";
                    Display.SimLabelAGV[agv.ID].BackColor = Color.CornflowerBlue;
                }

                else if (agv.CurrentNode == currentTask.PickNode && currentTask.Status == "Doing" && agv.PathCopmpleted == 1)
                {
                    agv.Path.RemoveAt(0);
                    agv.Path.Add(Algorithm.A_starFindPath(Node.ListNode, Node.MatrixNodeDistance, agv.CurrentNode, agv.Tasks[0].DropNode));

                    AGV.SimFullPathOfAGV[agv.ID] = Navigation.GetNavigationFrame(agv.Path[0], Node.MatrixNodeOrient);
                    agv.HavePallet = true;
                    if (currentTask.Type == "Order")
                    {
                        Pallet pallet = Pallet.SimListPallet.Find(c => c.Code == currentTask.PalletCode);
                        Display.DeleteLabelPallet(pallet);
                    }
                    else if (currentTask.Type == "Store")
                    {
                    }
                }
                else if ((agv.CurrentNode == currentTask.DropNode && currentTask.Status == "Doing" && agv.PathCopmpleted == 2))
                {
                    agv.Tasks.RemoveAt(0);
                    agv.Path.Clear();
                    agv.Status = "Stop";
                    Display.SimLabelAGV[agv.ID].BackColor = Color.Silver;
                    string timeComplete = DateTime.Now.ToString("dddd, MMMM dd, yyyy  h:mm:ss tt");
                    DBUtility.InsertCompleteTaskToDB("SimHistoryTask", currentTask, timeComplete, "Done");
                    agv.HavePallet = false;
                    if (currentTask.Type == "Order")
                    {
                        DBUtility.DeletePalletFromDB("SimPalletInfoTable", currentTask.PalletCode);

                        Task.SimListTask.Remove(currentTask);
                    }
                    else if (currentTask.Type == "Store")
                    {
                        //agv.HavePallet = false;
                        Pallet pallet = Pallet.SimStorePallet.Find(c => c.Code == currentTask.PalletCode);
                        pallet.DeliverTime = DateTime.Now.ToString("dddd, MMMM dd, yyyy  h:mm:ss tt");
                        DBUtility.InsertNewPalletToDB("SimPalletInfoTable", pallet.Code, pallet.Name, pallet.InStock, pallet.DeliverTime, pallet.AtBlock, pallet.AtColumn, pallet.AtLevel);
                        Pallet.SimStorePallet.Remove(pallet);
                        Pallet.SimListPallet.Add(pallet);
                        Display.UpdateLabelPallet(pallet);
                        Task.SimListTask.Remove(currentTask);
                    }
                    else if (currentTask.Type == "Input" || currentTask.Type == "Output")
                    {
                        Task.SimListTask.Remove(currentTask);
                    }
                }
            }
            else
            {
                if (agv.CurrentNode == 55)
                {
                    agv.Status = "Stop";
                    agv.Path.Clear();
                }
            }
        }