Example #1
0
 // public override event Action<Object> ErrorProcedureHandler;
 public ProcedureRobotToReady(RobotUnity robot, ChargerId id, TrafficManagementService trafficService, ChargerManagementService chargerService, Pose PointCheckIn) : base(robot, trafficService)
 {
     StateRobotGoToReady = RobotGoToReady.ROBREA_IDLE;
     this.robot          = robot;
     this.Traffic        = trafficService;
     this.charger        = chargerService;
     this.chardgeId      = id;
     this.robot.ShowText("this.chardgeId" + this.chardgeId);
     procedureCode = ProcedureCode.PROC_CODE_ROBOT_TO_READY;
 }
Example #2
0
        public void Start(RobotGoToReady state = RobotGoToReady.ROBREA_SELECT_BEHAVIOR_ONZONE)
        {
            order               = new OrderItem();
            order.typeReq       = TyeRequest.TYPEREQUEST_GOTO_READY;
            errorCode           = ErrorCode.RUN_OK;
            robot.robotTag      = RobotStatus.WORKING;
            robot.ProcedureAs   = ProcedureControlAssign.PRO_READY;
            StateRobotGoToReady = state;
            ProRobotToReady     = new Thread(this.Procedure);
            procedureCode       = ProcedureCode.PROC_CODE_ROBOT_TO_READY;
            ProRun              = true;
            //robot.prioritLevel.OnAuthorizedPriorityProcedure = false;
            order.startTimeProcedure = DateTime.Now;

            points.PointCheckIn          = null;
            points.PointFrontLine        = GetFrontLineChargeStation();
            points.PointOfCharger        = GetPointOfCharger();
            registryRobotJourney         = new RegistryRobotJourney();
            registryRobotJourney.robot   = robot;
            registryRobotJourney.traffic = Traffic;
            ProRobotToReady.Start(this);
            cntOrderItem = 0;
            robot.bayId  = -1;
        }
