SHARP_CLAS_UI/500.Equipment/700.Unit/400.Unloader/ULD_Handler_1.cs
@@ -1106,6 +1106,9 @@
            var isAoiPanel1MeasurementAck = aoiStage.Stage1.IsExist == false || aoiStage.Panel1.Measurement_Ack;
            var isAoiPanel2MeasurementAck = aoiStage.Stage2.IsExist == false || aoiStage.Panel2.Measurement_Ack;
            var isAoiPanel1WidthMeasurementAck = aoiStage.Stage1.IsExist == false || aoiStage.Panel1.WidthMeasurement_Ack;
            var isAoiPanel2WidthMeasurementAck = aoiStage.Stage2.IsExist == false || aoiStage.Panel2.WidthMeasurement_Ack;
            switch (Step)
            {
                case UnloaderHandler1Steps.S4000_MEASUREMENT_START:
@@ -1674,13 +1677,25 @@
                            if (isAoiPanel1MeasurementAck && isAoiPanel2MeasurementAck)
                            {
                                if (equipment.cim_mode == En_Cim_Mode.Online)
                                //AOI 완료. -> Width meausrement 여기에 추가 해야 될듯..?
                                if (equipment.Mode.Width_Measurement_Skip || equipment.WidthMeasurementCount < equipment.Setting.Width_Measurement_Count)
                                {
                                    Step = UnloaderHandler1Steps.S4600_PANEL_LEFT_CIM_SEND;
                                    equipment.WidthMeasurementCount = equipment.WidthMeasurementCount + 1;
                                    if (equipment.cim_mode == En_Cim_Mode.Online)
                                    {
                                        Step = UnloaderHandler1Steps.S4800_PANEL_LEFT_CIM_SEND;
                                    }
                                    else
                                    {
                                        Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                                    }
                                }
                                else
                                {
                                    Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                                    measurement_retry_cnt = 0;
                                    Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                                }
                            }
                            else
@@ -1690,7 +1705,7 @@
                                if (measurement_retry_cnt >= equipment.Setting.Vision_Retry_Count)
                                {
                                    Step = UnloaderHandler1Steps.S4700_USER_COMMAND_START;
                                    Step = UnloaderHandler1Steps.S4560_USER_COMMAND_START;
                                }
                                else
                                {
@@ -1708,7 +1723,7 @@
                                {
                                    if (sequenceChangedTime.Minute > 5)
                                    {
                                        Step = UnloaderHandler1Steps.S4700_USER_COMMAND_START;
                                        Step = UnloaderHandler1Steps.S4560_USER_COMMAND_START;
                                    }
                                }
                                else if (measurement_retry_cnt == equipment.Setting.Vision_Retry_Count)
@@ -1717,7 +1732,7 @@
                                    Tact_Move.Stop();
                                    equipment.Write_Tact_Time_Log($"ULD Handler 1, AOI Reading [End]");
                                    equipment.Write_Tact_Time_Log($"ULD Handler 1, AOI Reading [Tact : {Tact_Move.Seconds} (sec)]");
                                    Step = UnloaderHandler1Steps.S4700_USER_COMMAND_START;
                                    Step = UnloaderHandler1Steps.S4560_USER_COMMAND_START;
                                }
                                else
                                {
@@ -1732,100 +1747,7 @@
                        break;
                    }
                case UnloaderHandler1Steps.S4600_PANEL_LEFT_CIM_SEND:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        Panel_Info info1 = equipment.after.AoiStage.Panel1;
                        if (equipment.after.AoiStage.Stage1.IsExist == false || info1.IsPanelIdRead == false)
                        {
                            Step = UnloaderHandler1Steps.S4620_PANEL_RIGHT_CIM_SEND;
                            return;
                        }
                        else
                        {
                            if (equipment.cim_client.Send_Process_End("E123456", info1))
                            {
                                Step = UnloaderHandler1Steps.S4610_PANEL_LEFT_CIM_SEND_WAIT;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4610_PANEL_LEFT_CIM_SEND_WAIT:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        if (equipment.cim_client.Get_Command_Ack(En_Cim_Command.PREND))
                        {
                            if (equipment.cim_client.Get_Command_Result(En_Cim_Command.PREND))
                            {
                                Step = UnloaderHandler1Steps.S4620_PANEL_RIGHT_CIM_SEND;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4600_PANEL_LEFT_CIM_SEND;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4620_PANEL_RIGHT_CIM_SEND:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        Panel_Info info2 = equipment.after.AoiStage.Panel2;
                        if (equipment.after.AoiStage.Stage2.IsExist == false || info2.IsPanelIdRead == false)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                        }
                        else
                        {
                            if(equipment.cim_client.Send_Process_End("E123456", info2))
                            {
                                Step = UnloaderHandler1Steps.S4630_PANEL_RIGHT_CIM_SEND_WAIT;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4630_PANEL_RIGHT_CIM_SEND_WAIT:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        if (equipment.cim_client.Get_Command_Ack(En_Cim_Command.PREND))
                        {
                            if (equipment.cim_client.Get_Command_Result(En_Cim_Command.PREND))
                            {
                                Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4620_PANEL_RIGHT_CIM_SEND;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4700_USER_COMMAND_START:
                case UnloaderHandler1Steps.S4560_USER_COMMAND_START:
                    {
                        var aoistage = equipment.after.AoiStage;
                        Panel_Info info1 = aoistage.Panel1;
@@ -1844,10 +1766,10 @@
                        measurement_user_command = new Form_User_Command_Set("Measurement");
                        measurement_user_command_show = true;
                        Step = UnloaderHandler1Steps.S4710_USER_COMMAND_WAIT;
                        Step = UnloaderHandler1Steps.S4570_USER_COMMAND_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4710_USER_COMMAND_WAIT:
                case UnloaderHandler1Steps.S4570_USER_COMMAND_WAIT:
                    {
                        var aoistage = equipment.after.AoiStage;
                        Panel_Info info1 = aoistage.Panel1;
@@ -1948,6 +1870,734 @@
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY:
                    {
                        Tact_Move.Start();
                        equipment.Write_Tact_Time_Log($"ULD Handler 1, AOI Ready [Start]");
                        var info = equipment.after.AoiStage.Panel1;
                        if (isAoiPanel1WidthMeasurementAck)
                        {
                            Step = UnloaderHandler1Steps.S4602_RIGHT_CAMERA_GRAB_READY;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Ready_Req(0, 0, 0, info.Stage_Num, info.Tray_Num, info.Panel_Num, info.Panel_ID))
                            Step = UnloaderHandler1Steps.S4601_LEFT_CAMERA_GRAB_READY_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4601_LEFT_CAMERA_GRAB_READY_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Ready_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4602_RIGHT_CAMERA_GRAB_READY;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4602_RIGHT_CAMERA_GRAB_READY:
                    {
                        if (sequenceChangedTime.Seconds < 0.1) break;
                        var info = equipment.after.AoiStage.Panel2;
                        if (isAoiPanel2WidthMeasurementAck)
                        {
                            Tact_Move.Stop();
                            equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Ready [End]");
                            equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Ready [Tact : {Tact_Move.Seconds} (sec)]");
                            Step = UnloaderHandler1Steps.S4610_MOVE_MEASUREMENT_MARK1_POSITION;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Ready_Req(1, 0, 0, info.Stage_Num, info.Tray_Num, info.Panel_Num, info.Panel_ID))
                            Step = UnloaderHandler1Steps.S4603_RIGHT_CAMERA_GRAB_READY_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4603_RIGHT_CAMERA_GRAB_READY_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Ready_Ack))
                        {
                            Tact_Move.Stop();
                            equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Ready [End]");
                            equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Ready [Tact : {Tact_Move.Seconds} (sec)]");
                            Step = UnloaderHandler1Steps.S4610_MOVE_MEASUREMENT_MARK1_POSITION;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4610_MOVE_MEASUREMENT_MARK1_POSITION:
                    {
                        Tact_Move.Start();
                        equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading Position [Start]");
                        if (MotorX.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark1_X, 500) && MotorY.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark1_Y, 500))
                            Step = UnloaderHandler1Steps.S4611_POSITION_CHECK;
                        break;
                    }
                case UnloaderHandler1Steps.S4611_POSITION_CHECK:
                    {
                        if (MotorX.MotionComplete && MotorY.MotionComplete)
                        {
                            if (MotorX.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark1_X, equipment.Setting.Inposition_Offset) && MotorY.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark1_Y, equipment.Setting.Inposition_Offset))
                            {
                                Tact_Move.Stop();
                                equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading Position [End]");
                                equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading Position [Tact : {Tact_Move.Seconds} (sec)]");
                                vision_delay.Start();
                                Step = UnloaderHandler1Steps.S4612_LEFT_CAMERA_MARK_1_GRAB_START;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4610_MOVE_MEASUREMENT_MARK1_POSITION;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4612_LEFT_CAMERA_MARK_1_GRAB_START:
                    {
                        if (vision_delay.Seconds < equipment.Setting.Vision_Move_Delay) return;
                        Tact_Move.Start();
                        equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading [Start]");
                        var info = equipment.after.AoiStage.Panel1;
                        if (isAoiPanel1WidthMeasurementAck)
                        {
                            Step = UnloaderHandler1Steps.S4614_RIGHT_CAMERA_MARK_1_GRAB_START;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(0, 0, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4613_LEFT_CAMERA_MARK_1_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4613_LEFT_CAMERA_MARK_1_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Left_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4614_RIGHT_CAMERA_MARK_1_GRAB_START;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4614_RIGHT_CAMERA_MARK_1_GRAB_START:
                    {
                        if (sequenceChangedTime.Seconds < 0.1) return;
                        var info = equipment.after.AoiStage.Panel2;
                        if (isAoiPanel2WidthMeasurementAck)
                        {
                            Step = UnloaderHandler1Steps.S4620_MOVE_MEASUREMENT_MARK2_POSITION;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(1, 0, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4615_RIGHT_CAMERA_MARK_1_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4615_RIGHT_CAMERA_MARK_1_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Right_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4620_MOVE_MEASUREMENT_MARK2_POSITION;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4620_MOVE_MEASUREMENT_MARK2_POSITION:
                    {
                        if (sequenceChangedTime.Seconds < equipment.Setting.Vision_Move_Delay) break;
                        if (MotorX.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark2_X, 500) && MotorY.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark2_Y, 500))
                            Step = UnloaderHandler1Steps.S4621_POSITION_CHECK;
                        break;
                    }
                case UnloaderHandler1Steps.S4621_POSITION_CHECK:
                    {
                        if (MotorX.MotionComplete && MotorY.MotionComplete)
                        {
                            if (MotorX.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark2_X, equipment.Setting.Inposition_Offset) && MotorY.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark2_Y, equipment.Setting.Inposition_Offset))
                            {
                                vision_delay.Start();
                                Step = UnloaderHandler1Steps.S4622_LEFT_CAMERA_MARK_2_GRAB_START;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4620_MOVE_MEASUREMENT_MARK2_POSITION;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4622_LEFT_CAMERA_MARK_2_GRAB_START:
                    {
                        if (vision_delay.Seconds < equipment.Setting.Vision_Move_Delay) return;
                        var info = equipment.after.AoiStage.Panel1;
                        if (isAoiPanel1WidthMeasurementAck)
                        {
                            Step = UnloaderHandler1Steps.S4624_RIGHT_CAMERA_MARK_2_GRAB_START;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(0, 1, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4623_LEFT_CAMERA_MARK_2_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4623_LEFT_CAMERA_MARK_2_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Left_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4624_RIGHT_CAMERA_MARK_2_GRAB_START;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4624_RIGHT_CAMERA_MARK_2_GRAB_START:
                    {
                        if (sequenceChangedTime.Seconds < 0.1) return;
                        var info = equipment.after.AoiStage.Panel2;
                        if (isAoiPanel2WidthMeasurementAck)
                        {
                            sequenceChangedTime.Start();
                            if (equipment.Cur_Main_Recipe.vision_info.AoiMark34Use)
                            {
                                Step = UnloaderHandler1Steps.S4630_MOVE_MEASUREMENT_MARK3_POSITION;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4650_MEASUREMENT_CHECK;
                            }
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(1, 1, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4625_RIGHT_CAMERA_MARK_2_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4625_RIGHT_CAMERA_MARK_2_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Right_Ack))
                        {
                            if (equipment.Cur_Main_Recipe.vision_info.AoiMark34Use)
                            {
                                Step = UnloaderHandler1Steps.S4630_MOVE_MEASUREMENT_MARK3_POSITION;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4650_MEASUREMENT_CHECK;
                            }
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4630_MOVE_MEASUREMENT_MARK3_POSITION:
                    {
                        if (sequenceChangedTime.Seconds < equipment.Setting.Vision_Move_Delay) break;
                        if (MotorX.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark3_X, 500) && MotorY.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark3_Y, 500))
                            Step = UnloaderHandler1Steps.S4631_POSITION_CHECK;
                        break;
                    }
                case UnloaderHandler1Steps.S4631_POSITION_CHECK:
                    {
                        if (MotorX.MotionComplete && MotorY.MotionComplete)
                        {
                            if (MotorX.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark3_X, equipment.Setting.Inposition_Offset) && MotorY.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark3_Y, equipment.Setting.Inposition_Offset))
                            {
                                vision_delay.Start();
                                Step = UnloaderHandler1Steps.S4632_LEFT_CAMERA_MARK_3_GRAB_START;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4630_MOVE_MEASUREMENT_MARK3_POSITION;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4632_LEFT_CAMERA_MARK_3_GRAB_START:
                    {
                        if (vision_delay.Seconds < equipment.Setting.Vision_Move_Delay) return;
                        var info = equipment.after.AoiStage.Panel1;
                        if (isAoiPanel1WidthMeasurementAck)
                        {
                            Step = UnloaderHandler1Steps.S4634_RIGHT_CAMERA_MARK_3_GRAB_START;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(0, 2, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4633_LEFT_CAMERA_MARK_3_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4633_LEFT_CAMERA_MARK_3_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Left_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4634_RIGHT_CAMERA_MARK_3_GRAB_START;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4634_RIGHT_CAMERA_MARK_3_GRAB_START:
                    {
                        if (sequenceChangedTime.Seconds < 0.1) return;
                        var info = equipment.after.AoiStage.Panel2;
                        if (isAoiPanel2WidthMeasurementAck)
                        {
                            sequenceChangedTime.Start();
                            Step = UnloaderHandler1Steps.S4640_MOVE_MEASUREMENT_MARK4_POSITION;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(1, 2, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4635_RIGHT_CAMERA_MARK_3_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4635_RIGHT_CAMERA_MARK_3_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Right_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4640_MOVE_MEASUREMENT_MARK4_POSITION;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4640_MOVE_MEASUREMENT_MARK4_POSITION:
                    {
                        if (sequenceChangedTime.Seconds < equipment.Setting.Vision_Move_Delay) break;
                        if (MotorX.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark4_X, 500) && MotorY.Move_Absolute_Pos(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark4_Y, 500))
                            Step = UnloaderHandler1Steps.S4641_POSITION_CHECK;
                        break;
                    }
                case UnloaderHandler1Steps.S4641_POSITION_CHECK:
                    {
                        if (MotorX.MotionComplete && MotorY.MotionComplete)
                        {
                            if (MotorX.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark4_X, equipment.Setting.Inposition_Offset) && MotorY.Is_Inposition(equipment.Cur_Main_Recipe.vision_info.Width_AOI_Mark4_Y, equipment.Setting.Inposition_Offset))
                            {
                                vision_delay.Start();
                                Step = UnloaderHandler1Steps.S4642_LEFT_CAMERA_MARK_4_GRAB_START;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4640_MOVE_MEASUREMENT_MARK4_POSITION;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4642_LEFT_CAMERA_MARK_4_GRAB_START:
                    {
                        if (vision_delay.Seconds < equipment.Setting.Vision_Move_Delay) return;
                        var info = equipment.after.AoiStage.Panel1;
                        if (isAoiPanel1WidthMeasurementAck)
                        {
                            Step = UnloaderHandler1Steps.S4644_RIGHT_CAMERA_MARK_4_GRAB_START;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(0, 3, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4643_LEFT_CAMERA_MARK_4_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4643_LEFT_CAMERA_MARK_4_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Left_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4644_RIGHT_CAMERA_MARK_4_GRAB_START;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4644_RIGHT_CAMERA_MARK_4_GRAB_START:
                    {
                        if (sequenceChangedTime.Seconds < 0.1) return;
                        var info = equipment.after.AoiStage.Panel2;
                        if (isAoiPanel2WidthMeasurementAck)
                        {
                            sequenceChangedTime.Start();
                            Step = UnloaderHandler1Steps.S4650_MEASUREMENT_CHECK;
                            return;
                        }
                        if (equipment.Aoi_vision.Send_WidthMeasurement_Grab_Start_Req(1, 3, MotorX.Position, MotorY.Position))
                            Step = UnloaderHandler1Steps.S4645_RIGHT_CAMERA_MARK_4_GRAB_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4645_RIGHT_CAMERA_MARK_4_GRAB_WAIT:
                    {
                        if (equipment.sm.Get_Bit(Vision_Address.Measurement_Grab_Start_Right_Ack))
                        {
                            Step = UnloaderHandler1Steps.S4650_MEASUREMENT_CHECK;
                        }
                        else if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                        {
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4650_MEASUREMENT_CHECK:
                    {
                        var aoistage = equipment.after.AoiStage;
                        var info1 = aoistage.Panel1;
                        var info2 = aoistage.Panel2;
                        object value;
                        bool result;
                        if ((isAoiPanel1WidthMeasurementAck || equipment.sm.Get_Bit(Vision_Address.Measurement_Left_Ack))
                            && (isAoiPanel2WidthMeasurementAck || equipment.sm.Get_Bit(Vision_Address.Measurement_Right_Ack)))
                        {
                            if (aoistage.Stage1.IsExist && info1.WidthMeasurement_Ack == false)
                            {
                                info1.WidthMeasurement_Ack = true;
                                if (equipment.sm.Get_Bit(Vision_Address.Measurement_Left_Result, out result))
                                {
                                    info1.WidthMeasurement_Result = result;
                                    info1.End_Time = DateTime.Now;
                                    equipment.sm.Get_Value(Vision_Address.Measurement_Left_Mark_1_Point_1, out value);
                                    info1.Mark1Point1 = double.Parse(value.ToString());
                                    equipment.sm.Get_Value(Vision_Address.Measurement_Left_Mark_2_Point_1, out value);
                                    info1.Mark2Point1 = double.Parse(value.ToString());
                                    equipment.sm.Get_Value(Vision_Address.Measurement_Left_Mark_3_Point_1, out value);
                                    info1.Mark3Point1 = double.Parse(value.ToString());
                                    equipment.sm.Get_Value(Vision_Address.Measurement_Left_Mark_4_Point_1, out value);
                                    info1.Mark4Point1 = double.Parse(value.ToString());
                                    aoistage.Panel1 = info1;
                                    isAoiPanel1WidthMeasurementAck = aoiStage.Stage1.IsExist == false || aoiStage.Panel1.WidthMeasurement_Ack;
                                }
                                else
                                {
                                    return;
                                }
                            }
                            if (aoistage.Stage2.IsExist && info2.WidthMeasurement_Ack == false)
                            {
                                if (equipment.sm.Get_Bit(Vision_Address.Measurement_Right_Align_Result))
                                {
                                    info2.WidthMeasurement_Ack = true;
                                    if (equipment.sm.Get_Bit(Vision_Address.Measurement_Right_Result, out result))
                                    {
                                        info2.Measurement_Result = result;
                                        info2.End_Time = DateTime.Now;
                                        equipment.sm.Get_Value(Vision_Address.Measurement_Right_Mark_1_Point_1, out value);
                                        info2.Mark1Point1 = double.Parse(value.ToString());
                                        equipment.sm.Get_Value(Vision_Address.Measurement_Right_Mark_2_Point_1, out value);
                                        info2.Mark2Point1 = double.Parse(value.ToString());
                                        equipment.sm.Get_Value(Vision_Address.Measurement_Right_Mark_3_Point_1, out value);
                                        info2.Mark3Point1 = double.Parse(value.ToString());
                                        equipment.sm.Get_Value(Vision_Address.Measurement_Right_Mark_4_Point_1, out value);
                                        info2.Mark4Point1 = double.Parse(value.ToString());
                                        aoistage.Panel2 = info2;
                                        isAoiPanel2WidthMeasurementAck = aoiStage.Stage2.IsExist == false || aoiStage.Panel2.WidthMeasurement_Ack;
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                            }
                            Tact_Move.Stop();
                            equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading [End]");
                            equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading [Tact : {Tact_Move.Seconds} (sec)]");
                            if (isAoiPanel1WidthMeasurementAck && isAoiPanel2WidthMeasurementAck)
                            {
                                if (equipment.cim_mode == En_Cim_Mode.Online)
                                {
                                    Step = UnloaderHandler1Steps.S4800_PANEL_LEFT_CIM_SEND;
                                }
                                else
                                {
                                    Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                                }
                            }
                            else
                            {
                                equipment.Aoi_vision.WriteClientLog("no align result");
                                measurement_retry_cnt++;
                                if (measurement_retry_cnt >= equipment.Setting.Vision_Retry_Count)
                                {
                                    Step = UnloaderHandler1Steps.S4700_USER_COMMAND_START;
                                }
                                else
                                {
                                    Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                                }
                            }
                        }
                        else
                        {
                            if (sequenceChangedTime.Seconds > equipment.Setting.Vision_Timeout)
                            {
                                measurement_retry_cnt++;
                                if (measurement_retry_cnt == equipment.Setting.Vision_Retry_Count)
                                {
                                    equipment.Aoi_vision.WriteClientLog("no ack result");
                                    Tact_Move.Stop();
                                    equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading [End]");
                                    equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading [Tact : {Tact_Move.Seconds} (sec)]");
                                    Step = UnloaderHandler1Steps.S4700_USER_COMMAND_START;
                                }
                                else
                                {
                                    equipment.Aoi_vision.WriteClientLog("no ack result");
                                    Tact_Move.Stop();
                                    equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading [End]");
                                    equipment.Write_Tact_Time_Log($"ULD Handler 1, Widht AOI Reading [Tact : {Tact_Move.Seconds} (sec)]");
                                    Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                                }
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4700_USER_COMMAND_START:
                    {
                        var aoistage = equipment.after.AoiStage;
                        Panel_Info info1 = aoistage.Panel1;
                        Panel_Info info2 = aoistage.Panel2;
                        if (aoistage.Stage1.IsExist && info1.WidthMeasurement_Ack == false)
                        {
                            Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0886_MEASUREMENT_LEFT_ERROR);
                        }
                        if (aoistage.Stage2.IsExist && info2.WidthMeasurement_Ack == false)
                        {
                            Alarm_Manager.Instance.Occurred(En_Alarm_List.AL_0887_MEASUREMENT_RIGHT_ERROR);
                        }
                        measurement_user_command = new Form_User_Command_Set("Measurement");
                        measurement_user_command_show = true;
                        Step = UnloaderHandler1Steps.S4700_USER_COMMAND_WAIT;
                        break;
                    }
                case UnloaderHandler1Steps.S4700_USER_COMMAND_WAIT:
                    {
                        var aoistage = equipment.after.AoiStage;
                        Panel_Info info1 = aoistage.Panel1;
                        Panel_Info info2 = aoistage.Panel2;
                        if (measurement_user_command.Command_Type == En_User_Command.Scrap)
                        {
                            if (aoistage.Stage1.IsExist && info1.Measurement_Ack == false)
                            {
                                aoistage.Panel1 = new Panel_Info();
                                aoistage.Stage_1_Scrap();
                                equipment.Aoi_vision.Send_Measurement_Command_Req(0, 0, info1.Tray_Num, info1.Panel_Num, info1.Panel_ID);
                            }
                            if (aoistage.Stage2.IsExist && info2.Measurement_Ack == false)
                            {
                                aoistage.Panel2 = new Panel_Info();
                                aoistage.Stage_2_Scrap();
                                equipment.Aoi_vision.Send_Measurement_Command_Req(0, 1, info2.Tray_Num, info2.Panel_Num, info2.Panel_ID);
                            }
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                        }
                        else if (measurement_user_command.Command_Type == En_User_Command.Retry)
                        {
                            if (aoistage.Stage1.IsExist && info1.Measurement_Ack == false)
                            {
                                equipment.Aoi_vision.Send_Measurement_Command_Req(1, 0, info1.Tray_Num, info1.Panel_Num, info1.Panel_ID);
                            }
                            if (aoistage.Stage2.IsExist && info2.Measurement_Ack == false)
                            {
                                equipment.Aoi_vision.Send_Measurement_Command_Req(1, 1, info2.Tray_Num, info2.Panel_Num, info2.Panel_ID);
                            }
                            measurement_retry_cnt = 0;
                            Step = UnloaderHandler1Steps.S4600_LEFT_CAMERA_GRAB_READY;
                        }
                        else if (measurement_user_command.Command_Type == En_User_Command.Skip)
                        {
                            if (aoistage.Stage1.IsExist && info1.Measurement_Ack == false)
                            {
                                equipment.sm.Set_Bit(Vision_Address.Measurement_Left_Ack, true);
                                equipment.sm.Set_Bit(Vision_Address.Measurement_Left_Align_Result, true);
                                equipment.sm.Set_Bit(Vision_Address.Measurement_Left_Result, false);
                                equipment.Aoi_vision.Send_Measurement_Command_Req(2, 0, info1.Tray_Num, info1.Panel_Num, info1.Panel_ID);
                            }
                            if (aoistage.Stage2.IsExist && info2.Measurement_Ack == false)
                            {
                                equipment.sm.Set_Bit(Vision_Address.Measurement_Right_Ack, true);
                                equipment.sm.Set_Bit(Vision_Address.Measurement_Right_Align_Result, true);
                                equipment.sm.Set_Bit(Vision_Address.Measurement_Right_Result, false);
                                equipment.Aoi_vision.Send_Measurement_Command_Req(2, 1, info2.Tray_Num, info2.Panel_Num, info2.Panel_ID);
                            }
                            Step = UnloaderHandler1Steps.S4650_MEASUREMENT_CHECK;
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4800_PANEL_LEFT_CIM_SEND:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        Panel_Info info1 = equipment.after.AoiStage.Panel1;
                        if (equipment.after.AoiStage.Stage1.IsExist == false || info1.IsPanelIdRead == false)
                        {
                            Step = UnloaderHandler1Steps.S4820_PANEL_RIGHT_CIM_SEND;
                            return;
                        }
                        else
                        {
                            if (equipment.cim_client.Send_Process_End("E123456", info1))
                            {
                                Step = UnloaderHandler1Steps.S4810_PANEL_LEFT_CIM_SEND_WAIT;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4810_PANEL_LEFT_CIM_SEND_WAIT:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        if (equipment.cim_client.Get_Command_Ack(En_Cim_Command.PREND))
                        {
                            if (equipment.cim_client.Get_Command_Result(En_Cim_Command.PREND))
                            {
                                Step = UnloaderHandler1Steps.S4820_PANEL_RIGHT_CIM_SEND;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4800_PANEL_LEFT_CIM_SEND;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4820_PANEL_RIGHT_CIM_SEND:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        Panel_Info info2 = equipment.after.AoiStage.Panel2;
                        if (equipment.after.AoiStage.Stage2.IsExist == false || info2.IsPanelIdRead == false)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                        }
                        else
                        {
                            if (equipment.cim_client.Send_Process_End("E123456", info2))
                            {
                                Step = UnloaderHandler1Steps.S4830_PANEL_RIGHT_CIM_SEND_WAIT;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4830_PANEL_RIGHT_CIM_SEND_WAIT:
                    {
                        if (equipment.cim_mode != En_Cim_Mode.Online)
                        {
                            Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            return;
                        }
                        if (equipment.cim_client.Get_Command_Ack(En_Cim_Command.PREND))
                        {
                            if (equipment.cim_client.Get_Command_Result(En_Cim_Command.PREND))
                            {
                                Step = UnloaderHandler1Steps.S4999_MEASUREMENT_END;
                            }
                            else
                            {
                                Step = UnloaderHandler1Steps.S4820_PANEL_RIGHT_CIM_SEND;
                            }
                        }
                        break;
                    }
                case UnloaderHandler1Steps.S4999_MEASUREMENT_END:
                    {
                        Tact_AOI.Stop();