private void LogicLoad(int Slot_ID, int Slot_Index) { Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In Function"); try { if (!StaticRes.Global.Hardware_Connection) { loadcomplete(true); return; } if (!StaticRes.Global.Need_Homing) { #region ***(L000)*** Rotary move to point position if (StaticRes.Global.Process_Code.Loading == "L000" && StaticRes.Global.Transaction_Continue) { Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In L000"); IO_Control.Green_Tower_Light_Setting(); step("L000 - Rotary move to Slot-" + Slot_ID.ToString() + ",Position:" + StaticRes.Global.Slot_Position[Slot_ID - 1].ToString() + "");//" + StaticRes.Global.Slot_Position[Slot_ID - 1].ToString + " try { Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "L000, Start Move to slot"); Motion_Control.Rotary_MoveTo_Slot_ABSMode(Slot_ID); Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "L000, move complete, current position:" + Motion_Control.Got_Rotary_Position().ToString()); Common.Reports.LogFile.Log("load move to slot successful ,current position:" + Motion_Control.Got_Rotary_Position().ToString() + ""); Motion_Control.Motion_Speed_Checking(); StaticRes.Global.Process_Code.Loading = "L100"; } catch (Exception ex) { Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "L000, Catch Exception:" + ex.ToString()); Error_Throw(StaticRes.Global.Error_List.Motion_failed, "L000"); return; } } #endregion //2020 07 19 by Dwyane for Slot Barcode Validation #region ***(L100)*** Slot Barcode Validation if (StaticRes.Global.Process_Code.Loading == "L100" && StaticRes.Global.Transaction_Continue) { Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "In L100"); step("L100 - Scan Slot-" + Slot_ID.ToString() + " Barcode ,Position:" + StaticRes.Global.Slot_Position[Slot_ID - 1].ToString() + ""); try { Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "L100, 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(), "L100, 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(), "L100, 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(), "L100, move come and back, time" + i.ToString()); } if (receivedSlotID == "") { //来回5次都没扫到报警. Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "L100, 5 times moving come and back still can not read slot barcode, start alarming"); Error_Throw(StaticRes.Global.Error_List.SlotBarcode_Read_Fail, "L000"); return; } else { if (receivedSlotID == Slot_ID.ToString()) { //进入下一步 StaticRes.Global.Process_Code.Loading = "L200"; receivedSlotID = ""; } else { //扫到的位置不是目标位置则报错. Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "L100, received wrong place received slot id:" + "receivedSlotID" + ", tartget slot id:" + Slot_ID); Error_Throw(StaticRes.Global.Error_List.MissingPlace, "L000"); return; } } } catch (Exception ex) { Common.Reports.LogFile.DebugLog(MethodBase.GetCurrentMethod(), "L100, Catch Exception:" + ex.ToString()); Error_Throw(StaticRes.Global.Error_List.Motion_failed, "L000"); return; } } #endregion #region ***(L200)*** Check slot index and move to related process if (StaticRes.Global.Process_Code.Loading == "L200" && StaticRes.Global.Transaction_Continue) { switch (Slot_Index) { case 1: StaticRes.Global.Process_Code.Loading = "L300"; break; case 2: StaticRes.Global.Process_Code.Loading = "L700"; break; case 3: StaticRes.Global.Process_Code.Loading = "L1100"; break; case 4: StaticRes.Global.Process_Code.Loading = "L1500"; break; } } #endregion #region Index 1 #region ***(L300)*** Open Gate A and check X109 if (StaticRes.Global.Process_Code.Loading == "L300" && StaticRes.Global.Transaction_Continue) { step("L300 - Open Gate A and check X109"); if (IO_Control.X109_Gate_A_Open_and_Check()) { StaticRes.Global.Process_Code.Loading = "L400"; loadcomplete(false); return; } else { Error_Throw(StaticRes.Global.Error_List.Gate_A_not_opened, "L300"); return; } } #endregion #region ***(L400)*** Check loading door close sensor X102 if (StaticRes.Global.Process_Code.Loading == "L400" && StaticRes.Global.Transaction_Continue) { step("L400 - Close loading door and check X102"); if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed()) { StaticRes.Global.Process_Code.Loading = "L500"; } else { Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "L400"); return; } } #endregion #region ***(L500)*** Check syringe A present sensor X104 if (StaticRes.Global.Process_Code.Loading == "L500" && StaticRes.Global.Transaction_Continue) { step("L500 - Check syringe A present sensor X104"); if (Hardware.IO_LIST.Input.X104_Syringe_A_Present()) { StaticRes.Global.Process_Code.Loading = "L600"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_A_not_present, "L500"); return; } } #endregion #region ***(L600)*** Close gate A and check X108 if (StaticRes.Global.Process_Code.Loading == "L600" && StaticRes.Global.Transaction_Continue) { step("L600 - Close Gate A and check X108"); if (IO_Control.X108_Gate_A_Close_and_Check()) { StaticRes.Global.Process_Code.Loading = "L1900"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_A_not_closed, "L600"); return; } } #endregion #endregion #region Index 2 #region ***(L700)*** Open Gate B and check X111 if (StaticRes.Global.Process_Code.Loading == "L700" && StaticRes.Global.Transaction_Continue) { step("L700 - Open Gate B and check X111"); if (IO_Control.X111_Gate_B_Open_and_Check()) { StaticRes.Global.Process_Code.Loading = "L800"; loadcomplete(false); return; } else { Error_Throw(StaticRes.Global.Error_List.Gate_B_not_opened, "L700"); return; } } #endregion #region ***(L800)*** Check loading door close sensor X102 if (StaticRes.Global.Process_Code.Loading == "L800" && StaticRes.Global.Transaction_Continue) { step("L800 - Close loading door and check X102"); if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed()) { StaticRes.Global.Process_Code.Loading = "L900"; } else { Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "L800"); return; } } #endregion #region ***(L900)*** Check syringe B present sensor X105 if (StaticRes.Global.Process_Code.Loading == "L900" && StaticRes.Global.Transaction_Continue) { step("L900 - Check syringe B present sensor X105"); if (Hardware.IO_LIST.Input.X105_Syringe_B_Present()) { StaticRes.Global.Process_Code.Loading = "L1000"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_B_not_present, "L900"); return; } } #endregion #region ***(L1000)*** Close gate B and check X110 if (StaticRes.Global.Process_Code.Loading == "L1000" && StaticRes.Global.Transaction_Continue) { step("L1000 - Close gate B and check X110 sensor"); if (IO_Control.X110_Gate_B_Close_and_Check()) { StaticRes.Global.Process_Code.Loading = "L1900"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_B_not_closed, "L1000"); return; } } #endregion #endregion #region Index 3 #region ***(L1100)*** Open Gate C and check X113 if (StaticRes.Global.Process_Code.Loading == "L1100" && StaticRes.Global.Transaction_Continue) { step("L1100 - Open Gate C and check X113"); if (IO_Control.X113_Gate_C_Open_and_Check()) { StaticRes.Global.Process_Code.Loading = "L1200"; loadcomplete(false); return; } else { Error_Throw(StaticRes.Global.Error_List.Gate_C_not_opened, "L1100"); return; } } #endregion #region ***(L1200)*** Check loading door close sensor X102 if (StaticRes.Global.Process_Code.Loading == "L1200" && StaticRes.Global.Transaction_Continue) { step("L1200 - Check loading door close sensor X102"); if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed()) { StaticRes.Global.Process_Code.Loading = "L1300"; } else { Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "L1200"); return; } } #endregion #region ***(L1300)*** Check syringe C present sensor X106 if (StaticRes.Global.Process_Code.Loading == "L1300" && StaticRes.Global.Transaction_Continue) { step("L1300 - Check syringe C present sensor X106"); if (Hardware.IO_LIST.Input.X106_Syringe_C_Present()) { StaticRes.Global.Process_Code.Loading = "L1400"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_C_not_present, "L1300"); return; } } #endregion #region ***(L1400)*** Close gate C and check X112 if (StaticRes.Global.Process_Code.Loading == "L1400" && StaticRes.Global.Transaction_Continue) { step("L1400 - Close gate C and check X112 sensor"); if (IO_Control.X112_Gate_C_Close_and_Check()) { StaticRes.Global.Process_Code.Loading = "L1900"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_C_not_closed, "L1400"); return; } } #endregion #endregion #region Index 4 #region ***(L1500)*** Open Gate D and check X115 if (StaticRes.Global.Process_Code.Loading == "L1500" && StaticRes.Global.Transaction_Continue) { step("L1500 - Open Gate D and check X115"); if (IO_Control.X115_Gate_D_Open_and_Check()) { StaticRes.Global.Process_Code.Loading = "L1600"; loadcomplete(false); return; } else { Error_Throw(StaticRes.Global.Error_List.Gate_D_not_opened, "L1500"); return; } } #endregion #region ***(L1600)*** Check loading door close sensor X102 if (StaticRes.Global.Process_Code.Loading == "L1600" && StaticRes.Global.Transaction_Continue) { step("L1600 - Check loading door close sensor X102"); if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed()) { StaticRes.Global.Process_Code.Loading = "L1700"; } else { Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "L1600"); return; } } #endregion #region ***(L1700)*** Check syringe D present sensor X107 if (StaticRes.Global.Process_Code.Loading == "L1700" && StaticRes.Global.Transaction_Continue) { step("L1700 - Check syringe D present sensor X107"); if (Hardware.IO_LIST.Input.X107_Syringe_D_Present()) { StaticRes.Global.Process_Code.Loading = "L1800"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_C_not_present, "L1700"); return; } } #endregion #region ***(L1800)*** Close gate D and check X114 if (StaticRes.Global.Process_Code.Loading == "L1800" && StaticRes.Global.Transaction_Continue) { step("L1800 - Close gate D and check X114 sensor"); if (IO_Control.X114_Gate_D_Close_and_Check()) { StaticRes.Global.Process_Code.Loading = "L1900"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_D_not_closed, "L1800"); return; } } #endregion #endregion #region ***(L1900)*** Loading completed , rotary continue moving if (StaticRes.Global.Process_Code.Loading == "L1900" && StaticRes.Global.Transaction_Continue) { step("L1900 - Loading completed"); try { IO_Control.Yellow_Tower_Light_Setting(); StaticRes.Global.Process_Code.Loading = "L000"; StaticRes.Global.IsOnProgress = false; loadcomplete(true); return; } catch (Exception ee) { Error_Throw(StaticRes.Global.Error_List.Motion_failed, "L1900"); return; } } #endregion return; } else { Error_Throw(StaticRes.Global.Error_List.Please_homing_first, "L000"); return; } } catch (Exception ee) { Common.Reports.LogFile.Log("Loading Error -- " + ee.Message + ",L000 , user:"******"From Load Exception"); return; } }
private void LogicWeight(int Capacity, bool Load_Process, string Scrap_Weight, string Expiry_Time, bool Force_Scrap, string Syringe_Weight) { try { if (!StaticRes.Global.Need_Homing) { #region ***(W000)*** Weighing tray cylinder forward and check X204 if (StaticRes.Global.Process_Code.Weighting == "W000") { step("W000 - Weighing tray cylinder forward and check X204"); if (IO_Control.X204_Weighing_Tray_Cylinder_Forward_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W100"; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_tray_cylinder_forward_failed, "W000"); return; } } #endregion #region ***(W100)*** Open weighting door and check X300 sensor to ask user put in material if (StaticRes.Global.Process_Code.Weighting == "W100") { step("W100 - Open weighing door and check X300"); if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; weightcontinue(Weight_Return); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W100"); return; } } #endregion #region ***(W200)*** Close weight door and check X301 sensor if (StaticRes.Global.Process_Code.Weighting == "W200") { step("W200 - Close weighing door and check X301"); if (IO_Control.X301_Weighing_Door_Close_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W300"; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_closed, "W200"); return; } } #endregion #region ***(W300)*** Check cap present sensor base on cap type if (StaticRes.Global.Process_Code.Weighting == "W300") { switch (Capacity) { case 5: { step("W300 - Check 5CC cap present sensor X305"); if (StaticRes.Global.System_Setting.Bypass_Syringe_5cc_Cap_Present_Sensor == "Y") { StaticRes.Global.Process_Code.Weighting = "W400"; } else { if (Hardware.IO_LIST.Input.X305_5cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Weighting = "W400"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Syringe_5cc_cap_not_present, "W300"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W300"); return; } } } } break; case 10: { step("W300 - Check 10CC cap present sensor X304"); if (StaticRes.Global.System_Setting.Bypass_Syringe_10cc_Cap_Present_Sensor == "Y") { StaticRes.Global.Process_Code.Weighting = "W400"; } else { if (Hardware.IO_LIST.Input.X304_10cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Weighting = "W400"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Syringe_10cc_cap_not_present, "W300"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W300"); return; } } } } break; case 30: { step("W300 - Check 30CC cap present sensor X303"); if (StaticRes.Global.System_Setting.Bypass_Syringe_30cc_Cap_Present_Sensor == "Y") { StaticRes.Global.Process_Code.Weighting = "W400"; } else { if (Hardware.IO_LIST.Input.X303_30cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Weighting = "W400"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Syringe_30cc_cap_not_present, "W300"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W300"); return; } } } } break; } } #endregion #region ***(W400)*** Check syringe top cover present sensor X302 if (StaticRes.Global.Process_Code.Weighting == "W400") { step("W400 - Check syringe top cover present sensor X302"); if (StaticRes.Global.System_Setting.Bypass_Syringe_Top_Cover_Sensor == "Y") { StaticRes.Global.Process_Code.Weighting = "W500"; } else { if (Hardware.IO_LIST.Input.X302_Syringe_Top_Cover_Present()) { StaticRes.Global.Process_Code.Weighting = "W500"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Syringe_top_cover_not_present, "W400"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W400"); return; } } } } #endregion #region ***(W500)*** Check syringe present sensor X306 if (StaticRes.Global.Process_Code.Weighting == "W500") { step("W500 - Check syringe present sensor X306"); if (Hardware.IO_LIST.Input.X306_Syringe_Present()) { StaticRes.Global.Process_Code.Weighting = "W600"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Syringe_not_present, "W500"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W500"); return; } } } #endregion #region ***(W600)*** Weighting And Read Data if (StaticRes.Global.Process_Code.Weighting == "W600") { try { Open_WeightScale_ComPort(); step("W600 - Weighting....Result:" + Weight_Return.ToString() + ""); DateTime Start_Time = System.DateTime.Now; System.Threading.Thread.Sleep(1000); while (Weight_Return < float.Parse(Syringe_Weight)) { TimeSpan ts = System.DateTime.Now - Start_Time; if (ts.TotalMilliseconds > 10000) { break; } } Close_WeightScale_ComPort(); if (Weight_Return >= float.Parse(Syringe_Weight)) { StaticRes.Global.Process_Code.Weighting = "W700"; } else { Common.Reports.LogFile.Log("Weighting Error [W600] -- " + Weight_Return.ToString() + "<" + Syringe_Weight.ToString()); if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Weighing_Failed, "W600"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W600"); return; } } } catch { Common.Reports.LogFile.Log("Weighting Error [W600] -- " + Weight_Return.ToString() + "<" + Syringe_Weight.ToString()); if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Weighing_Failed, "W600"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W600"); return; } } } #endregion #region ***(W700)*** Check either is load or return , if load-go W1000,if return- go W800 if (StaticRes.Global.Process_Code.Weighting == "W700") { if (Load_Process) { StaticRes.Global.Process_Code.Weighting = "W1000"; } else { StaticRes.Global.Process_Code.Weighting = "W800"; } } #endregion #region ***(W800)*** Check either is scrap or reuse , if reuse-go W1000, if scrap-go W900 if (StaticRes.Global.Process_Code.Weighting == "W800") { try { string Status = string.Empty; if (Force_Scrap) { Status = StaticRes.Global.Status.Scrap; } else { if (DateTime.Parse(Expiry_Time) <= System.DateTime.Now) { Status = StaticRes.Global.Status.Scrap; } else if (Weight_Return <= float.Parse(Scrap_Weight)) { Status = StaticRes.Global.Status.Scrap; } else if (DateTime.Parse(Expiry_Time) <= System.DateTime.Now.AddHours(StaticRes.Global.System_Setting.Time_1))//yakun.zhoou 2015/06/30 { Status = StaticRes.Global.Status.Scrap; } else { Status = StaticRes.Global.Status.Reuse; } } if (Status == StaticRes.Global.Status.Reuse) { StaticRes.Global.Process_Code.Weighting = "W1000"; } else { StaticRes.Global.Process_Code.Weighting = "W900"; } step("W800 - Syringe go " + Status + ""); } catch { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W200"; Error_Throw(StaticRes.Global.Error_List.Weighing_Failed, "W800"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W800"); return; } } } #endregion #region ***(W900)*** if force scrap , scrap chute open if (StaticRes.Global.Process_Code.Weighting == "W900") { if (Force_Scrap) { step("W900 - Force scrap ,open scrap chute to scrap drawer 2 and check X203 sensor"); if (IO_Control.X203_Scrap_Chute_To_Drawer_2_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W910"; } else { Error_Throw(StaticRes.Global.Error_List.Scrap_shute_cyiinder_to_drawer_2_failed, "W900"); return; } } else { step("W900 - Normal scrap , open scrap chute to scrap drawer 1 and check X202 sensor"); if (IO_Control.X202_Scrap_Chute_To_Drawer_1_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W910"; } else { Error_Throw(StaticRes.Global.Error_List.Scrap_chute_cylinder_to_drawer_1_failed, "W900"); return; } } } #endregion #region ***(W910)*** Weighting tray cylinder backward and check X205 if (StaticRes.Global.Process_Code.Weighting == "W910") { step("W910 - Weighting tray cylinder backward and check X205"); if (IO_Control.X205_Weighing_Tray_Cylinder_Backward_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W920"; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_tray_cylinder_backward_failed, "W910"); return; } } #endregion #region ***(W920)*** Null if (StaticRes.Global.Process_Code.Weighting == "W920") { StaticRes.Global.Process_Code.Weighting = "W930"; } #endregion #region ***(W930)*** Weighting tray cylinder backward and check X205 if (StaticRes.Global.Process_Code.Weighting == "W930") { step("W930 - Weighting tray cylinder forward and check X204"); if (IO_Control.X204_Weighing_Tray_Cylinder_Forward_and_Check()) { Weight_Return = 100 + Weight_Return; //for indicate whether need update server after weighing StaticRes.Global.Process_Code.Weighting = "W1600"; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_tray_cylinder_forward_failed, "W930"); return; } } #endregion #region ***(W1000)*** Open Weight Scale door and check X300 sensor to ask user take out material if (StaticRes.Global.Process_Code.Weighting == "W1000") { step("W1000 - Open weighting door and check X300"); if (IO_Control.X300_Weighing_Door_Open_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W1100"; weightcontinue(Weight_Return); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "W1000"); return; } } #endregion #region ***(W1100)*** Check syringe top cover present sensor X302 if (StaticRes.Global.Process_Code.Weighting == "W1100") { step("W1100 - Check syringe top cover present sensor X302"); if (!Hardware.IO_LIST.Input.X302_Syringe_Top_Cover_Present()) { StaticRes.Global.Process_Code.Weighting = "W1200"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_top_cover_present, "W1100"); return; } } #endregion #region ***(W1200)*** Check 30cc cap present sensor X303 if (StaticRes.Global.Process_Code.Weighting == "W1200") { step("W1200 - Check 30cc cap present sensor X303"); if (!Hardware.IO_LIST.Input.X303_30cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Weighting = "W1300"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_30cc_cap_present, "W1200"); return; } } #endregion #region ***(W1300)*** Check 10cc cap present sensor X304 if (StaticRes.Global.Process_Code.Weighting == "W1300") { step("W1300 - Check 10cc syringe cap present sensor X304"); if (!Hardware.IO_LIST.Input.X304_10cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Weighting = "W1400"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_10cc_cap_present, "W1300"); return; } } #endregion #region ***(W1400)*** Check 5cc cap present sensor X305 if (StaticRes.Global.Process_Code.Weighting == "W1400") { step("W1400 - Check 5cc cap present sensor X305"); if (!Hardware.IO_LIST.Input.X305_5cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Weighting = "W1500"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_5cc_cap_present, "W1400"); return; } } #endregion #region ***(W1500)*** Check syringe present sensor X306 if (StaticRes.Global.Process_Code.Weighting == "W1500") { step("W1500 - Check syringe present sensor X306"); if (!Hardware.IO_LIST.Input.X306_Syringe_Present()) { StaticRes.Global.Process_Code.Weighting = "W1600"; } else { Error_Throw(StaticRes.Global.Error_List.Syringe_present, "W1500"); return; } } #endregion #region ***(W1600)*** Close weight scale door and check X301 sensor if (StaticRes.Global.Process_Code.Weighting == "W1600") { step("W1600 - Close weighing door and check X301 sensor"); if (IO_Control.X301_Weighing_Door_Close_and_Check()) { StaticRes.Global.Process_Code.Weighting = "W000"; StaticRes.Global.IsOnProgress = false; weightcomplete(Weight_Return); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_closed, "W1600"); return; } } #endregion } } catch (Exception ee) { Common.Reports.LogFile.Log("Weighting Error -- " + ee.Message + ",W000 , user:"******"From Weighting Exception"); return; } }
private void LogicHome(bool Continue) { try { System.IO.Ports.SerialPort soltScanner_1 = new System.IO.Ports.SerialPort(StaticRes.Global.SlotScannerPort.Index1Port); System.IO.Ports.SerialPort soltScanner_2 = new System.IO.Ports.SerialPort(StaticRes.Global.SlotScannerPort.Index2Port); System.IO.Ports.SerialPort soltScanner_3 = new System.IO.Ports.SerialPort(StaticRes.Global.SlotScannerPort.Index3Port); System.IO.Ports.SerialPort soltScanner_4 = new System.IO.Ports.SerialPort(StaticRes.Global.SlotScannerPort.Index4Port); if (soltScanner_1.IsOpen) { soltScanner_1.Close(); } if (soltScanner_2.IsOpen) { soltScanner_2.Close(); } if (soltScanner_3.IsOpen) { soltScanner_3.Close(); } if (soltScanner_4.IsOpen) { soltScanner_4.Close(); } if (!StaticRes.Global.Hardware_Connection) { homecomplete(); return; } Motion_Control.Rotary_Motion_Stop(); #region ***(H000)*** Turn on green tower light if (StaticRes.Global.Process_Code.Homing == "H000" && StaticRes.Global.Transaction_Continue) { step("H000 - Turn on green light"); HardwareControl.IO_Control.Green_Tower_Light_Setting(); StaticRes.Global.Process_Code.Homing = "H100"; } #endregion #region ***(H100)*** Loading door close and check X102 sensor if (StaticRes.Global.Process_Code.Homing == "H100" && StaticRes.Global.Transaction_Continue) { step("H100 - Loading door close and check X102 sensor"); if (Hardware.IO_LIST.Input.X102_Loading_Door_Closed()) { StaticRes.Global.Process_Code.Homing = "H200"; } else { Error_Throw(StaticRes.Global.Error_List.Loading_door_not_closed, "H100"); return; } } #endregion #region ***(H200)*** Check thawing box door closed sensor X103 if (StaticRes.Global.Process_Code.Homing == "H200" && StaticRes.Global.Transaction_Continue) { step("H200 - Check thawing door close sensor X103 "); if (Hardware.IO_LIST.Input.X103_Thawing_Door_Closed()) { StaticRes.Global.Process_Code.Homing = "H300"; } else { Error_Throw(StaticRes.Global.Error_List.Thawing_door_not_closed, "H200"); return; } } #endregion #region ***(H300)*** Check syringe top cover present sensor X302 if (StaticRes.Global.Process_Code.Homing == "H300" && StaticRes.Global.Transaction_Continue) { step("H300 - Check syringe top cover present sensor X302"); if (!Hardware.IO_LIST.Input.X302_Syringe_Top_Cover_Present()) { StaticRes.Global.Process_Code.Homing = "H400"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { Error_Throw(StaticRes.Global.Error_List.Syringe_top_cover_present, "H300"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "H300"); return; } } } #endregion #region ***(H400)*** Check 30cc syringe cap present sensor X303 if (StaticRes.Global.Process_Code.Homing == "H400" && StaticRes.Global.Transaction_Continue) { step("H400 - Check 30 CC syringe cap present sensor X303"); if (!Hardware.IO_LIST.Input.X303_30cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Homing = "H500"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { Error_Throw(StaticRes.Global.Error_List.Syringe_30cc_cap_present, "H400"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "H400"); return; } } } #endregion #region ***(H500)*** Check 10 cc syringe cap present sensor X304 if (StaticRes.Global.Process_Code.Homing == "H500" && StaticRes.Global.Transaction_Continue) { step("H500 - Check 10 CC syringe cap present sensor X304"); if (!Hardware.IO_LIST.Input.X304_10cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Homing = "H600"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { Error_Throw(StaticRes.Global.Error_List.Syringe_10cc_cap_present, "H500"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "H500"); return; } } } #endregion #region ***(H600)*** Check 5cc syringe cap present sensor X305 if (StaticRes.Global.Process_Code.Homing == "H600" && StaticRes.Global.Transaction_Continue) { step("H600 - Check 5CC syringe cap present sensor X305"); if (!Hardware.IO_LIST.Input.X304_10cc_Syringe_Cap_Present()) { StaticRes.Global.Process_Code.Homing = "H700"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { Error_Throw(StaticRes.Global.Error_List.Syringe_5cc_cap_present, "H600"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "H600"); return; } } } #endregion #region ***(H700)*** Check syringe present sensor X306 if (StaticRes.Global.Process_Code.Homing == "H700" && StaticRes.Global.Transaction_Continue) { step("H700 - Check syringe present sensor X306"); if (!Hardware.IO_LIST.Input.X306_Syringe_Present()) { StaticRes.Global.Process_Code.Homing = "H800"; } else { if (IO_Control.X300_Weighing_Door_Open_and_Check()) { Error_Throw(StaticRes.Global.Error_List.Syringe_present, "H700"); return; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_opened, "H700"); return; } } } #endregion #region ***(H800)*** Weighing door not close and check X301 sensor if (StaticRes.Global.Process_Code.Homing == "H800" && StaticRes.Global.Transaction_Continue) { step("H800 - Weighing door close and check X301 sensor"); if (IO_Control.X301_Weighing_Door_Close_and_Check()) { StaticRes.Global.Process_Code.Homing = "H900"; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_door_not_closed, "H800"); return; } } #endregion #region ***(H900)*** Null if (StaticRes.Global.Process_Code.Homing == "H900" && StaticRes.Global.Transaction_Continue) { StaticRes.Global.Process_Code.Homing = "H1000"; } #endregion #region ***(H1000)*** Null if (StaticRes.Global.Process_Code.Homing == "H1000" && StaticRes.Global.Transaction_Continue) { StaticRes.Global.Process_Code.Homing = "H1100"; } #endregion #region ***(H1100)*** Close scrap drawer 1 and check X200 if (StaticRes.Global.Process_Code.Homing == "H1100" && StaticRes.Global.Transaction_Continue) { step("H1100 - Close scrap drawer 1 and check X200"); if (Hardware.IO_LIST.Input.X200_Scrap_Drawer_1_Closed()) { StaticRes.Global.Process_Code.Homing = "H1200"; } else { Error_Throw(StaticRes.Global.Error_List.Scrap_drawer_1_not_closed, "H1100"); return; } } #endregion #region ***(H1200)*** Close scrap drawer 2 and check X201 if (StaticRes.Global.Process_Code.Homing == "H1200" && StaticRes.Global.Transaction_Continue) { step("H1200 - Close scrap drawer 2 and check X201"); if (Hardware.IO_LIST.Input.X201_Scrap_Drawer_2_Closed()) { StaticRes.Global.Process_Code.Homing = "H1300"; } else { Error_Throw(StaticRes.Global.Error_List.Scrap_drawer_2_not_closed, "H1200"); return; } } #endregion #region ***(H1300)*** Weighing tray forward and check X204 if (StaticRes.Global.Process_Code.Homing == "H1300" && StaticRes.Global.Transaction_Continue) { step("H1300 - Weighing tray forward and check X204"); if (IO_Control.X204_Weighing_Tray_Cylinder_Forward_and_Check()) { StaticRes.Global.Process_Code.Homing = "H1400"; } else { Error_Throw(StaticRes.Global.Error_List.Weighing_tray_cylinder_forward_failed, "H1300"); return; } } #endregion #region ***(H1400)*** Ejector A down and check X209 if (StaticRes.Global.Process_Code.Homing == "H1400" && StaticRes.Global.Transaction_Continue) { step("H1400 - Ejector A down and check X209"); if (IO_Control.X209_Ejector_A_Down_and_Check()) { StaticRes.Global.Process_Code.Homing = "H1500"; } else { Error_Throw(StaticRes.Global.Error_List.Ejector_A_not_down, "H1400"); return; } } #endregion #region ***(H1500)*** Ejector B down and check X211 if (StaticRes.Global.Process_Code.Homing == "H1500" && StaticRes.Global.Transaction_Continue) { step("H1500 - Ejector B down and check X211"); if (IO_Control.X211_Ejector_B_Down_and_Check()) { StaticRes.Global.Process_Code.Homing = "H1600"; } else { Error_Throw(StaticRes.Global.Error_List.Ejector_B_not_down, "H1500"); return; } } #endregion #region ***(H1600)*** Ejector C down and check X213 if (StaticRes.Global.Process_Code.Homing == "H1600" && StaticRes.Global.Transaction_Continue) { step("H1600 - Ejector C down and check X213"); if (IO_Control.X213_Ejector_C_Down_and_Check()) { StaticRes.Global.Process_Code.Homing = "H1700"; } else { Error_Throw(StaticRes.Global.Error_List.Ejector_C_not_down, "H1600"); return; } } #endregion #region ***(H1700)*** Ejector D down and check X215 if (StaticRes.Global.Process_Code.Homing == "H1700" && StaticRes.Global.Transaction_Continue) { step("H1700 - Ejector D down and check X215"); if (IO_Control.X215_Ejector_D_Down_and_Check()) { StaticRes.Global.Process_Code.Homing = "H1800"; } else { Error_Throw(StaticRes.Global.Error_List.Ejector_D_not_down, "H1700"); return; } } #endregion #region ***(H1800)*** Close Gate A and check X108 if (StaticRes.Global.Process_Code.Homing == "H1800" && StaticRes.Global.Transaction_Continue) { step("H1800 - Close Gate A and check X108 "); if (IO_Control.X108_Gate_A_Close_and_Check()) { StaticRes.Global.Process_Code.Homing = "H1900"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_A_not_closed, "H1800"); return; } } #endregion #region ***(H1900)*** Close Gate B and check X110 if (StaticRes.Global.Process_Code.Homing == "H1900" && StaticRes.Global.Transaction_Continue) { step("H1900 - Close Gate B and check X110 "); if (IO_Control.X110_Gate_B_Close_and_Check()) { StaticRes.Global.Process_Code.Homing = "H2000"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_B_not_closed, "H1900"); return; } } #endregion #region ***(H2000)*** Close Gate C and check X112 if (StaticRes.Global.Process_Code.Homing == "H2000" && StaticRes.Global.Transaction_Continue) { step("H2000 - Close Gate C and check X112 "); if (IO_Control.X112_Gate_C_Close_and_Check()) { StaticRes.Global.Process_Code.Homing = "H2100"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_A_not_closed, "H2000"); return; } } #endregion #region ***(H2100)*** Close Gate D and check X114 if (StaticRes.Global.Process_Code.Homing == "H2100" && StaticRes.Global.Transaction_Continue) { step("H2100 - Close Gate D and check X114 "); if (IO_Control.X114_Gate_D_Close_and_Check()) { StaticRes.Global.Process_Code.Homing = "H2200"; } else { Error_Throw(StaticRes.Global.Error_List.Gate_A_not_closed, "H2100"); return; } } #endregion #region ***(H2200)*** Rotary Homing if (StaticRes.Global.Process_Code.Homing == "H2200" && StaticRes.Global.Transaction_Continue) { try { step("H2200 - Rotary motor homing "); int i = 1; do { i++; HardwareControl.Motion_Control.Motion_Speed_Checking(); HardwareControl.Motion_Control.Rotary_Move(100000); HardwareControl.Motion_Control.Motion_Speed_Checking(); HardwareControl.Motion_Control.Rotary_Motor_Homing(); HardwareControl.Motion_Control.Motion_Speed_Checking(); HardwareControl.Motion_Control.Rotary_Move(-StaticRes.Global.System_Setting.Rotary_Homing_Pitch); HardwareControl.Motion_Control.Motion_Speed_Checking(); }while (!HardwareControl.Motion_Control.Rotary_Homing_Sensor_On() && i < 3); if (HardwareControl.Motion_Control.Rotary_Homing_Sensor_On()) { HardwareControl.Motion_Control.Set_Rotary_Zero_Position(); StaticRes.Global.Process_Code.Homing = "H2300"; } else { Error_Throw(StaticRes.Global.Error_List.Rotary_homing_failed, "H2200"); return; } } catch { } } #endregion #region ***(H2300)*** Move to standard position if (StaticRes.Global.Process_Code.Homing == "H2300" && StaticRes.Global.Transaction_Continue) { step("H2300 - Homing complete"); try { StaticRes.Global.Process_Code.Homing = "H000"; StaticRes.Global.Process_Code.Loading = "L000"; StaticRes.Global.Process_Code.Unloading = "U000"; StaticRes.Global.Process_Code.Returning = "R000"; StaticRes.Global.Process_Code.Weighting = "W000"; StaticRes.Global.Need_Homing = false; DataTable dt = DataProvider.Local.Binning.Select.Bin_WithMateria(); if (dt.Rows.Count > 0) { HardwareControl.Motion_Control.Rotary_Continue_Move(); } } catch (Exception ex) { Common.Reports.LogFile.Log("Homing H2300 Exception, Msg:" + ex.ToString()); Error_Throw(StaticRes.Global.Error_List.Motion_failed, "H2300"); return; } } #endregion StaticRes.Global.IsOnProgress = false; homecomplete(); return; } catch (Exception ee) { Common.Reports.LogFile.Log("Homing Error -- " + ee.Message + ",H000 , user:"******"From Homing Exception"); return; } }
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; } }
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; } }