Пример #1
0
        public static void UpdatePathFromTaskOfAGV(AGV agv)
        {
            if (agv.Tasks.Count != 0)
            {
                Task currentTask = agv.Tasks[0];
                if (currentTask.Status == "Waiting")
                {
                    Debug.WriteLine("AAAAA");
                    agv.Path.Clear();
                    agv.Path.Add(Algorithm.A_starFindPath(Node.ListNode, Node.MatrixNodeDistance, agv.CurrentNode, agv.Tasks[0].PickNode));
                    AGV.FullPathOfAGV[agv.ID] = "N-0-" + agv.CurrentOrient + "-" + Navigation.GetNavigationFrame(agv.Path[0], Node.MatrixNodeOrient) + "-N-0";
                    Communication.SendPathData(AGV.FullPathOfAGV[agv.ID]);
                    Display.UpdateComStatus("send", agv.ID, "Send Path 1", Color.Green);

                    // if(DashboardForm.timerToSendPathAgain.Enabled == false)
                    //   DashboardForm.timerToSendPathAgain.Start();

                    //  agv.Tasks[0].Status = "Doing";
                    agv.PathCopmpleted = 0;
                    //  agv.Status = "Running";
                }
                else if (agv.CurrentNode == currentTask.PickNode && currentTask.Status == "Doing" && agv.PathCopmpleted == 1)
                {
                    Debug.WriteLine("BBBB");
                    agv.Path.RemoveAt(0);
                    agv.Path.Add(Algorithm.A_starFindPath(Node.ListNode, Node.MatrixNodeDistance, agv.CurrentNode, agv.Tasks[0].DropNode));
                    string pick, drop;
                    if (currentTask.PickLevel == 1 || currentTask.PickLevel == 2 || currentTask.PickLevel == 3)
                    {
                        pick = "P-" + currentTask.PickLevel.ToString() + "-";
                    }
                    else
                    {
                        pick = "N-0-";
                    }
                    if (currentTask.DropLevel == 1 || currentTask.DropLevel == 2 || currentTask.DropLevel == 3)
                    {
                        drop = "-D-" + currentTask.DropLevel.ToString();
                    }
                    else
                    {
                        drop = "-N-0";
                    }
                    AGV.FullPathOfAGV[agv.ID] = pick + agv.CurrentOrient + "-" + Navigation.GetNavigationFrame(agv.Path[0], Node.MatrixNodeOrient) + drop;
                    Communication.SendPathData(AGV.FullPathOfAGV[agv.ID]);

                    Display.UpdateComStatus("send", agv.ID, "Send Path 2", Color.Green);

                    // if (DashboardForm.timerToSendPathAgain.Enabled == false)
                    //    DashboardForm.timerToSendPathAgain.Start();

                    //  agv.PathCopmpleted = 2;
                }
                else if (agv.CurrentNode == currentTask.DropNode && currentTask.Status == "Doing" && agv.PathCopmpleted == 3)
                {
                    Debug.WriteLine("CCCC");
                    agv.Tasks.RemoveAt(0);
                    agv.Path.Clear();
                    agv.Status = "Stop";
                }
            }
        }