public VMResultLot GetTrayCellLotNO(string trayNo) { try { return(MesAcc.GetTrayCellLotNO(trayNo)); } catch (Exception ex) { VMResultLot re = new VMResultLot(); re.ResultCode = -1; re.ResultMsg = "MES网络异常:" + ex.Message; return(re); } }
private int GetSwitchDecision(string palletID, ref string reStr) { int re = 0; #region 查询本地应该进入哪个分区 /* * string nextMesStepID = targetPorts[0].AsrsCtl.GetNextStepID(this.rfidUID); * string currentMesStepID = GetCurrentStepID(this.rfidUID); * int curSeq = SysCfg.SysCfgModel.stepSeqs.IndexOf(currentMesStepID); * int nextSeq = SysCfg.SysCfgModel.stepSeqs.IndexOf(nextMesStepID); * string storeAreaZone = AsrsModel.EnumLogicArea.常温区.ToString(); * int seq1 = SysCfg.SysCfgModel.stepSeqs.IndexOf("PS-60"); * //int seq2 = SysCfg.SysCfgModel.stepSeqs.IndexOf("PS-100"); * if (nextSeq <= seq1) * { * storeAreaZone = AsrsModel.EnumLogicArea.冷却区.ToString(); * } * else * { * * storeAreaZone = AsrsModel.EnumLogicArea.常温区.ToString(); * }*/ #endregion #region 查询MES 下一步应该进哪个库区 string storeAreaZone = AsrsModel.EnumLogicArea.常温区.ToString(); ANCStepResult stepRe = MesAcc.GetStep(palletID); if (stepRe.ResultCode != 0) { reStr = string.Format("查询MES托盘{0}步次失败:{1}", palletID, stepRe.ResultMsg); return(-1); } if (stepRe.Step < 12) { storeAreaZone = AsrsModel.EnumLogicArea.冷却区.ToString(); } else { storeAreaZone = AsrsModel.EnumLogicArea.常温区.ToString(); } #endregion if (targetPorts[0].PalletBuffer.Count() == 0 && targetPorts[1].PalletBuffer.Count() == 0) { //查询C1,C2库剩余货位数量 int cellEmptCounts1 = 0, cellEmptCounts2 = 0; this.asrsResManage.GetHouseAreaLeftGs("C1库房", storeAreaZone, ref cellEmptCounts1, reStr); this.asrsResManage.GetHouseAreaLeftGs("C2库房", storeAreaZone, ref cellEmptCounts2, reStr); if (cellEmptCounts1 >= cellEmptCounts2 && cellEmptCounts1 > 0 && targetPorts[0].Db2Vals[0] != 2 && targetPorts[0].Db2Vals[1] != 2) { re = 1;//流向C1, this.db1ValsToSnd[0] = 1; } else if (cellEmptCounts1 < cellEmptCounts2 && cellEmptCounts2 > 0 && targetPorts[1].Db2Vals[0] != 2 && targetPorts[1].Db2Vals[1] != 2) { re = 2;//流向C2, this.db1ValsToSnd[0] = 2; } else { re = 3;//等待 this.db1ValsToSnd[0] = 3; } } else { bool switchStat = false; for (int i = 0; i < targetPorts.Count(); i++) { if (targetPorts[i].PalletBuffer.Count() > 0 && targetPorts[i].PalletBuffer.Count() < targetPorts[i].PortinBufCapacity) { string lastPalletID = targetPorts[i].PalletBuffer[targetPorts[i].PalletBuffer.Count() - 1]; #region 查询MES应该进入那个分区,及批次 string storeAreaZoneLast = AsrsModel.EnumLogicArea.冷却区.ToString(); stepRe = MesAcc.GetStep(lastPalletID); if (stepRe.ResultCode != 0) { reStr = "查询MES托盘步次失败:" + stepRe.ResultMsg; return(-1); } if (stepRe.Step < 12) { storeAreaZoneLast = AsrsModel.EnumLogicArea.冷却区.ToString(); } else { storeAreaZoneLast = AsrsModel.EnumLogicArea.常温区.ToString(); } VMResultLot reLast = MesAcc.GetTrayCellLotNO(lastPalletID); VMResultLot reCur = MesAcc.GetTrayCellLotNO(this.rfidUID); if (reLast.ResultCode != 0) { reStr = string.Format("查询MES 托盘号{0}的批次失败,{1}", lastPalletID, reLast.ResultMsg); break; } if (reCur.ResultCode != 0) { reStr = string.Format("查询MES 托盘号{0}的批次失败,{1}", this.rfidUID, reCur.ResultMsg); break; } string preBatch = reLast.LotNO; //productOnlineBll.GetBatchNameofPallet(lastPalletID); string curBatch = reCur.LotNO; //productOnlineBll.GetBatchNameofPallet(this.rfidUID); #endregion #region 查询MES应该进入那个分区,本地批次信息 /* * string preBatch = productOnlineBll.GetBatchNameofPallet(lastPalletID); * string curBatch = productOnlineBll.GetBatchNameofPallet(this.rfidUID); * string nextMesStepIDLast = targetPorts[0].AsrsCtl.GetNextStepID(lastPalletID); * string currentMesStepIDLast = GetCurrentStepID(lastPalletID); * int curSeqLast = SysCfg.SysCfgModel.stepSeqs.IndexOf(currentMesStepIDLast); * int nextSeqLast = SysCfg.SysCfgModel.stepSeqs.IndexOf(nextMesStepIDLast); * string storeAreaZoneLast = AsrsModel.EnumLogicArea.冷却区.ToString(); * int seq1Last = SysCfg.SysCfgModel.stepSeqs.IndexOf("PS-60"); * //int seq2 = SysCfg.SysCfgModel.stepSeqs.IndexOf("PS-100"); * if (nextSeqLast <= seq1Last) * { * storeAreaZoneLast = AsrsModel.EnumLogicArea.冷却区.ToString(); * } * else * { * * storeAreaZoneLast = AsrsModel.EnumLogicArea.常温区.ToString(); * }*/ #endregion if (preBatch == curBatch && (storeAreaZone == storeAreaZoneLast)) { re = (Int16)(i + 1);//this.db1ValsToSnd[0] = //targetPorts[i].PushPalletID(this.rfidUID); switchStat = true; break; } } } if (!switchStat) //遍历各入口未能满足2筐入库规则,则选择缓存为空的入口 { for (int i = 0; i < targetPorts.Count(); i++) { //if (targetPorts[i].PalletBuffer.Count() == 0 && ((targetPorts[i].AsrsCtl.StackDevice.Db2Vals[1] < 3) || (targetPorts[i].AsrsCtl.StackDevice.Db2Vals[0] > 0))) if ((targetPorts[i].PalletBuffer.Count() == 0) && (targetPorts[i].Db2Vals[0] < 2))//入口缓存数据为空,并且入口处无板(光眼信号判断)。 { int cellEmptCounts = 0; if (!this.asrsResManage.GetHouseAreaLeftGs(targetPorts[i].AsrsCtl.HouseName, storeAreaZone, ref cellEmptCounts, reStr)) { continue; } if (cellEmptCounts <= 0) { continue; } re = (Int16)(i + 1);//this.db1ValsToSnd[0] = // targetPorts[i].PushPalletID(this.rfidUID); switchStat = true; break; } } } if (!switchStat) { re = 3;// this.db1ValsToSnd[0] = 3; //this.currentTaskDescribe = "等待分流"; //break; } } return(re); }