Example #3
0
        public void Procedure(object ojb)
        {
            ProcedureRobotToReady    RbToRd  = (ProcedureRobotToReady)ojb;
            RobotUnity               rb      = RbToRd.robot;
            DataRobotToReady         p       = RbToRd.points;
            TrafficManagementService Traffic = RbToRd.Traffic;

            robot.ShowText(" start -> " + procedureCode + "_________________0000000000000000000_____________________");
            while (ProRun)
            {
                switch (StateRobotGoToReady)
                {
                case RobotGoToReady.ROBREA_IDLE:
                    //robot.ShowText("ROBREA_IDLE");
                    break;

                case RobotGoToReady.ROBREA_SELECT_BEHAVIOR_ONZONE:
                    robot.ShowText("ROBREA_SELECT_BEHAVIOR_ONZONE");
                    if (Traffic.RobotIsInArea("READY", robot.properties.pose.Position, TypeZone.OPZS))
                    {
                        robot.ShowText("ROBREA_ROBOT_RELEASED");
                        StateRobotGoToReady = RobotGoToReady.ROBREA_ROBOT_RELEASED;
                    }
                    if (rb.SendPoseStamped(p.PointFrontLine))
                    {
                        StateRobotGoToReady = RobotGoToReady.ROBREA_ROBOT_WAITTING_GOTO_READYSTATION_REG;
                        robot.ShowText("ROBREA_ROBOT_GOTO_FRONTLINE_READYSTATION");
                        registryRobotJourney.startPlaceName = Traffic.DetermineArea(robot.properties.pose.Position);
                        registryRobotJourney.startPoint     = robot.properties.pose.Position;
                        registryRobotJourney.endPoint       = p.PointFrontLine.Position;
                    }
                    break;

                case RobotGoToReady.ROBREA_ROBOT_WAITTING_GOTO_READYSTATION_REG:     // Robot dang di toi dau line ready station
                    if (TrafficRountineConstants.DetetectInsideStationCheck(registryRobotJourney))
                    {
                        if (DetermineHasTaskWaitingAnRobotAvailable())
                        {
                            StateRobotGoToReady = RobotGoToReady.ROBREA_ROBOT_WAITINGREADY_FORCERELEASED;
                            robot.ShowText("ROBREA_ROBOT_WAITINGREADY_FORCERELEASED");
                            break;
                        }
                    }
                    else
                    {
                        StateRobotGoToReady = RobotGoToReady.ROBREA_ROBOT_WAITTING_GOTO_READYSTATION;
                    }
                    break;

                case RobotGoToReady.ROBREA_ROBOT_WAITTING_GOTO_READYSTATION:     // Robot dang di toi dau line ready station

                    if (resCmd == ResponseCommand.RESPONSE_LASER_CAME_POINT)
                    {
                        TrafficRountineConstants.DetectRelease(registryRobotJourney);
                        resCmd = ResponseCommand.RESPONSE_NONE;
                        StateRobotGoToReady = RobotGoToReady.ROBREA_ROBOT_WAIITNG_DETECTLINE_TO_READYSTATION;
                        robot.ShowText("ROBREA_ROBOT_WAIITNG_DETECTLINE_TO_READYSTATION");
                    }
                    break;

                case RobotGoToReady.ROBREA_ROBOT_WAIITNG_DETECTLINE_TO_READYSTATION:     // đang đợi dò line để đến vị trí line trong buffer
                    if (rb.SendCmdAreaPallet(RbToRd.points.PointOfCharger))
                    {
                        StateRobotGoToReady = RobotGoToReady.ROBREA_ROBOT_WAITTING_CAME_POSITION_READYSTATION;
                        robot.ShowText("ROBREA_ROBOT_WAITTING_CAME_POSITION_READYSTATION");
                    }
                    break;

                case RobotGoToReady.ROBREA_ROBOT_WAITTING_CAME_POSITION_READYSTATION:     // đến vị trả robot về robotmanagement để nhận quy trình mới
                    if (resCmd == ResponseCommand.RESPONSE_FINISH_GOTO_POSITION)
                    {
                        //rb.prioritLevel.OnAuthorizedPriorityProcedure = false;
                        StateRobotGoToReady = RobotGoToReady.ROBREA_ROBOT_RELEASED;
                        TrafficRountineConstants.RegIntZone_READY.Release(robot);
                        robot.robotTag = RobotStatus.IDLE;
                        robot.SetSafeYellowcircle(false);
                        robot.SetSafeBluecircle(false);
                        robot.SetSafeSmallcircle(false);
                        robot.TurnOnSupervisorTraffic(false);
                        rb.mcuCtrl.lampRbOff();
                        robot.ShowText("ROBREA_ROBOT_RELEASED");
                    }
                    else if (resCmd == ResponseCommand.RESPONSE_ERROR)
                    {
                        errorCode = ErrorCode.DETECT_LINE_ERROR;
                        CheckUserHandleError(this);
                    }
                    break;

                case RobotGoToReady.ROBREA_ROBOT_RELEASED:
                    Global_Object.cntGoready++;
                    rb.PreProcedureAs = ProcedureControlAssign.PRO_READY;
                    // if (errorCode == ErrorCode.RUN_OK) {
                    ReleaseProcedureHandler(this);
                    // } else {
                    //     ErrorProcedureHandler (this);
                    // }
                    robot.setColorRobotStatus(RobotStatusColorCode.ROBOT_STATUS_OK);
                    ProRun = false;
                    //robot.ShowText("RELEASED");
                    UpdateInformationInProc(this, ProcessStatus.S);
                    order.endTimeProcedure   = DateTime.Now;
                    order.totalTimeProcedure = order.endTimeProcedure.Subtract(order.startTimeProcedure).TotalMinutes;
                    KillEvent();
                    break;

                case RobotGoToReady.ROBREA_ROBOT_WAITINGREADY_FORCERELEASED:
                    // add to wait task;
                    //robot.robotTag = RobotStatus.IDLE;

                    robot.setColorRobotStatus(RobotStatusColorCode.ROBOT_STATUS_OK);
                    procedureCode = ProcedureControlServices.ProcedureCode.PROC_CODE_ROBOT_WAITINGTO_READY;
                    ProRun        = false;
                    robot.ShowText("RELEASED WHEN WAITTING TO READY, HAS AN NEW TASK");
                    UpdateInformationInProc(this, ProcessStatus.S);
                    order.endTimeProcedure   = DateTime.Now;
                    order.totalTimeProcedure = order.endTimeProcedure.Subtract(order.startTimeProcedure).TotalMinutes;

                    rb.PreProcedureAs = ProcedureControlAssign.PRO_WAIT_TASK;
                    ReleaseProcedureHandler(this);
                    KillEvent();
                    break;
                }
                Thread.Sleep(700);
            }
            StateRobotGoToReady = RobotGoToReady.ROBREA_IDLE;
        }