コード例 #1
0
        public ResultRobotReady GetRobotUnityWaitTaskItem0()
        {
            ResultRobotReady result = null;

            int index = 0;

            while (RobotUnityWaitTaskList.Count > 0)
            {
                try
                {
                    RobotUnity robot = RobotUnityWaitTaskList[index];
                    if (robot != null)
                    {
                        if (robot.properties.IsConnected)
                        {
                            result = new ResultRobotReady()
                            {
                                robot = robot, onReristryCharge = robot.getBattery()
                            };
                            break;
                        }
                    }

                    if (index++ >= RobotUnityWaitTaskList.Count)
                    {
                        break;
                    }
                }
                catch
                {
                    break;
                }
            }

            return(result);
        }
コード例 #2
0
        public ResultRobotReady GetRobotUnityReadyItem0()
        {
#if true
            ResultRobotReady result = null;
            foreach (RobotUnity rbRd in RobotUnityReadyList)
            {
                if (rbRd.properties.IsConnected)
                {
                    result = new ResultRobotReady()
                    {
                        robot = rbRd, onReristryCharge = rbRd.getBattery()
                    };
                    if (rbRd.getBattery())
                    {
                        rbRd.setColorRobotStatus(RobotStatusColorCode.ROBOT_STATUS_CHARGING);
                        RemoveRobotUnityReadyList(rbRd);
                    }
                    break;
                }
            }
            //while (RobotUnityReadyList.Count > 0)
            //{
            //    try
            //    {
            //        if (indexRd >= RobotUnityReadyList.Count)
            //        {
            //            indexRd = 0;
            //        }
            //        RobotUnity robot = RobotUnityReadyList[indexRd];
            //        indexRd++;
            //        if (robot != null)
            //        {
            //            if (robot.properties.IsConnected)
            //            {
            //                result = new ResultRobotReady() { robot = robot, onReristryCharge = robot.getBattery() };
            //                if (robot.getBattery())
            //                {
            //                    robot.setColorRobotStatus(RobotStatusColorCode.ROBOT_STATUS_CHARGING);
            //                    RemoveRobotUnityReadyList(robot);
            //                }
            //                break;
            //            }
            //        }

            //    }
            //    catch (Exception e)
            //    {
            //        indexRd = 0;
            //        Console.WriteLine("Error ReadyTask in  RobotManagement Service Remove Robot");
            //        Console.WriteLine(e);
            //    }
            //}

            return(result);
#else
            ResultRobotReady result = null;
            if (RobotUnityReadyList.Count > 0)
            {
                int index = 0;
                do
                {
                    RobotUnity robot = RobotUnityReadyList[index];
                    try
                    {
                        if (robot.properties.IsConnected)
                        {
                            result = new ResultRobotReady()
                            {
                                robot = robot, onReristryCharge = robot.getBattery()
                            };
                            if (robot.getBattery())
                            {
                                RemoveRobotUnityReadyList(robot);
                            }

                            break;
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Error ReadyTask in  RobotManagement Service Remove Robot");
                    }
                    index++;
                }while (RobotUnityReadyList.Count < index && RobotUnityReadyList.Count > 0);
            }
            return(result);
#endif
        }
コード例 #3
0
        public ResultRobotReady GetRobotUnityWaitTaskItem0()
        {
#if true
            ResultRobotReady result = null;
            foreach (RobotUnity rbWt in RobotUnityWaitTaskList)
            {
                if (rbWt.properties.IsConnected)
                {
                    result = new ResultRobotReady()
                    {
                        robot = rbWt, onReristryCharge = rbWt.getBattery()
                    };
                    break;
                }
            }
            //ResultRobotReady result = null;
            //while (RobotUnityWaitTaskList.Count > 0)
            //{
            //    try
            //    {
            //        if (indexWt >= RobotUnityWaitTaskList.Count)
            //        {
            //            indexWt = 0;
            //        }
            //        RobotUnity robot = RobotUnityWaitTaskList[indexWt];
            //        indexWt++;
            //        if (robot != null)
            //        {
            //            if (robot.properties.IsConnected)
            //            {
            //                result = new ResultRobotReady() { robot = robot, onReristryCharge = robot.getBattery() };
            //                break;
            //            }
            //        }

            //    }
            //    catch (Exception e)
            //    {
            //        indexWt = 0;
            //        Console.WriteLine("Error ReadyTask in  RobotManagement Service Remove Robot");
            //        Console.WriteLine(e);
            //    }
            //}

            return(result);
#else
            ResultRobotReady result = null;

            int index = 0;
            while (RobotUnityWaitTaskList.Count > 0)
            {
                try
                {
                    RobotUnity robot = RobotUnityWaitTaskList[index];
                    if (robot != null)
                    {
                        if (robot.properties.IsConnected)
                        {
                            result = new ResultRobotReady()
                            {
                                robot = robot, onReristryCharge = robot.getBattery()
                            };
                            break;
                        }
                    }

                    if (index++ >= RobotUnityWaitTaskList.Count)
                    {
                        break;
                    }
                }
                catch
                {
                    break;
                }
            }

            return(result);
#endif
        }
コード例 #4
0
        public bool AssignWaitTask(OrderItem order)
        {
            processAssignAnTaskWait = ProcessAssignAnTaskWait.PROC_ANY_GET_ANROBOT_IN_WAITTASKLIST;
            OrderItem  orderItem_wait = null;
            RobotUnity robotwait      = null;

            while (true)
            {
                switch (processAssignAnTaskWait)
                {
                case ProcessAssignAnTaskWait.PROC_ANY_IDLE:
                    break;

                case ProcessAssignAnTaskWait.PROC_ANY_GET_ANROBOT_IN_WAITTASKLIST:
                    if (robotManageService.RobotUnityWaitTaskList.Count > 0)
                    {
                        ResultRobotReady result = robotManageService.GetRobotUnityWaitTaskItem0();
                        if (result != null)
                        {
                            robotwait = result.robot;
                            if (result.onReristryCharge)
                            {
                                procedureService.Register(ProcedureItemSelected.PROCEDURE_ROBOT_TO_READY, robotwait, null);
                                robotManageService.RemoveRobotUnityWaitTaskList(robotwait);
                            }
                            else
                            {
                                if (order != null)
                                {
                                    processAssignAnTaskWait = ProcessAssignAnTaskWait.PROC_ANY_CHECK_HAS_ANTASK;
                                    break;
                                }
                                else
                                {
                                    processAssignAnTaskWait = ProcessAssignAnTaskWait.PROC_ANY_CHECK_ROBOT_GOTO_READY;     // mở lại
                                    break;
                                }
                            }
                        }
                    }
                    return(false);

                case ProcessAssignAnTaskWait.PROC_ANY_CHECK_HAS_ANTASK:
                    orderItem_wait = order;
                    //orderItem_wait.onAssiged = true;
                    processAssignAnTaskWait = ProcessAssignAnTaskWait.PROC_ANY_ASSIGN_ANTASK;
                    orderItem_wait.robot    = robotwait.properties.Label;
                    robotwait.orderItem     = orderItem_wait;
                    //  MoveElementToEnd();
                    break;

                case ProcessAssignAnTaskWait.PROC_ANY_CHECK_ROBOT_GOTO_READY:
                    robotwait.TurnOnSupervisorTraffic(true);
                    procedureService.Register(ProcedureItemSelected.PROCEDURE_ROBOT_TO_READY, robotwait, null);
                    Console.WriteLine(robotwait.properties.Label + " Assign goto ready_____________(-_-)______________");
                    robotManageService.RemoveRobotUnityWaitTaskList(robotwait);
                    return(false);

                case ProcessAssignAnTaskWait.PROC_ANY_ASSIGN_ANTASK:
                    robotwait.TurnOnSupervisorTraffic(true);
                    SelectProcedureItem(robotwait, orderItem_wait);
                    deviceItemsList[0].RemoveFirstOrder();
                    robotManageService.RemoveRobotUnityWaitTaskList(robotwait);
                    processAssignAnTaskWait = ProcessAssignAnTaskWait.PROC_ANY_GET_ANROBOT_IN_WAITTASKLIST;
                    orderItem_wait.status   = StatusOrderResponseCode.DELIVERING;
                    return(true);
                }
                Thread.Sleep(10);
            }
        }
コード例 #5
0
        public bool AssignTaskAtReady(OrderItem order)
        {
            processAssignTaskReady = ProcessAssignTaskReady.PROC_READY_GET_ANROBOT_INREADYLIST;
            OrderItem  orderItem_ready = null;
            RobotUnity robotatready    = null;

            while (true)
            {
                switch (processAssignTaskReady)
                {
                case ProcessAssignTaskReady.PROC_READY_IDLE:
                    break;

                case ProcessAssignTaskReady.PROC_READY_GET_ANROBOT_INREADYLIST:
                    if (robotManageService.RobotUnityReadyList.Count > 0)
                    {
                        ResultRobotReady result = robotManageService.GetRobotUnityReadyItem0();
                        if (result != null)
                        {
                            robotatready = result.robot;
                            if ((true == result.onReristryCharge) || (robotatready.properties.enableChage == true))
                            {
                                procedureService.Register(ProcedureItemSelected.PROCEDURE_ROBOT_TO_CHARGE, robotatready, null);
                                robotManageService.RemoveRobotUnityReadyList(robotatready);
                            }
                            else
                            {
                                if (order != null)
                                {
                                    if (!trafficService.HasOtherRobotUnityinArea("READY", robotatready))
                                    {
                                        if (order.typeReq == TyeRequest.TYPEREQUEST_FORLIFT_TO_BUFFER || order.typeReq == TyeRequest.TYPEREQUEST_FORLIFT_TO_MACHINE)
                                        {
                                            if (trafficService.HasOtherRobotUnityinArea("GATE", robotatready))
                                            {
                                                // MoveElementToEnd();
                                            }
                                            else
                                            {
                                                if (TrafficRountineConstants.RegIntZone_READY.ProcessRegistryIntersectionZone(robotatready))
                                                {
                                                    processAssignTaskReady = ProcessAssignTaskReady.PROC_READY_CHECK_HAS_ANTASK;
                                                    break;
                                                }
                                                else
                                                {
                                                    TrafficRountineConstants.RegIntZone_READY.Release(robotatready);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (TrafficRountineConstants.RegIntZone_READY.ProcessRegistryIntersectionZone(robotatready))
                                            {
                                                processAssignTaskReady = ProcessAssignTaskReady.PROC_READY_CHECK_HAS_ANTASK;
                                                break;
                                            }
                                            else
                                            {
                                                TrafficRountineConstants.RegIntZone_READY.Release(robotatready);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    return(false);

                case ProcessAssignTaskReady.PROC_READY_CHECK_HAS_ANTASK:
                    orderItem_ready = order;
                    //  orderItem_ready.onAssiged = true;
                    Console.WriteLine(processAssignTaskReady);
                    orderItem_ready.robot  = robotatready.properties.Label;
                    robotatready.orderItem = orderItem_ready;
                    processAssignTaskReady = ProcessAssignTaskReady.PROC_READY_ASSIGN_ANTASK;
                    // MoveElementToEnd();
                    break;

                case ProcessAssignTaskReady.PROC_READY_ASSIGN_ANTASK:
                    TrafficRountineConstants.RegIntZone_READY.Release(robotatready);
                    robotatready.TurnOnSupervisorTraffic(true);
                    Console.WriteLine(processAssignTaskReady);
                    SelectProcedureItem(robotatready, orderItem_ready);
                    deviceItemsList[0].RemoveFirstOrder();
                    robotManageService.RemoveRobotUnityReadyList(robotatready);
                    orderItem_ready.status = StatusOrderResponseCode.DELIVERING;
                    processAssignTaskReady = ProcessAssignTaskReady.PROC_READY_CHECK_ROBOT_OUTSIDEREADY;
                    return(true);
                }
                Thread.Sleep(10);
            }
        }