/// <summary> /// //AGV在各工作区卸货完成后,检查是否还有订单(如果多于或大于2个,则通知立库出库,有1个说明有一个当前正在操作),并且检查每个工作区是否有空闲, //如果两个条件都满足,我们就通知立库继续出库(向立库指令表中插入出库信息) /// </summary> private void CheckAndInformWH(object endpoint) { int EndPoint = 0; if (endpoint != null) { EndPoint = Convert.ToInt32(endpoint); } DataBaseHandle db = new DataBaseHandle(); SqlConnection con = new SqlConnection(); Thread.Sleep(TimeSpan.FromSeconds(5)); // 发布AGV的状态给各个PLC保持5s SetNull(); if (StateMachine.P_Process_Area1 == 0 && MainWindow.WHMatchingProcess1 == false && StateMachine.P_System_State == 2 && MainWindow.P_Order_Enable == true) { bool P_Outlib_Can = db.JudgeOutlib(con, "加工订单") && db.JudgePreOutlibNum(con, "加工订单"); //判断加工订单是否还可以出库 if (P_Outlib_Can == true) { db.InsertWHCmd(con, "加工订单", "侧边出库", ConfigClass.Tray_A1); //侧边出库加工毛坯托盘A1 db.InsertWHCmd(con, "加工订单", "出库", ConfigClass.Tray_A0); //出库加工空托盘A0 db.UpdatePreOutlibNum(con, "加工订单"); MainWindow.WHMatchingProcess1 = true; RefreshWHMatchingWorkArea(EndPoint); RefreshAGVMatchingWorkArea(EndPoint); InformWHThreadState = false; return; } } if (StateMachine.D_Detection_Area1 == 0 && MainWindow.WHMatchingDetection1 == false && StateMachine.D_System_State == 2 && MainWindow.D_Order_Enable == true) { bool D_Outlib_Can = db.JudgeOutlib(con, "检测订单") && db.JudgePreOutlibNum(con, "检测订单"); //判断检测订单是否还可以出库 if (D_Outlib_Can == true) { db.InsertWHCmd(con, "检测订单", "出库", ConfigClass.Tray_A2); //出库加工成品托盘A2托盘 db.UpdatePreOutlibNum(con, "检测订单"); MainWindow.WHMatchingDetection1 = true; RefreshWHMatchingWorkArea(EndPoint); RefreshAGVMatchingWorkArea(EndPoint); InformWHThreadState = false; return; } } if (StateMachine.A_Assembly_Area1 == 0 && StateMachine.A_Assembly_InArea1 == 0 && MainWindow.WHMatchingAssembly1 == false && StateMachine.A_System_State == 2 && MainWindow.A1_Order_Enable == true) { bool A1_Outlib_Can = db.JudgeOutlib(con, "拧螺丝订单") && db.JudgePreOutlibNum(con, "拧螺丝订单"); //判断拧螺丝订单是否还可以出库 if (A1_Outlib_Can == true) { db.InsertWHCmd(con, "拧螺丝订单", "出库", ConfigClass.Tray_B1); //出库拧螺钉打钉托盘B1 db.UpdatePreOutlibNum(con, "拧螺丝订单"); MainWindow.WHMatchingAssembly1 = true; RefreshWHMatchingWorkArea(EndPoint); RefreshAGVMatchingWorkArea(EndPoint); InformWHThreadState = false; return; } } if (StateMachine.A_Assembly_Area2 == 0 && StateMachine.A_Assembly_InArea2 == 0 && MainWindow.WHMatchingAssembly2 == false && StateMachine.A_System_State == 2 && MainWindow.A2_Order_Enable == true) { bool A2_Outlib_Can = db.JudgeOutlib(con, "轴承压装订单") && db.JudgePreOutlibNum(con, "轴承压装订单"); //判断轴承压装订单是否还可以出库 if (A2_Outlib_Can == true) { db.InsertWHCmd(con, "轴承压装订单", "出库", ConfigClass.Tray_A4); //出库轴承压装毛坯托盘A4 db.UpdatePreOutlibNum(con, "轴承压装订单"); MainWindow.WHMatchingAssembly2 = true; RefreshWHMatchingWorkArea(EndPoint); RefreshAGVMatchingWorkArea(EndPoint); InformWHThreadState = false; return; } } if (StateMachine.P_Process_Area2 == 0 && MainWindow.WHMatchingProcess2 == false && StateMachine.P_System_State == 2 && MainWindow.P_Order_Enable == true) { bool P_Outlib_Can = db.JudgeOutlib(con, "加工订单") && db.JudgePreOutlibNum(con, "加工订单"); //判断加工订单是否还可以出库 if (P_Outlib_Can == true) { db.InsertWHCmd(con, "加工订单", "侧边出库", ConfigClass.Tray_A1); //侧边出库加工毛坯托盘A1 db.InsertWHCmd(con, "加工订单", "出库", ConfigClass.Tray_A0); //出库加工空托盘A0 db.UpdatePreOutlibNum(con, "加工订单"); MainWindow.WHMatchingProcess2 = true; RefreshWHMatchingWorkArea(EndPoint); RefreshAGVMatchingWorkArea(EndPoint); InformWHThreadState = false; return; } } if (StateMachine.D_Detection_Area2 == 0 && MainWindow.WHMatchingDetection2 == false && StateMachine.D_System_State == 2 && MainWindow.D_Order_Enable == true) { bool D_Outlib_Can = db.JudgeOutlib(con, "检测订单") && db.JudgePreOutlibNum(con, "检测订单"); //判断检测订单是否还可以出库 if (D_Outlib_Can == true) { db.InsertWHCmd(con, "检测订单", "出库", ConfigClass.Tray_A2); //出库加工成品托盘A2托盘 db.UpdatePreOutlibNum(con, "检测订单"); MainWindow.WHMatchingDetection2 = true; RefreshWHMatchingWorkArea(EndPoint); RefreshAGVMatchingWorkArea(EndPoint); InformWHThreadState = false; return; } } //上诉if条件都进不去的话,依然要刷新立库和AGV的匹配状态 RefreshWHMatchingWorkArea(EndPoint); RefreshAGVMatchingWorkArea(EndPoint); }
private void CheckWHNumber(string OrderStyle) { DataBaseHandle db = new DataBaseHandle(); SqlConnection con = new SqlConnection(); //检查入库数量 bool P_InlibNum = db.JudgeCompleteNum(con, "加工订单"); //小于订单数量就返回true bool D_InlibNum = db.JudgeCompleteNum(con, "检测订单"); bool A1_InlibNum = db.JudgeCompleteNum(con, "拧螺丝订单"); bool A2_InlibNum = db.JudgeCompleteNum(con, "轴承压装订单"); if (P_InlibNum == false) { MainWindow.orderstate.P_Order = ""; DTUSendPackage.P_Order_Enable = 0; DTUSendPackage.Hand_Order_Enabel = 1; MainWindow.P_Order_Enable = false; } if (D_InlibNum == false) { MainWindow.orderstate.D_Order = ""; DTUSendPackage.D_Order_Enable = 0; MainWindow.D_Order_Enable = false; } if (A1_InlibNum == false) { MainWindow.orderstate.A1_Order = ""; DTUSendPackage.A1_Order_Enable = 0; MainWindow.A1_Order_Enable = false; } if (A2_InlibNum == false) { MainWindow.orderstate.A2_Order = ""; DTUSendPackage.A2_Order_Enable = 0; MainWindow.A2_Order_Enable = false; } if (P_InlibNum == false && D_InlibNum == false && A1_InlibNum == false && A2_InlibNum == false) { //所有订单都完成了 //对下订单和执行订单两个按钮解禁。 OCDelegate(); //触发事件 } if (OrderStyle == "加工订单") { //检查出库数量 bool P_OutlibNum = db.JudgeOutlib(con, "加工订单"); //小于订单数量就返回true bool P_PreOutlibNum = db.JudgePreOutlibNum(con, "加工订单"); //小于订单数量就返回 //检查是否可以继续出库 bool P_Can_Outlib = P_InlibNum && P_OutlibNum && P_PreOutlibNum; if (P_Can_Outlib == true && StateMachine.P_Process_Area1 == 0 && MainWindow.WHMatchingProcess1 == false && StateMachine.P_System_State == 2 && MainWindow.P_Order_Enable == true) { db.InsertWHCmd(con, "加工订单", "侧边出库", ConfigClass.Tray_A1); //侧边出库加工毛坯托盘A1 db.InsertWHCmd(con, "加工订单", "出库", ConfigClass.Tray_A0); //出库加工空托盘A0 db.UpdatePreOutlibNum(con, "加工订单"); MainWindow.WHMatchingProcess1 = true; return; } if (P_Can_Outlib == true && StateMachine.P_Process_Area2 == 0 && MainWindow.WHMatchingProcess2 == false && StateMachine.P_System_State == 2 && MainWindow.P_Order_Enable == true) { db.InsertWHCmd(con, "加工订单", "侧边出库", ConfigClass.Tray_A1); //侧边出库加工毛坯托盘A1 db.InsertWHCmd(con, "加工订单", "出库", ConfigClass.Tray_A0); //出库加工空托盘A0 db.UpdatePreOutlibNum(con, "加工订单"); MainWindow.WHMatchingProcess2 = true; return; } return; } if (OrderStyle == "检测订单") { //检查出库数量 bool D_OutlibNum = db.JudgeOutlib(con, "检测订单"); bool D_PreOutlibNum = db.JudgeOutlib(con, "检测订单"); //检查是否可以继续出库 bool D_Can_Outlib = D_InlibNum && D_OutlibNum && D_PreOutlibNum; if (D_Can_Outlib == true && StateMachine.D_Detection_Area1 == 0 && MainWindow.WHMatchingDetection1 == false && StateMachine.D_System_State == 2 && MainWindow.D_Order_Enable == true) { db.InsertWHCmd(con, "检测订单", "出库", ConfigClass.Tray_A2); //出库加工成品托盘A2托盘 db.UpdatePreOutlibNum(con, "检测订单"); MainWindow.WHMatchingDetection1 = true; return; } if (D_Can_Outlib == true && StateMachine.D_Detection_Area2 == 0 && MainWindow.WHMatchingDetection2 == false && StateMachine.D_System_State == 2 && MainWindow.D_Order_Enable == true) { db.InsertWHCmd(con, "检测订单", "出库", ConfigClass.Tray_A2); //出库加工成品托盘A2托盘 db.UpdatePreOutlibNum(con, "检测订单"); MainWindow.WHMatchingDetection2 = true; return; } return; } if (OrderStyle == "拧螺丝订单") { //检查出库数量 bool A1_OutlibNum = db.JudgeOutlib(con, "拧螺丝订单"); bool A1_PreOutlibNum = db.JudgePreOutlibNum(con, "拧螺丝订单"); //检查是否可以继续出库 bool A1_Can_Outlib = A1_InlibNum && A1_OutlibNum && A1_PreOutlibNum; if (A1_Can_Outlib == true && StateMachine.A_Assembly_Area1 == 0 && StateMachine.A_Assembly_InArea1 == 0 && MainWindow.WHMatchingAssembly1 == false && StateMachine.A_System_State == 2 && MainWindow.A1_Order_Enable == true) { db.InsertWHCmd(con, "拧螺丝订单", "出库", ConfigClass.Tray_B1); //出库拧螺钉打钉托盘B1 db.UpdatePreOutlibNum(con, "拧螺丝订单"); MainWindow.WHMatchingAssembly1 = true; return; } return; } if (OrderStyle == "轴承压装订单") { //检查出库数量 bool A2_OutlibNum = db.JudgeOutlib(con, "轴承压装订单"); bool A2_PreOutlibNum = db.JudgePreOutlibNum(con, "轴承压装订单"); //检查是否可以继续出库 bool A2_Can_Outlib = A2_InlibNum && A2_OutlibNum && A2_PreOutlibNum; if (A2_Can_Outlib == true && StateMachine.A_Assembly_Area2 == 0 && StateMachine.A_Assembly_InArea2 == 0 && MainWindow.WHMatchingAssembly2 == false && StateMachine.A_System_State == 2 && MainWindow.A2_Order_Enable == true) { db.InsertWHCmd(con, "轴承压装订单", "出库", ConfigClass.Tray_A4); //出库轴承压装毛坯托盘A4 db.UpdatePreOutlibNum(con, "轴承压装订单"); MainWindow.WHMatchingAssembly2 = true; return; } } }