Exemple #1
0
        private void LogicReturn(int Slot_ID, int Slot_Index, bool Reuse)
        {
            try
            {
                if (!StaticRes.Global.Hardware_Connection)
                {
                    returncomplete(true);
                    return;
                }
                if (!StaticRes.Global.Need_Homing)
                {
                    #region  ***(R000)*** Rotary move to point position
                    if (StaticRes.Global.Process_Code.Returning == "R000" && StaticRes.Global.Transaction_Continue)
                    {
                        IO_Control.Green_Tower_Light_Setting();
                        step("R000 -  Rotary move to Slot-" + Slot_ID.ToString() + ",Position:" + StaticRes.Global.Slot_Position[Slot_ID - 1].ToString() + "");
                        try
                        {
                            //Motion_Control.Motion_Speed_Checking();
                            //if (StaticRes.Global.Need_Homing)
                            //{
                            //    Error_Throw(StaticRes.Global.Error_List.Please_homing_first, "L000");
                            //    return;
                            //}
                            Motion_Control.Rotary_MoveTo_Slot(Slot_ID);
                            Motion_Control.Motion_Speed_Checking();
                            StaticRes.Global.Process_Code.Returning = "R200";
                        }
                        catch (Exception ex)
                        {
                            Common.Reports.LogFile.Log("Return R000, Exception:" + ex.ToString());
                            Error_Throw(StaticRes.Global.Error_List.Motion_failed, "R000");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R200)*** Check slot index and move to related process
                    if (StaticRes.Global.Process_Code.Returning == "R200" && StaticRes.Global.Transaction_Continue)
                    {
                        switch (Slot_Index)
                        {
                        case 1:
                            StaticRes.Global.Process_Code.Returning = "R300";
                            break;

                        case 2:
                            StaticRes.Global.Process_Code.Returning = "R700";
                            break;

                        case 3:
                            StaticRes.Global.Process_Code.Returning = "R1100";
                            break;

                        case 4:
                            StaticRes.Global.Process_Code.Returning = "R1500";
                            break;
                        }
                    }
                    #endregion

                    #region Index 1
                    #region ***(R300)*** Open Gate A and check X109
                    if (StaticRes.Global.Process_Code.Returning == "R300" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R300 - Open Gate A and check X109");
                        if (IO_Control.X109_Gate_A_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R400";
                            returncomplete(false);
                            return;
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_A_not_opened, "R300");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R400)*** Check loading door closed sensor X102
                    if (StaticRes.Global.Process_Code.Returning == "R400" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R400 - Check loading door closed sensor X102");
                        if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed())
                        {
                            StaticRes.Global.Process_Code.Returning = "R500";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "R400");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R500)*** Check syringe A present sensor X104
                    if (StaticRes.Global.Process_Code.Returning == "R500" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R500 - Check syringe A present sensor X104");
                        if (Hardware.IO_LIST.Input.X104_Syringe_A_Present())
                        {
                            StaticRes.Global.Process_Code.Returning = "R600";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_A_not_present, "R500");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R600)*** Close gate A and check X108
                    if (StaticRes.Global.Process_Code.Returning == "R600" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R600 - Close gate A and check X108 sensor");
                        if (IO_Control.X108_Gate_A_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1900";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_A_not_closed, "R600");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region Index 2
                    #region ***(R700)*** Open Gate B and check X111
                    if (StaticRes.Global.Process_Code.Returning == "R700" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R700 - Open Gate B and check X111");
                        if (IO_Control.X111_Gate_B_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R800";
                            returncomplete(false);
                            return;
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_B_not_opened, "R700");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R800)*** Check loading door closed sensor X102
                    if (StaticRes.Global.Process_Code.Returning == "R800" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R800 - Check loading door closed sensor X102");
                        if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed())
                        {
                            StaticRes.Global.Process_Code.Returning = "R900";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "R800");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R900)*** Check syringe B present sensor X105
                    if (StaticRes.Global.Process_Code.Returning == "R900" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R900 - Check syringe B present sensor X105");
                        if (Hardware.IO_LIST.Input.X105_Syringe_B_Present())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1000";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_B_not_present, "R900");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R1000)*** Close gate B and check X110
                    if (StaticRes.Global.Process_Code.Returning == "R1000" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1000 - Close gate B and check X110");
                        if (IO_Control.X110_Gate_B_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1900";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_B_not_closed, "R1000");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region Index 3
                    #region ***(R1100)*** Open Gate C and check X113
                    if (StaticRes.Global.Process_Code.Returning == "R1100" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1100 - Open Gate C and check X113");
                        if (IO_Control.X113_Gate_C_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1200";
                            returncomplete(false);
                            return;
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_C_not_opened, "R1100");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R1200)*** Check loading door closed sensor X102
                    if (StaticRes.Global.Process_Code.Returning == "R1200" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1200 - Close loading window and check X102");
                        if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1300";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "R1200");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R1300)*** Check syringe C present sensor X106
                    if (StaticRes.Global.Process_Code.Returning == "R1300" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1300 - Check syringe C present sensor X106");
                        if (Hardware.IO_LIST.Input.X106_Syringe_C_Present())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1400";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_C_not_present, "R1300");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R1400)*** Close gate C and check X112
                    if (StaticRes.Global.Process_Code.Returning == "R1400" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1400 - Close gate C and check X112");
                        if (IO_Control.X112_Gate_C_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1900";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_C_not_closed, "R1400");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region Index 4
                    #region ***(R1500)*** Open Gate D and check X115
                    if (StaticRes.Global.Process_Code.Returning == "R1500" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1500 - Open Gate D and check X115");
                        if (IO_Control.X115_Gate_D_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1600";
                            returncomplete(false);
                            return;
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_D_not_opened, "R1500");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R1600)*** Check loadind door closed sensor X102
                    if (StaticRes.Global.Process_Code.Returning == "R1600" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1600 - Close loading window and check X102");
                        if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1700";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "R1600");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R1700)*** Check syringe D present sensor X107
                    if (StaticRes.Global.Process_Code.Returning == "R1700" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1700 - Check syringe D present sensor X107");
                        if (Hardware.IO_LIST.Input.X107_Syringe_D_Present())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1800";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_C_not_present, "R1700");
                            return;
                        }
                    }
                    #endregion

                    #region ***(R1800)*** Close gate D and check X114
                    if (StaticRes.Global.Process_Code.Returning == "R1800" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1800 - Close gate D and check X114");
                        if (IO_Control.X114_Gate_D_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Returning = "R1900";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_D_not_closed, "R1800");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region ***(R1900)*** Return completed , rotary continue moving
                    if (StaticRes.Global.Process_Code.Returning == "R1900" && StaticRes.Global.Transaction_Continue)
                    {
                        step("R1900 - return completed");
                        try
                        {
                            IO_Control.Yellow_Tower_Light_Setting();
                            StaticRes.Global.Process_Code.Returning = "R000";
                            StaticRes.Global.IsOnProgress           = false;
                            returncomplete(true);
                            return;
                        }
                        catch (Exception ex)
                        {
                            Common.Reports.LogFile.Log("Return R1900, Exception:" + ex.ToString());
                            Error_Throw(StaticRes.Global.Error_List.Motion_failed, "R1900");
                            return;
                        }
                    }
                    #endregion
                }
                else
                {
                    Error_Throw(StaticRes.Global.Error_List.Please_homing_first, "R000");
                    return;
                }
            }
            catch (Exception ee)
            {
                Common.Reports.LogFile.Log("Return Error -- " + ee.Message + ",R000 , user:"******"From Return Exception");
                return;
            }
        }
Exemple #2
0
        private void LogicUnload(int Slot_ID, int Slot_Index)
        {
            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In Function");

            try
            {
                if (!StaticRes.Global.Hardware_Connection)
                {
                    unloadcomplete(true);
                    return;
                }
                if (!StaticRes.Global.Need_Homing)
                {
                    #region ***(U000)*** Move to pointed position
                    if (StaticRes.Global.Process_Code.Unloading == "U000" && StaticRes.Global.Transaction_Continue)
                    {
                        Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In U000");
                        IO_Control.Green_Tower_Light_Setting();
                        step("U000 -  Rotary move to Slot-" + Slot_ID.ToString() + ",Position:" + StaticRes.Global.Slot_Position[Slot_ID - 1].ToString() + "");
                        try
                        {
                            //Motion_Control.Motion_Speed_Checking();
                            //if (StaticRes.Global.Need_Homing)
                            //{
                            //    Error_Throw(StaticRes.Global.Error_List.Please_homing_first, "U000");
                            //    return;
                            //}
                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U000, Start move to slot");
                            Motion_Control.Rotary_MoveTo_Slot(Slot_ID);
                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U000, move complete, current position: " + Motion_Control.Got_Rotary_Position().ToString());
                            Common.Reports.LogFile.Log("Unload move to slot successful ,current position:" + Motion_Control.Got_Rotary_Position().ToString() + "");
                            Motion_Control.Motion_Speed_Checking();


                            StaticRes.Global.Process_Code.Unloading = "U050";
                        }
                        catch (Exception ex)
                        {
                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U000, Catch Exception:" + ex.ToString());
                            Error_Throw(StaticRes.Global.Error_List.Motion_failed, "U000");
                            return;
                        }
                    }
                    #endregion


                    //2020 07 19 by Dwyane for Slot Barcode Validation
                    #region ***(U050)*** Slot Barcode Validation
                    if (StaticRes.Global.Process_Code.Unloading == "U050" && StaticRes.Global.Transaction_Continue)
                    {
                        Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In U050");
                        step("U050 -  Scan Slot-" + Slot_ID.ToString() + " Barcode ,Position:" + StaticRes.Global.Slot_Position[Slot_ID - 1].ToString() + "");

                        try
                        {
                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U050, slot index:" + Slot_Index);
                            string comPort = string.Empty;
                            switch (Slot_Index)
                            {
                            case 1:
                                comPort = StaticRes.Global.System_Setting.SlotScanner_Index1Port;
                                break;

                            case 2:
                                comPort = StaticRes.Global.System_Setting.SlotScanner_Index2Port;

                                break;

                            case 3:
                                comPort = StaticRes.Global.System_Setting.SlotScanner_Index3Port;
                                break;

                            case 4:
                                comPort = StaticRes.Global.System_Setting.SlotScanner_Index4Port;
                                break;
                            }


                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U050, start init & open com port:");


                            //初始化, 并打开com port
                            InitAndOpen(comPort);



                            //转盘来回摆动5次
                            for (int i = 0; i < 5; i++)
                            {
                                //一旦扫到barcode, 就立马跳出循环并关闭com口
                                if (receivedSlotID != "")
                                {
                                    Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U050, received scanner msg, break");
                                    CloseSlotScanner();
                                    break;
                                }

                                Motion_Control.Rotary_Move(10000);
                                Motion_Control.Motion_Speed_Checking();
                                System.Threading.Thread.Sleep(300);
                                Motion_Control.Rotary_Move(-10000);
                                Motion_Control.Motion_Speed_Checking();
                                System.Threading.Thread.Sleep(300);
                                Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U050, move come and back, time" + i.ToString());
                            }



                            if (receivedSlotID == "")
                            {
                                //来回5次都没扫到报警.
                                Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U050, 5 times moving come and back still can not read slot barcode, start alarming");
                                Error_Throw(StaticRes.Global.Error_List.SlotBarcode_Read_Fail, "U000");
                                return;
                            }
                            else
                            {
                                if (receivedSlotID == Slot_ID.ToString())
                                {
                                    //进入下一步
                                    StaticRes.Global.Process_Code.Unloading = "U100";
                                    receivedSlotID = "";
                                }
                                else
                                {
                                    //扫到的位置不是目标位置则报错.
                                    Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U050, received wrong place received slot id:" + "receivedSlotID" + ", tartget slot id:" + Slot_ID);
                                    Error_Throw(StaticRes.Global.Error_List.MissingPlace, "U000");
                                    return;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U050, Catch Exception:" + ex.ToString());
                            Error_Throw(StaticRes.Global.Error_List.Motion_failed, "U000");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U100)*** Check slot index and move to related process
                    if (StaticRes.Global.Process_Code.Unloading == "U100" && StaticRes.Global.Transaction_Continue)
                    {
                        switch (Slot_Index)
                        {
                        case 1:
                            StaticRes.Global.Process_Code.Unloading = "U200";
                            break;

                        case 2:
                            StaticRes.Global.Process_Code.Unloading = "U900";
                            break;

                        case 3:
                            StaticRes.Global.Process_Code.Unloading = "U1600";
                            break;

                        case 4:
                            StaticRes.Global.Process_Code.Unloading = "U2300";
                            break;
                        }
                    }
                    #endregion

                    #region Index 1
                    #region ***(U200)*** Open Gate A and check X109
                    if (StaticRes.Global.Process_Code.Unloading == "U200" && StaticRes.Global.Transaction_Continue)
                    {
                        Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In U200");

                        step("U200 - Open Gate A and check X109");
                        if (IO_Control.X109_Gate_A_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U300";
                        }
                        else
                        {
                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U200, Gate A not open");
                            Error_Throw(StaticRes.Global.Error_List.Gate_A_not_opened, "U200");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U300)*** Ejector A Up and check X208
                    if (StaticRes.Global.Process_Code.Unloading == "U300" && StaticRes.Global.Transaction_Continue)
                    {
                        Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In U300");
                        step("U030 - Ejector A Up and check X208");
                        if (IO_Control.X208_Ejector_A_Up_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U600";
                            unloadcomplete(false);
                            return;
                        }
                        else
                        {
                            Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "U300, Ejector A not up");
                            Error_Throw(StaticRes.Global.Error_List.Ejector_A_not_up, "U300");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U600)*** Ejector A down and check X209
                    if (StaticRes.Global.Process_Code.Unloading == "U600" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U600 - Ejector A down and check X209");
                        if (IO_Control.X209_Ejector_A_Down_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U700";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Ejector_A_not_down, "U600");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U700)*** Check syringe a present sensor X104
                    if (StaticRes.Global.Process_Code.Unloading == "U700" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U700 - Check syringe A present sensor X104");
                        if (!Hardware.IO_LIST.Input.X104_Syringe_A_Present())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U800";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_A_present, "U700");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U800)*** Close gate A and check X108
                    if (StaticRes.Global.Process_Code.Unloading == "U800" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U800 - Close Gate A and check X108");
                        if (IO_Control.X108_Gate_A_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U3000";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_A_not_closed, "U800");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region Index 2
                    #region ***(U900)*** Open Gate B and check X111
                    if (StaticRes.Global.Process_Code.Unloading == "U900" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U900 - Open Gate B and check X111");
                        if (IO_Control.X111_Gate_B_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U1000";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_B_not_opened, "U900");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U1000)*** Ejector B Up and check X210
                    if (StaticRes.Global.Process_Code.Unloading == "U1000" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U1000 - Ejector B Up and check X210");
                        if (IO_Control.X210_Ejector_B_Up_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U1300";
                            unloadcomplete(false);
                            return;
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Ejector_B_not_up, "U1000");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U1300)*** Ejector B down and check X211
                    if (StaticRes.Global.Process_Code.Unloading == "U1300" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U1300 - Ejector B down and check X211");
                        if (IO_Control.X211_Ejector_B_Down_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U1400";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Ejector_B_not_down, "U1300");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U1400)*** Check syringe B present sensor
                    if (StaticRes.Global.Process_Code.Unloading == "U1400" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U1400 - Check syringe B present sensor X105");
                        if (!Hardware.IO_LIST.Input.X105_Syringe_B_Present())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U1500";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_B_present, "U1400");

                            return;
                        }
                    }
                    #endregion

                    #region ***(U1500)*** Close gate B and check X110
                    if (StaticRes.Global.Process_Code.Unloading == "U1500" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U1500 - Close Gate B and check X110");
                        if (IO_Control.X110_Gate_B_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U3000";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_B_not_closed, "U1500");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region Index 3
                    #region ***(U1600)*** Open Gate C and check X113
                    if (StaticRes.Global.Process_Code.Unloading == "U1600" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U1600 - Open Gate C and check X113");
                        if (IO_Control.X113_Gate_C_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U1700";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_C_not_opened, "U1600");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U1700)*** Ejector C Up and check X212
                    if (StaticRes.Global.Process_Code.Unloading == "U1700" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U1700 - Ejector C Up and check X212");
                        if (IO_Control.X212_Ejector_C_Up_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U2000";
                            unloadcomplete(false);
                            return;
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Ejector_C_not_up, "U1700");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U2000)*** Ejector C down and check X213
                    if (StaticRes.Global.Process_Code.Unloading == "U2000" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2000 - Ejector C down and check X213");
                        if (IO_Control.X213_Ejector_C_Down_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U2100";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Ejector_C_not_down, "U2000");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U2100)*** Check syringe C present sensor
                    if (StaticRes.Global.Process_Code.Unloading == "U2100" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2100 - Check syringe C present sensor X106");
                        if (!Hardware.IO_LIST.Input.X106_Syringe_C_Present())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U2200";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_C_present, "U2100");

                            return;
                        }
                    }
                    #endregion

                    #region ***(U2200)*** Close gate C and check X112
                    if (StaticRes.Global.Process_Code.Unloading == "U2200" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2200 - Close Gate C and check X112");
                        if (IO_Control.X112_Gate_C_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U3000";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_C_not_closed, "U2200");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region Index 4
                    #region ***(U2300)*** Open Gate D and check X115
                    if (StaticRes.Global.Process_Code.Unloading == "U2300" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2300 - Open Gate D and check X115");
                        if (IO_Control.X115_Gate_D_Open_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U2400";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_D_not_opened, "U2300");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U2400)*** Ejector D Up and check X214
                    if (StaticRes.Global.Process_Code.Unloading == "U2400" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2400 - Ejector D Up and check X214");
                        if (IO_Control.X214_Ejector_D_Up_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U2700";
                            unloadcomplete(false);
                            return;
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Ejector_D_not_up, "U2400");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U2700)*** Ejector D down and check X215
                    if (StaticRes.Global.Process_Code.Unloading == "U2700" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2700 - Ejector D down and check X215");
                        if (IO_Control.X215_Ejector_D_Down_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U2800";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Ejector_D_not_down, "U2700");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U2800)*** Check syringe D present sensor
                    if (StaticRes.Global.Process_Code.Unloading == "U2800" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2800 - Check syringe D present sensor X107");
                        if (!Hardware.IO_LIST.Input.X107_Syringe_D_Present())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U2900";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Syringe_D_present, "U2800");

                            return;
                        }
                    }
                    #endregion

                    #region ***(U2900)*** Close gate D and check X114
                    if (StaticRes.Global.Process_Code.Unloading == "U2900" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U2900 - Close gate D and check X114");
                        if (IO_Control.X114_Gate_D_Close_and_Check())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U3000";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Gate_D_not_closed, "U2900");
                            return;
                        }
                    }
                    #endregion
                    #endregion

                    #region ***(U3000)*** Check loading door close sensor X102
                    if (StaticRes.Global.Process_Code.Unloading == "U3000" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U3000 - Check loading door close sensor X102");
                        if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed())
                        {
                            StaticRes.Global.Process_Code.Unloading = "U3100";
                        }
                        else
                        {
                            Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "U3000");
                            return;
                        }
                    }
                    #endregion

                    #region ***(U3100)*** Unloading complete
                    if (StaticRes.Global.Process_Code.Unloading == "U3100" && StaticRes.Global.Transaction_Continue)
                    {
                        step("U3100 - unload complete");
                        IO_Control.Yellow_Tower_Light_Setting();
                        StaticRes.Global.Process_Code.Unloading = "U000";
                        StaticRes.Global.IsOnProgress           = false;
                        unloadcomplete(true);
                        return;
                    }
                    #endregion
                }
                else
                {
                    Error_Throw(StaticRes.Global.Error_List.Please_homing_first, "U000");
                    return;
                }
            }
            catch (Exception ee)
            {
                Common.Reports.LogFile.Log("Unload Error -- " + ee.Message + ",U000 , user:"******"From Unload Exception");
                return;
            }
        }