private bool Switch4002(string palletID, ref Int16 switchRe, ref string reStr) { try { switchRe = 0; int step = 0; string desc = ""; if (!MesAcc.GetStep(palletID, out step, ref reStr)) { return(false); } if (step < 3) { switchRe = 2; desc = "满筐进加压化成或空筐回流进注液"; } else { switchRe = 3; desc = "满筐进二封"; } string logStr = string.Format("{0}分流结果:{1},{2}", palletID, switchRe, desc); logRecorder.AddDebugLog(nodeName, logStr); AddProduceRecord(this.rfidUID, logStr); return(true); } catch (Exception ex) { reStr = ex.ToString(); return(false); } }
///// <summary> ///// db1 条码赋值 ///// </summary> ///// <param name="barcode"></param> ///// <param name="db1StIndex">db1地址块索引起始,从0开始编号</param> //protected void BarcodeFillDB1(string barcode,int db1StIndex) //{ // byte[] barcodeBytes = System.Text.UTF8Encoding.Default.GetBytes(barcode); // for (int i = 0; i < barcodeBytes.Count(); i++) // { // db1ValsToSnd[db1StIndex + i] = barcodeBytes[i]; // } //} ///// <summary> ///// 分析工位状态 ///// </summary> ///// <param name="reStr"></param> ///// <returns></returns> //protected virtual bool NodeStatParse(ref string reStr) //{ // return true; //} #endregion #region MES接口的再封装 /// <summary> /// 查询绑定数据 /// </summary> /// <param name="palletID"></param> /// <returns></returns> protected bool MESGetProductsInPallet(string palletID, ref List <MesDBAccess.Model.ProductOnlineModel> batteryList, ref string reStr) { batteryList = new List <MesDBAccess.Model.ProductOnlineModel>(); VMResultCells re = MesAcc.GetTrayBindingCell(palletID); if (re.ResultCode != 0) { reStr = "查询MES托盘电芯数据错误" + re.ResultMsg; return(false); } JObject jsonCellObj = (JObject)JsonConvert.DeserializeObject(re.Cells); if (jsonCellObj == null) { return(true); } for (int i = 0; i < 36; i++) { int channel = i + 1; string channelKey = "Cell" + channel.ToString(); if (jsonCellObj[channelKey] == null) { continue; } MesDBAccess.Model.ProductOnlineModel battery = new MesDBAccess.Model.ProductOnlineModel(); battery.palletID = palletID; battery.palletBinded = true; battery.tag1 = channel.ToString(); battery.productID = jsonCellObj[channelKey].ToString().ToUpper(); batteryList.Add(battery); } return(true); }
///// <summary> ///// db1 条码赋值 ///// </summary> ///// <param name="barcode"></param> ///// <param name="db1StIndex">db1地址块索引起始,从0开始编号</param> //protected void BarcodeFillDB1(string barcode,int db1StIndex) //{ // byte[] barcodeBytes = System.Text.UTF8Encoding.Default.GetBytes(barcode); // for (int i = 0; i < barcodeBytes.Count(); i++) // { // db1ValsToSnd[db1StIndex + i] = barcodeBytes[i]; // } //} ///// <summary> ///// 分析工位状态 ///// </summary> ///// <param name="reStr"></param> ///// <returns></returns> //protected virtual bool NodeStatParse(ref string reStr) //{ // return true; //} #endregion #region MES接口的再封装 /// <summary> /// 查询绑定数据 /// </summary> /// <param name="palletID"></param> /// <returns></returns> protected bool MESGetProductsInPallet(string palletID, ref List <MesDBAccess.Model.ProductOnlineModel> batteryList, ref string reStr) { batteryList = new List <MesDBAccess.Model.ProductOnlineModel>(); string strJsonCells = ""; bool re = MesAcc.GetTrayBindingCell(palletID, out strJsonCells, ref reStr); if (!re) { reStr = "查询MES托盘电芯数据错误" + reStr; return(false); } JObject jsonCellObj = (JObject)JsonConvert.DeserializeObject(strJsonCells); if (jsonCellObj == null) { return(true); } for (int i = 0; i < SysCfg.SysCfgModel.TrayChannelMax; i++) { int channel = i + 1; string channelKey = "Cell" + channel.ToString(); if (jsonCellObj[channelKey] == null) { continue; } MesDBAccess.Model.ProductOnlineModel battery = new MesDBAccess.Model.ProductOnlineModel(); battery.palletID = palletID; battery.palletBinded = true; battery.productID = jsonCellObj[channelKey].ToString().ToUpper(); batteryList.Add(battery); } return(true); }
private bool Switch4007(string palletID, ref Int16 switchRe, ref string reStr) { try { switchRe = 0; switchRe = 0; int step = 0; if (!MesAcc.GetStep(palletID, out step, ref reStr)) { return(false); } string desc = ""; if (step <= 8) { switchRe = 2; desc = "分流去OCV1"; } else { switchRe = 3; desc = "分流去OCV2"; } string logStr = string.Format("{0} {1}分流结果:{2},{3}", this.nodeName, this.rfidUID, switchRe, desc); logRecorder.AddDebugLog(nodeName, logStr); AddProduceRecord(palletID, logStr); return(true); } catch (Exception ex) { reStr = ex.ToString(); return(false); } }
public override int PathValidWeight(string palletID, ref string reStr) { int step = 0; int weight = 0; if (!MesAcc.GetStep(palletID, out step, ref reStr)) { return(-1); } if (palletBuffer.Count() > 0) { weight = 100000; } /* * string batchName=""; * if(this.palletBuffer.Count()>0) * { * string curPalletID=this.palletBuffer[0]; * MesDBAccess.BLL.palletBll palletDBAcc = new MesDBAccess.BLL.palletBll(); * MesDBAccess.Model.palletModel palletM = palletDBAcc.GetModel(curPalletID); * string curBatch=""; * if(MesAcc.GetTrayCellLotNO(curPalletID,out curBatch,ref reStr)) * { * if(MesAcc.GetTrayCellLotNO(palletID,out batchName,ref reStr)) * { * if(curBatch == batchName) * { * weight=100000; * } * } * } * } */ string storeAreaZone = "注液高温区"; storeAreaZone = asrsCtlModel.GetAreaToCheckin(palletID, step);//(AsrsModel.EnumLogicArea)Enum.Parse(typeof(AsrsModel.EnumLogicArea), SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(step)); //AsrsModel.EnumLogicArea.注液高温区; //此处需要根据步号判断 int cellEmptCounts = 0; if (!asrsCtlModel.AsrsResManage.GetHouseAreaLeftGs(asrsCtlModel.HouseName, storeAreaZone.ToString(), ref cellEmptCounts, reStr)) { reStr = string.Format("查询{0}库房,{1}剩余货位失败,{2}", asrsCtlModel.HouseName, storeAreaZone.ToString(), reStr); return(-1); } weight += cellEmptCounts; return(weight); }
public override bool IsPathOpened(string palletID, ref string reStr) { if (!base.IsPathOpened(palletID, ref reStr)) { return(false); } if (db2Vals[0] != 0) { reStr = "设备故障:故障码:" + db2Vals[0].ToString(); return(false); } if (db2Vals[1] == 3) { reStr = "堆垛机处于故障状态"; return(false); } if (db2Vals[1] == 4) { reStr = "堆垛机处于非联机状态"; return(false); } int step = 0; if (!MesAcc.GetStep(palletID, out step, ref reStr)) { reStr = "获取工步失败:" + reStr; return(false); } string storeAreaZone = "注液高温区"; storeAreaZone = this.asrsCtlModel.GetAreaToCheckin(palletID, step);//(AsrsModel.EnumLogicArea)Enum.Parse(typeof(AsrsModel.EnumLogicArea), SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(step)); //AsrsModel.EnumLogicArea.注液高温区; //此处需要根据步号判断 int cellEmptCounts = 0; if (!asrsCtlModel.AsrsResManage.GetHouseAreaLeftGs(asrsCtlModel.HouseName, storeAreaZone.ToString(), ref cellEmptCounts, reStr)) { reStr = string.Format("查询{0}库房,{1}剩余货位失败,{1}", asrsCtlModel.HouseName, storeAreaZone.ToString(), reStr); return(false); } if (cellEmptCounts <= 0) { reStr = "可用货位为0"; return(false); } return(true); }
private bool Process4010(string palletID, ref Int16 re, ref string reStr) { if (palletID.Length < 12) { reStr = string.Format("{0}条码长度不足", palletID); if (this.db1ValsToSnd[1] != 1) { logRecorder.AddDebugLog(nodeName, reStr); } currentTaskDescribe = reStr; this.db1ValsToSnd[1] = 1; return(false); } string strRe = MesAcc.ParsePalletID(palletID); if (string.IsNullOrWhiteSpace(strRe)) { reStr = string.Format("{0}筐码解析失败,电芯型号未配置", palletID); if (this.db1ValsToSnd[1] != 2) { logRecorder.AddDebugLog(nodeName, reStr); } currentTaskDescribe = reStr; this.db1ValsToSnd[1] = 2; return(false); } JObject parseObj = JsonConvert.DeserializeObject(strRe) as JObject; short palletCata = 0; if ((parseObj == null) || (parseObj["料筐内衬类型"] == null) || (!short.TryParse(parseObj["料筐内衬PLC值"].ToString(), out palletCata))) { reStr = string.Format("{0}筐码解析失败,电芯内衬型号未配置", palletID); if (this.db1ValsToSnd[1] != 2) { logRecorder.AddDebugLog(nodeName, reStr); } this.db1ValsToSnd[1] = 2; return(false); } re = (short)(1 + palletCata); return(true); }
private bool Process4012(string palletID, ref Int16 re, ref string reStr) { //1 先解绑 int step = 0; if (!MesAcc.GetStep(this.rfidUID, out step, ref reStr)) { currentTaskDescribe = "查询MES工步失败:" + reStr; return(false); } step = 0; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; return(false); } //2 再分流 return(Process4010(palletID, ref re, ref reStr)); }
private bool Switch4003() { string reStr = ""; if (!MesAcc.UpdateStep(1, this.rfidUID, ref reStr)) { Console.WriteLine("{0} 更新步号错误,{1}", nodeName, reStr); return(false); } int switchRe = 0; FlowPathModel switchPath = FindFirstValidPath(this.rfidUID, ref reStr); if (switchPath == null) { switchRe = this.flowPathList.Count() + 2; //无可用路径,等待 this.db1ValsToSnd[0] = 3; return(false); } else { //string strCata = this.rfidUID.Substring(10, 1).ToUpper(); string strCataName = "正极材料"; if (!RecordPalletInfo(this.rfidUID, ref strCataName, ref reStr)) { return(false); } switchRe = switchPath.PathSeq + 1; CtlNodeBaseModel node = switchPath.NodeList[0]; if (node.GetType().ToString() == "AsrsControl.AsrsPortalModel") { (node as AsrsControl.AsrsPortalModel).PushPalletID(this.rfidUID); } this.db1ValsToSnd[0] = (short)switchRe; logRecorder.AddDebugLog(nodeName, string.Format("{0}分流,进入{1}", this.rfidUID, switchPath.NodeList[0].NodeName)); return(true); } }
/// <summary> /// 化成后修改工步为3 /// </summary> private bool Process4008(string palletID, ref Int16 re, ref string reStr) { try { re = 0; int updateStep = 3; if (!MesAcc.UpdateStep(updateStep, palletID, ref reStr)) { return(false); } re = 2; string logStr = string.Format("{0},{1}更新工步{2}", this.nodeName, palletID, updateStep); logRecorder.AddDebugLog(nodeName, logStr); AddProduceRecord(palletID, logStr); return(true); } catch (Exception ex) { reStr = ex.ToString(); return(false); } }
private bool MESBatteryFill(int fillSeq, string palletID, List <string> batteryList, ref string reStr) { try { ANCStepResult stepRe = MesAcc.GetStep(palletID); if (stepRe.ResultCode != 0) { reStr = stepRe.ResultMsg; return(false); } int channelMax = 36; JObject jsonObj = new JObject(new JProperty("Type", "One"), new JProperty("TrayNO", palletID)); if (fillSeq > 1) { jsonObj["Type"] = "Two"; } for (int i = 0; i < Math.Min(channelMax, batteryList.Count()); i++) { jsonObj.Add("Cell" + (i + 1).ToString(), batteryList[i]); } VMResult re = MesAcc.UploadTrayCellInfo(jsonObj.ToString()); if (re.ResultCode != 0) { reStr = re.ResultMsg; return(false); } else { return(true); } } catch (Exception ex) { reStr = ex.ToString(); return(false); } }
public override bool ExeBusiness(ref string reStr) { if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (db2Vals[0] == 1) { currentTaskPhase = 0; Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); rfidUID = string.Empty; currentTaskDescribe = "等待新的任务"; //return true; } //if(db1ValsToSnd[0] >1) //分流完成后 //{ // return true; //} if (db2Vals[0] == 2) { if (currentTaskPhase == 0) { currentTaskPhase = 1; } } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始读RFID"; this.rfidUID = ""; if (SysCfg.SysCfgModel.UnbindMode) { this.rfidUID = System.Guid.NewGuid().ToString(); } else { if (SysCfg.SysCfgModel.SimMode || SysCfg.SysCfgModel.RfidSimMode) { this.rfidUID = this.SimRfidUID; } else { this.rfidUID = this.barcodeRW.ReadBarcode(); } } if (string.IsNullOrWhiteSpace(this.rfidUID)) { if (this.db1ValsToSnd[0] != barcodeFailedStat) { logRecorder.AddDebugLog(nodeName, "读料框条码失败"); } this.db1ValsToSnd[0] = barcodeFailedStat; break; } this.rfidUID = this.rfidUID.Trim(new char[] { '\0', '\r', '\n', '\t', ' ' }); string palletPattern = @"^[a-z|A-Z|0-9]{4}TP[0-9]{4,}"; if (!Regex.IsMatch(this.rfidUID, palletPattern)) { if (this.db1ValsToSnd[0] != barcodeFailedStat) { logRecorder.AddDebugLog(nodeName, "读料框条码不符合规则," + this.rfidUID); this.currentTaskDescribe = "读料框条码不符合规则," + this.rfidUID; } this.db1ValsToSnd[0] = barcodeFailedStat; break; } /* * //检测是否跟库里有重码 * string[] houseNames = new string[] { AsrsModel.EnumStoreHouse.A1库房.ToString(), AsrsModel.EnumStoreHouse.A2库房.ToString(), * AsrsModel.EnumStoreHouse.B1库房.ToString(), AsrsModel.EnumStoreHouse.C1库房.ToString(),AsrsModel.EnumStoreHouse.C2库房.ToString(),AsrsModel.EnumStoreHouse.C3库房.ToString() }; * foreach (string houseName in houseNames) * { * string cellIn = AsrsResManage.IsProductCodeInStore(houseName, this.rfidUID, ref reStr); * if (!string.IsNullOrWhiteSpace(cellIn)) * { * if (this.db1ValsToSnd[0] != 3) * { * currentTaskDescribe = string.Format("条码异常,条码{0}已经在库房{1},库位{2}", this.rfidUID.Length.ToString(), houseName, cellIn); * logRecorder.AddDebugLog(nodeName, currentTaskDescribe); * } * this.db1ValsToSnd[0] = 3; * return true; * } * }*/ logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID); this.currentTaskPhase++; break; } case 2: { //分流 currentTaskDescribe = "等待分流"; int switchRe = 0; int step = 0; if (!MesAcc.GetStep(this.rfidUID, out step, ref reStr)) { currentTaskDescribe = "查询MES工步失败:" + reStr; break; } if (this.nodeID == "4001") { if (step == 0) { currentTaskDescribe = string.Format("{0} 入库分流失败,步号为0,禁止入库", this.rfidUID); if (this.db1ValsToSnd[0] != 4) { logRecorder.AddDebugLog(nodeName, string.Format("{0} 入库分流失败,步号为0,禁止入库", this.rfidUID)); } this.db1ValsToSnd[0] = 4; // break; } } if (this.nodeID == "4004") { step = 5; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } } if (this.nodeID == "4005") { step = 6; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } } if (this.nodeID == "4006") { if (step > 0) { if (step >= 11) { step = 0; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } } else if (step != 10) { step = 10; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } } } } FlowPathModel switchPath = FindFirstValidPath(this.rfidUID, ref reStr); if (switchPath == null) { switchRe = 0; //无可用路径,等待 this.db1ValsToSnd[0] = (short)switchRe; this.currentTaskDescribe = reStr; break; } else { CtlNodeBaseModel node = switchPath.NodeList[0]; if (this.nodeID == "4004") { AsrsControl.AsrsPortalModel port = (node as AsrsControl.AsrsPortalModel); if (port == null) { break; } AsrsModel.CellCoordModel requireCell = null; AsrsControl.AsrsCtlModel asrsCtl = port.AsrsCtl; AsrsInterface.IAsrsManageToCtl asrsResManage = port.AsrsCtl.AsrsResManage; string logicArea = "通用分区"; if (dlgtGetLogicArea != null) { logicArea = dlgtGetLogicArea(this.rfidUID, asrsCtl, step); } if (string.IsNullOrWhiteSpace(logicArea)) { this.currentTaskDescribe = string.Format("{0} 检索货区失败,未配置", this.rfidUID); break; } // AsrsModel.EnumLogicArea logicArea = (AsrsModel.EnumLogicArea)Enum.Parse(typeof(AsrsModel.EnumLogicArea), SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(step)); if (!asrsResManage.CellRequire(asrsCtl.HouseName, logicArea, ref requireCell, ref reStr)) { Console.WriteLine("{0}申请库位失败,{1}", nodeName, reStr); break; } if (requireCell.Row == 1) { switchRe = 2; asrsCtl.SetAsrsCheckinRow(requireCell.Row); } else if (requireCell.Row == 2) { switchRe = 3; asrsCtl.SetAsrsCheckinRow(requireCell.Row); } else { break; } logRecorder.AddDebugLog(nodeName, string.Format("{0}锁定分容库位第{1}排", this.rfidUID, requireCell.Row)); } else { switchRe = switchPath.PathSeq + 1; } this.db1ValsToSnd[0] = (short)switchRe; /* * if(this.nodeID=="4006") //OCV后入库分流时,把条码后4位以整形发给PLC * { * this.db1ValsToSnd[1] = short.Parse(this.rfidUID.Substring(this.rfidUID.Length - 4, 4)); * }*/ if (node.GetType().ToString() == "AsrsControl.AsrsPortalModel") { (node as AsrsControl.AsrsPortalModel).PushPalletID(this.rfidUID); } string logStr = string.Format("{0}分流,进入{1}", this.rfidUID, switchPath.NodeList[0].NodeName); logRecorder.AddDebugLog(nodeName, logStr); AddProduceRecord(this.rfidUID, logStr); if (this.nodeID == "4001") { if (step >= 4) { step = 0; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } } } } this.currentTaskPhase++; break; } case 3: { currentTaskDescribe = "分流完成"; break; } default: break; } return(true); }
public override bool IsPathOpened(string palletID, ref string reStr) { try { if (!base.IsPathOpened(palletID, ref reStr)) { return(false); } lock (portBufLock) { int palletStep = 0; if (!MesAcc.GetStep(palletID, out palletStep, ref reStr)) { return(false); } if (palletStep == 0) { //判断第一个料框是否空筐 if (!EmptyPalletInputEnabled) { reStr = "系统已配置禁止空筐入库"; return(false); } } //先判断入口实际信号 bool portCrowd = true; for (int i = 0; i < PortinBufCapacity; i++) { if (db2Vals[i] == 1) { portCrowd = false; break; } } if (portCrowd) //入口拥堵 { return(false); } //再判断数据 if (this.palletBuffer.Count() >= PortinBufCapacity) { reStr = "缓存已满"; return(false); } if (dlgtGroupEnabled != null) { return(dlgtGroupEnabled(this, palletID, ref reStr)); } else { if (PortinBufCapacity > 1) //只有入口最大允许缓存数量大于1时才考虑库区,批次 { if (this.palletBuffer.Count() > 0) { //1 判断是否同一个库区 string lastPalletID = this.palletBuffer[0]; int lastStep = 0; if (!MesAcc.GetStep(lastPalletID, out lastStep, ref reStr)) { return(false); } int step = 0; if (!MesAcc.GetStep(palletID, out step, ref reStr)) { return(false); } string areaLast = asrsCtlModel.GetAreaToCheckin(lastPalletID, lastStep).ToString(); // AsrsModel.EnumLogicArea.注液高温区.ToString(); // areaLast=SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(lastStep); string areaCur = asrsCtlModel.GetAreaToCheckin(palletID, step).ToString(); //AsrsModel.EnumLogicArea.注液高温区.ToString(); ; // areaCur=SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(step); if (areaLast != areaCur) { reStr = string.Format("托盘{0}待进入的立库分区{1},跟当前缓存托盘待进入的分区{2}不同", palletID, areaCur, areaLast); return(false); } //2 是否同批 string batchLast = ""; string batch = ""; if (!MesAcc.GetTrayCellLotNO(palletID, out batch, ref reStr)) { return(false); } if (!MesAcc.GetTrayCellLotNO(lastPalletID, out batchLast, ref reStr)) { return(false); } if (batchLast == batch) { return(true); } else { reStr = string.Format("托盘{0} 批次{1},与入口缓存的托盘{2} 批次{3}不同", palletID, batch, lastPalletID, batchLast); return(false); } } } } return(true); } } catch (Exception ex) { reStr = ex.ToString(); return(false); } }
public override bool ExeBusiness(ref string reStr) { //Console.WriteLine("TES P1"); if (!nodeEnabled) { return(true); } if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } if (db2Vals[0] != 2) { db1ValsToSnd[1] = 1; } //任务撤销 if (db2Vals[1] == 3 && db1ValsToSnd[0] != 3) { if (this.currentTask != null && this.currentTaskPhase > 0) { this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString(); this.currentTask.FinishTime = System.DateTime.Now; ctlTaskBll.Update(this.currentTask); logRecorder.AddDebugLog(this.nodeName, string.Format("装载任务{0}撤销,托盘号:{1}", this.currentTask.TaskID, this.rfidUID)); currentTaskDescribe = "装载任务撤销"; this.currentTask = null; this.currentTaskPhase = 0; } Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); db1ValsToSnd[0] = 3;// return(true); } if (db1ValsToSnd[0] == 3 && db2Vals[1] == 1) { //任务撤销命令复位,应答也复位 db1ValsToSnd[0] = 1; } if (!FillTaskRequire(ref reStr)) { return(false); } // Console.WriteLine("TES P2"); //if(this.currentTask == null) //{ // return true; //} switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始执行装载任务"; this.db1ValsToSnd[1] = 2; //如果是一次装载,判断是否第一步 if (this.nodeID == "3001") { //如果是第1步,则上传MES步次,直接放行。通知PLC不用扫条码 ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); if (stepRe.ResultCode != 0) { this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; break; } if (SysCfg.SysCfgModel.ZhuyeMode == 1) //一步模式 { #region 一步模式 this.db1ValsToSnd[2] = 2; logRecorder.AddDebugLog(nodeName, string.Format("一次注液一步模式下,托盘{0}当前步次{1},等待装载 ", this.rfidUID, stepRe.Step)); #endregion } else if (SysCfg.SysCfgModel.ZhuyeMode == 2) //两步模式 { #region 两步模式 if (stepRe.Step < 3) { this.currentTaskDescribe = string.Format("{0}一次注液第1步,将跳过装载", this.rfidUID); int updateStep = 2; logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}当前步次{1},完成一次注液第1步后过站,不装载 ", this.rfidUID, stepRe.Step)); VMResult re = MesAcc.UpdateStep(updateStep, this.rfidUID); if (re.ResultCode != 0) { this.currentTaskDescribe = "更新MES步次失败," + re.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx ,11-16 } this.db1ValsToSnd[2] = 1; this.db1ValsToSnd[0] = 2; this.currentTaskPhase = 3; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } else if (stepRe.Step == 3) { this.db1ValsToSnd[2] = 2; logRecorder.AddDebugLog(nodeName, string.Format("一次注液两步模式下,托盘{0}当前步次{1},完成一次注液第2步后装载 ", this.rfidUID, stepRe.Step)); } else { if (this.db1ValsToSnd[2] != 3) { logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}步次错误,当前步次:{1} ", this.rfidUID, stepRe.Step)); } this.db1ValsToSnd[2] = 3; break; } #endregion } else { if (this.db1ValsToSnd[2] != 3) { logRecorder.AddDebugLog(nodeName, string.Format("一次注液模式错误,实际为{0}", SysCfg.SysCfgModel.ZhuyeMode)); } this.db1ValsToSnd[2] = 3; break; } } this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { if (this.db1ValsToSnd[0] == 4) { //装载错误状态 break; } //等待扫码完成 currentTaskDescribe = "RFID读取完成,等待电池条码数据"; if (db2Vals[1] != 2) { break; } if (SysCfg.SysCfgModel.SimMode) { //生成模拟数据 GenerateSimBatterys(); } //取电池条码数据 List <string> batteryList = new List <string>(); int validBatNum = 0; for (int i = 0; i < PalletCapacity; i++) { List <byte> batteryBytes = new List <byte>(); for (int j = 0; j < 20; j++) { int indexSt = 2 + i * 20 + j; batteryBytes.Add((byte)(this.db2Vals[indexSt] & 0xff)); batteryBytes.Add((byte)((this.db2Vals[indexSt] >> 8) & 0xff)); } //字节流转换成字符串 string batteryID = System.Text.ASCIIEncoding.UTF8.GetString(batteryBytes.ToArray()); batteryID = batteryID.Trim(new char[] { '\0', '\r', '\n', '\t', ' ' }).ToUpper(); if (batteryID.Contains("ERROR")) { batteryID = ""; } if (batteryID.Length > 22) { validBatNum++; if (batteryID.Length < 35 && batteryID.Substring(16, 6).ToUpper() == "17K03C") { batteryID = batteryID.Insert(22, "1"); } } batteryList.Add(batteryID); } if (validBatNum < 1) { if (this.db1ValsToSnd[0] != 5) { logRecorder.AddDebugLog(nodeName, string.Format("{0}电池数据为空", rfidUID)); } this.db1ValsToSnd[0] = 5; break; } #region 调用MES接口上传绑定数据,更新步次 int fillSeq = 1; if (this.nodeID == "3002") { fillSeq = 2; } logRecorder.AddDebugLog(nodeName, string.Format("{0}开始上传MES", rfidUID)); if (!MESBatteryFill(fillSeq, rfidUID, batteryList, ref reStr)) { logRecorder.AddDebugLog(nodeName, string.Format(" {0}MES装载错误:{1}", rfidUID, reStr)); this.db1ValsToSnd[0] = 4; //装载错误 currentTaskDescribe = string.Format(" 装载错误{0}", reStr); logRecorder.AddDebugLog(nodeName, currentTaskDescribe); break; //zwx,11-16 } else { logRecorder.AddDebugLog(nodeName, string.Format("{0}MES装载成功", rfidUID)); } ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); if (stepRe.ResultCode != 0) { this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx,11-16 } int updateStep = 0; if (this.nodeID == "3001") { updateStep = 4; } else { updateStep = 8; } VMResult re = MesAcc.UpdateStep(updateStep, this.rfidUID); if (re.ResultCode != 0) { this.currentTaskDescribe = "更新MES步次失败," + re.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx ,11-16 } #endregion //自动装载都是1次装载 #region 杭可 //string sndStr = ""; //if (!hkAccess.BatteryFill(0, this.rfidUID, batteryList, ref sndStr, ref reStr)) //{ // logRecorder.AddDebugLog(nodeName, string.Format(" 装载错误:{0},发送数据:{1}", reStr, sndStr)); // this.db1ValsToSnd[0] = 4;//装载错误 // currentTaskDescribe = string.Format(" 装载错误{0}", reStr); // break; //} #endregion #region 本地数据装载 for (int i = 0; i < batteryList.Count(); i++) { string batteryID = batteryList[i]; if (string.IsNullOrWhiteSpace(batteryID) || (batteryID.Length < 23)) { continue; } MesDBAccess.Model.ProductOnlineModel productModel = null; if (productOnlineBll.Exists(batteryID)) { productModel = productOnlineBll.GetModel(batteryID); productModel.productID = batteryID; productModel.palletID = this.rfidUID; productModel.modifyTime = System.DateTime.Now; productModel.processStepID = this.mesProcessStepID[0].ToString(); productModel.productCata = SysCfg.EnumProductCata.电芯.ToString(); productModel.palletBinded = true; productModel.stationID = this.nodeID; productModel.checkResult = "0"; if (batteryID.Length > 22) { productModel.batchName = batteryID.Substring(16, 6); } int seq = i + 1; productModel.tag1 = seq.ToString(); int rowIndex = i / 12 + 1; productModel.tag2 = rowIndex.ToString(); int colIndex = i - (rowIndex - 1) * 12 + 1; productModel.tag3 = colIndex.ToString(); productModel.tag5 = "0"; if (!productOnlineBll.Update(productModel)) { return(false); } } else { productModel = new MesDBAccess.Model.ProductOnlineModel(); productModel.onlineTime = System.DateTime.Now; productModel.modifyTime = System.DateTime.Now; productModel.productID = batteryID; productModel.palletID = this.rfidUID; productModel.processStepID = this.mesProcessStepID[0].ToString(); productModel.productCata = SysCfg.EnumProductCata.电芯.ToString(); productModel.palletBinded = true; productModel.stationID = this.nodeID; productModel.checkResult = "0"; productModel.tag5 = "0"; if (batteryID.Length > 22) { productModel.batchName = batteryID.Substring(16, 6); } int seq = i + 1; productModel.tag1 = seq.ToString(); int rowIndex = i / 12 + 1; productModel.tag2 = rowIndex.ToString(); int colIndex = i - (rowIndex - 1) * 12 + 1; productModel.tag3 = colIndex.ToString(); if (!productOnlineBll.Add(productModel)) { return(false); } } } #endregion logRecorder.AddDebugLog(nodeName, string.Format(" 装载成功{0},更新MES工步:{1}", rfidUID, updateStep)); AddProduceRecord(this.rfidUID, string.Format("装载:{0},更新MES步次{1}", nodeName, updateStep)); this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.db1ValsToSnd[0] = 2; break; } case 3: { currentTaskDescribe = "托盘跟电池条码数据绑定完成,等待扫码完成信号复位"; if (this.db2Vals[1] != 1) { break; } DevCmdReset(); this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString(); this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; currentTaskPhase = 0; currentTaskDescribe = "等待执行下一个任务"; //等待扫码完成 break; } default: break; } //Console.WriteLine("TES P3"); return(true); }
private void AsrsCheckinRequire() { //foreach(AsrsControl.AsrsPortalModel port in targetPorts) for (int i = 0; i < targetPorts.Count(); i++) { AsrsControl.AsrsPortalModel port = targetPorts[i]; if (port.AsrsCtl.StackDevice.Db2Vals[0] > 0 || port.AsrsCtl.StackDevice.Db2Vals[1] > 2) { continue; } if (port.PalletBuffer.Count() < 1) { continue; } bool checkInRequire = false; if (port.PalletBuffer.Count() >= port.PortinBufCapacity) { checkInRequire = true; } else { if (db1ValsToSnd[0] == 3 && port.Db2Vals[0] == 2) { checkInRequire = true; } } for (int j = 0; j < Math.Min(port.PalletBuffer.Count(), port.PortinBufCapacity); j++) { if (port.Db2Vals[j] != 2) { checkInRequire = false; break; } } if (port.Db2Vals[2] == 2) //手动入库按钮请求 { checkInRequire = true; } if (!checkInRequire) { continue; } string palletID = port.PalletBuffer[0]; #region 查询本地应该进入哪个分区 /* * string nextProcessID = port.AsrsCtl.GetNextStepID(palletID); * int nextProcessSeq = SysCfg.SysCfgModel.stepSeqs.IndexOf(nextProcessID); * int curSeq = SysCfg.SysCfgModel.stepSeqs.IndexOf(port.AsrsCtl.MesProcessStepID[0]); * AsrsModel.EnumLogicArea logicArea = AsrsModel.EnumLogicArea.冷却区; * if (nextProcessSeq > curSeq) * { * logicArea = AsrsModel.EnumLogicArea.常温区; * }*/ #endregion #region 查询MES应该进入哪个库区 //在MES中查询入口处的第一个托盘当前工步,判断应该进入哪个库区 ANCStepResult stepRe = MesAcc.GetStep(palletID); if (stepRe.ResultCode != 0) { port.CurrentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; continue; } AsrsModel.EnumLogicArea logicArea = AsrsModel.EnumLogicArea.冷却区; if (stepRe.Step < 12) { logicArea = AsrsModel.EnumLogicArea.冷却区; } else { logicArea = AsrsModel.EnumLogicArea.常温区; } #endregion string reStr = ""; SysCfg.EnumAsrsTaskType taskType = SysCfg.EnumAsrsTaskType.产品入库; if (port.AsrsCtl.AsrsCheckinTaskRequire(port, logicArea, taskType, port.PalletBuffer.ToArray(), ref reStr)) { //port.PalletBuffer.Clear(); if (!port.ClearBufPallets(ref reStr)) { logRecorder.AddDebugLog(port.NodeName, "清理入口缓存数据失败" + reStr); } } else { string logStr = string.Format("{0}申请失败,因为:{1}", taskType.ToString(), reStr); logRecorder.AddDebugLog(port.NodeName, logStr); } } }
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); }
public override bool ExeBusiness(ref string reStr) { if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (db2Vals[0] == 1) { currentTaskPhase = 0; Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); rfidUID = string.Empty; currentTaskDescribe = "等待新的任务"; //return true; } //if(db1ValsToSnd[0] >1) //分流完成后 //{ // return true; //} if (db2Vals[0] == 2) { if (currentTaskPhase == 0) { currentTaskPhase = 1; } } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始读RFID"; this.rfidUID = ""; if (SysCfg.SysCfgModel.UnbindMode) { this.rfidUID = System.Guid.NewGuid().ToString(); } else { if (SysCfg.SysCfgModel.SimMode || SysCfg.SysCfgModel.RfidSimMode) { this.rfidUID = this.SimRfidUID; } else { this.rfidUID = this.barcodeRW.ReadBarcode(); } } if (string.IsNullOrWhiteSpace(this.rfidUID)) { if (this.db1ValsToSnd[0] != barcodeFailedStat) { logRecorder.AddDebugLog(nodeName, "读料框条码失败"); } this.db1ValsToSnd[0] = barcodeFailedStat; break; } /* * //检测是否跟库里有重码 * string[] houseNames = new string[] { AsrsModel.EnumStoreHouse.A1库房.ToString(), AsrsModel.EnumStoreHouse.A2库房.ToString(), * AsrsModel.EnumStoreHouse.B1库房.ToString(), AsrsModel.EnumStoreHouse.C1库房.ToString(),AsrsModel.EnumStoreHouse.C2库房.ToString(),AsrsModel.EnumStoreHouse.C3库房.ToString() }; * foreach (string houseName in houseNames) * { * string cellIn = AsrsResManage.IsProductCodeInStore(houseName, this.rfidUID, ref reStr); * if (!string.IsNullOrWhiteSpace(cellIn)) * { * if (this.db1ValsToSnd[0] != 3) * { * currentTaskDescribe = string.Format("条码异常,条码{0}已经在库房{1},库位{2}", this.rfidUID.Length.ToString(), houseName, cellIn); * logRecorder.AddDebugLog(nodeName, currentTaskDescribe); * } * this.db1ValsToSnd[0] = 3; * return true; * } * }*/ logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID); this.currentTaskPhase++; break; } case 2: { //分流 currentTaskDescribe = "等待分流"; int switchRe = 0; int step = 0; if (!MesAcc.GetStep(this.rfidUID, out step, ref reStr)) { currentTaskDescribe = "查询MES工步失败:" + reStr; break; } if (this.nodeID == "4001") { step = 14; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } } else if (this.nodeID == "4002") { step = 0; if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } } FlowPathModel switchPath = FindFirstValidPath(this.rfidUID, ref reStr); if (switchPath == null) { switchRe = 0; //无可用路径,等待 this.db1ValsToSnd[0] = (short)switchRe; break; } else { CtlNodeBaseModel node = switchPath.NodeList[0]; switchRe = switchPath.PathSeq + 1; if (node.GetType().ToString() == "AsrsControl.AsrsPortalModel") { (node as AsrsControl.AsrsPortalModel).PushPalletID(this.rfidUID); } this.db1ValsToSnd[0] = (short)switchRe; string logStr = string.Format("{0}分流,进入{1}", this.rfidUID, switchPath.NodeList[0].NodeName); logRecorder.AddDebugLog(nodeName, logStr); AddProduceRecord(this.rfidUID, logStr); } this.currentTaskPhase++; break; } case 3: { currentTaskDescribe = "分流完成"; break; } default: break; } return(true); }
/// <summary> /// 分拣任务申请 /// </summary> private bool GraspTaskRequire(ref string reStr) { //if (db2Vals[0] == 1) //{ // currentTaskPhase = 0; // db1ValsToSnd[0] = 1; // rfidUID = string.Empty; // currentTaskDescribe = "等待新的任务"; // return; //} if (db2Vals[0] == 2 && db1ValsToSnd[1] != 2) { if (this.currentTask != null) { return(true); } //if (ExistUnCompletedTask((int)SysCfg.EnumAsrsTaskType.OCV测试分拣)) //{ // return true; //} //先读RFID卡 currentTaskDescribe = "开始读RFID"; this.rfidUID = ""; if (SysCfg.SysCfgModel.SimMode || SysCfg.SysCfgModel.RfidSimMode) { this.rfidUID = this.SimRfidUID; } else { if (this.barcodeRW != null) { this.rfidUID = this.barcodeRW.ReadBarcode(); } else { this.rfidUID = rfidRW.ReadStrData();// rfidRW.ReadUID(); } } if (string.IsNullOrWhiteSpace(this.rfidUID)) { if (this.db1ValsToSnd[0] != 3) { logRecorder.AddDebugLog(nodeName, "读RFID失败"); this.currentTaskDescribe = "读RFID失败"; } this.db1ValsToSnd[0] = 3; return(true); } this.rfidUID = this.rfidUID.Trim(new char[] { '\0', '\r', '\n', '\t', ' ' }); string palletPatten = @"^[a-z|A-Z|0-9]{4}TP[0-9]{4,}"; if (!System.Text.RegularExpressions.Regex.IsMatch(this.rfidUID, palletPatten)) { if (this.db1ValsToSnd[1] != 3) { logRecorder.AddDebugLog(nodeName, "读料框ID错误,含有非法字符 !" + this.rfidUID); } this.db1ValsToSnd[1] = 3; return(true); } //if (this.rfidUID.Length < 9) //{ // if (this.db1ValsToSnd[0] != 3) // { // logRecorder.AddDebugLog(nodeName, "读料框RFID错误,长度不足9字符!"); // } // this.db1ValsToSnd[0] = 3; // return true; //} //if (this.rfidUID.Length > 9) //{ // this.rfidUID = this.rfidUID.Substring(0, 9); //} if (db1ValsToSnd[0] == 1 || db1ValsToSnd[0] == 3) { logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID); this.currentTaskDescribe = "读到托盘号:" + this.rfidUID; } if (this.nodeID == "6002") //ocv1分拣处判断步号,如果大于10,报错 { int step = 0; if (!MesAcc.GetStep(this.rfidUID, out step, ref reStr)) { currentTaskDescribe = "查询MES工步失败:" + reStr; return(false); } if (step > 10) { if (db1ValsToSnd[0] != 5) { logRecorder.AddDebugLog(nodeName, string.Format("{0}步号错误,当前步号:{1},当前工位不能超过10,请检查是否使用了OCV2测试后的料筐", rfidUID, step)); } this.currentTaskDescribe = string.Format("{0}步号错误,当前步号:{1},当前工位不能超过10,请检查是否使用了OCV2测试后的料筐", rfidUID, step); db1ValsToSnd[0] = 5; reStr = this.currentTaskDescribe; return(false); } } /* * List<MesDBAccess.Model.ProductOnlineModel> bindedProducts = productOnlineBll.GetProductsInPallet(this.rfidUID); * if(bindedProducts == null || bindedProducts.Count()<1) * { * this.db1ValsToSnd[0] = 4; * this.currentTaskDescribe = string.Format("{0}无绑定数据",this.rfidUID); * return true; * }*/ //生成新任务 this.currentTaskPhase = 1; ControlTaskModel task = new ControlTaskModel(); task.DeviceID = this.nodeID; task.CreateMode = "自动"; task.CreateTime = System.DateTime.Now; task.TaskID = System.Guid.NewGuid().ToString("N"); task.TaskStatus = SysCfg.EnumTaskStatus.待执行.ToString(); task.TaskType = (int)SysCfg.EnumAsrsTaskType.分拣; task.TaskParam = this.rfidUID; task.TaskPhase = this.currentTaskPhase; task.TaskStatus = SysCfg.EnumTaskStatus.执行中.ToString(); this.ctlTaskBll.Add(task); this.currentTask = task; currentTaskDescribe = "分拣任务生成"; return(true); } if (db2Vals[0] == 1 && this.currentTask == null) { this.db1ValsToSnd[0] = 1; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!nodeEnabled) { return(true); } if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } if (db2Vals[0] != 2) { db1ValsToSnd[0] = 1; } //任务撤销 if (db2Vals[1] == 3 && db1ValsToSnd[1] != 3) { if (this.currentTask != null && this.currentTaskPhase > 0) { this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString(); this.currentTask.FinishTime = System.DateTime.Now; ctlTaskBll.Update(this.currentTask); logRecorder.AddDebugLog(this.nodeName, string.Format("分拣任务{0}撤销,托盘号:{1}", this.currentTask.TaskID, this.rfidUID)); currentTaskDescribe = "分拣任务撤销,等待任务撤销信号复位"; this.currentTask = null; this.currentTaskPhase = 0; } Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); db1ValsToSnd[1] = 3;// return(true); } if (db1ValsToSnd[1] == 3 && db2Vals[1] != 2) { //任务撤销命令复位,应答也复位 db1ValsToSnd[1] = 1; } if (!GraspTaskRequire(ref reStr)) { return(false); } if (this.currentTask == null) { return(true); } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始执行分拣任务"; if (SysCfg.SysCfgModel.SimMode || SysCfg.SysCfgModel.RfidSimMode) { this.rfidUID = this.SimRfidUID; } else { this.rfidUID = this.barcodeRW.ReadBarcode(); } if (string.IsNullOrWhiteSpace(this.rfidUID)) { if (this.db1ValsToSnd[0] != 3) { logRecorder.AddDebugLog(nodeName, "读料框条码失败"); } this.db1ValsToSnd[0] = 3; break; } // int ocvProcessID = 1;//zwx,临时 this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { //查询MES 不良电芯数据 //写入PLC db1ValsToSnd[0] = 2; currentTaskDescribe = "分拣参数发送完成"; this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 3: { //等待任务完成 currentTaskDescribe = "等待分拣完成"; if (this.db2Vals[1] != 2 && this.db2Vals[1] != 4) { break; } //更新MES步号 int stepUp = 0; if (this.nodeID == "6001") { stepUp = 7; } else if (this.nodeID == "6002") { stepUp = 10; } else { stepUp = 13; } if (!MesAcc.UpdateStep(stepUp, this.rfidUID, ref reStr)) { currentTaskDescribe = "更新MES工步失败:" + reStr; break; } db1ValsToSnd[1] = 2; string grasp = ""; AddProduceRecord(this.rfidUID, string.Format("正常分拣:{0}", nodeName)); logRecorder.AddDebugLog(nodeName, string.Format("{0},分拣完成,{1}", this.rfidUID, grasp)); this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 4: { currentTaskDescribe = "分拣流程完成,等待分拣完成信号复位"; if (this.db2Vals[1] != 1) { break; } DevCmdReset(); this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString(); this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; currentTaskPhase = 0; currentTaskDescribe = "等待执行下一个任务"; break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (this.nodeID == "4001") { if (this.db2Vals[1] != SysCfg.SysCfgModel.ZhuyeMode) { logRecorder.AddDebugLog(nodeName, string.Format("一次注液模式切换到{0}步模式", this.db2Vals[1])); } SysCfg.SysCfgModel.ZhuyeMode = this.db2Vals[1]; } if (this.nodeID == "4001" || this.nodeID == "4002") { barcodeFailedStat = 4; } else { barcodeFailedStat = 3; } if (db2Vals[0] == 1) { currentTaskPhase = 0; DevCmdReset(); db1ValsToSnd[0] = 0; rfidUID = string.Empty; currentTaskDescribe = "等待新的任务"; return(true); } if (db2Vals[0] == 2) { if (currentTaskPhase == 0) { currentTaskPhase = 1; } } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始读RFID"; this.rfidUID = ""; if (SysCfg.SysCfgModel.SimMode || SysCfg.SysCfgModel.RfidSimMode) { this.rfidUID = this.SimRfidUID; } else { if (this.barcodeRW != null) { this.rfidUID = this.barcodeRW.ReadBarcode(); } else { this.rfidUID = rfidRW.ReadStrData(); // rfidRW.ReadUID(); } } if (string.IsNullOrWhiteSpace(this.rfidUID)) { if (this.db1ValsToSnd[0] != barcodeFailedStat) { logRecorder.AddDebugLog(nodeName, "读RFID失败"); } this.db1ValsToSnd[0] = barcodeFailedStat; currentTaskDescribe = "读RFID失败"; break; } this.rfidUID = this.rfidUID.Trim(new char[] { '\0', '\r', '\n', '\t', ' ' }); string pattern = @"^[a-zA-Z0-9]*$"; //匹配所有字符都在字母和数字之间 if (!System.Text.RegularExpressions.Regex.IsMatch(this.rfidUID, pattern)) { if (this.db1ValsToSnd[0] != barcodeFailedStat) { logRecorder.AddDebugLog(nodeName, "读料框ID错误,含有非法字符 !" + this.rfidUID); } this.db1ValsToSnd[0] = barcodeFailedStat; return(true); } if (this.rfidUID.Length < 9) { if (this.db1ValsToSnd[0] != barcodeFailedStat) { logRecorder.AddDebugLog(nodeName, "读料框RFID错误,长度不足9字符!"); } this.db1ValsToSnd[0] = barcodeFailedStat; break; } if (this.rfidUID.Length > 9) { this.rfidUID = this.rfidUID.Substring(0, 9); } logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID); currentTaskDescribe = "开始执行分流"; string logStr = ""; ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); if (stepRe.ResultCode != 0) { this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; break; } int palletStat = MESPalletStat(this.rfidUID, ref reStr); if (this.nodeID == "4001") { if (stepRe.Step == 0) { this.db1ValsToSnd[0] = 1; logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}分流:空筐", this.rfidUID)); } else if (stepRe.Step >= 4) { this.db1ValsToSnd[0] = 3; logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}分流,MES工步:{1},已经完成一次注液第二步", this.rfidUID, stepRe.Step)); } else { this.db1ValsToSnd[0] = 2; logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}分流,MES工步:{1},已经完成一次注液第一步", this.rfidUID, stepRe.Step)); } } #region 二次注液前分流点 else if (this.nodeID == "4002") { if (palletStat == 0) { this.db1ValsToSnd[0] = 1; logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}分流:空筐", this.rfidUID)); } else { if (!MesAcc.UnbindTrayCell(this.rfidUID)) { this.db1ValsToSnd[0] = 3; logStr = string.Format("托盘{0}MES解绑失败", this.rfidUID); logRecorder.AddDebugLog(nodeName, logStr); } else { this.db1ValsToSnd[0] = 2; logStr = string.Format("托盘{0}分流:满筐,调用MES解绑成功", this.rfidUID); logRecorder.AddDebugLog(nodeName, logStr); } /* * if(stepRe.Step<6) * { * this.db1ValsToSnd[0] = 3; * logStr = string.Format("托盘{0}工序流程错误,化成未完成,MES工步{1}", this.rfidUID,stepRe.Step); * logRecorder.AddDebugLog(nodeName, logStr); * } * else * { * //调用MES接口解绑 * if (!MesAcc.UnbindTrayCell(this.rfidUID)) * { * this.db1ValsToSnd[0] = 3; * logStr = string.Format("托盘{0}MES解绑失败", this.rfidUID); * logRecorder.AddDebugLog(nodeName, logStr); * } * else * { * this.db1ValsToSnd[0] = 2; * logStr = string.Format("托盘{0}MES解绑成功", this.rfidUID); * logRecorder.AddDebugLog(nodeName, string.Format("托盘{0}分流:满筐", this.rfidUID)); * } * * * }*/ } } #endregion else { if (stepRe.Step < 20) { currentTaskDescribe = "OCV2"; this.db1ValsToSnd[0] = 1; //OCV2 logStr = string.Format("{0},MES工步:{1},分流信息:OCV2分拣后料框", this.rfidUID, stepRe.Step); logRecorder.AddDebugLog(nodeName, logStr); } else { currentTaskDescribe = "OCV4"; this.db1ValsToSnd[0] = 2; //OCV4 logStr = string.Format("{0},MES工步:{1},分流信息:OCV4分拣后料框", this.rfidUID, stepRe.Step); logRecorder.AddDebugLog(nodeName, logStr); } #region 本地工艺流程查询 /* * string curMesProcessID = this.productOnlineBll.GetProcessIDOfPallet(this.rfidUID); * if (string.IsNullOrWhiteSpace(curMesProcessID)) * { * currentTaskDescribe = "OCV2"; * this.db1ValsToSnd[0] = 1; //OCV2 * logStr = "分流信息:OCV2分拣后料框"; * } * else * { * int curSeq = SysCfg.SysCfgModel.stepSeqs.IndexOf(curMesProcessID); * int ocv2Seq = SysCfg.SysCfgModel.stepSeqs.IndexOf("PS-70"); * if (curSeq <= ocv2Seq) * { * currentTaskDescribe = "OCV2"; * this.db1ValsToSnd[0] = 1; //OCV2 * logStr = "分流信息:OCV2分拣后料框"; * } * else * { * currentTaskDescribe = "OCV4"; * this.db1ValsToSnd[0] = 2; //OCV4 * logStr = "分流信息:OCV4分拣后料框"; * } * }*/ #endregion } this.currentTaskPhase++; break; } case 2: { currentTaskDescribe = "流程完成"; break; } } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!nodeEnabled) { return(true); } if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } if (db2Vals[0] != 2) { db1ValsToSnd[0] = 1; } //任务撤销 if (db2Vals[1] == 3 && db1ValsToSnd[1] != 3) { if (this.currentTask != null && this.currentTaskPhase > 0) { this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString(); this.currentTask.FinishTime = System.DateTime.Now; ctlTaskBll.Update(this.currentTask); logRecorder.AddDebugLog(this.nodeName, string.Format("分拣任务{0}撤销,托盘号:{1}", this.currentTask.TaskID, this.rfidUID)); currentTaskDescribe = "分拣任务撤销,等待任务撤销信号复位"; this.currentTask = null; this.currentTaskPhase = 0; } Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); db1ValsToSnd[1] = 3;// return(true); } if (db1ValsToSnd[1] == 3 && db2Vals[1] != 2) { //任务撤销命令复位,应答也复位 db1ValsToSnd[1] = 1; } if (!GraspTaskRequire(ref reStr)) { return(false); } if (this.currentTask == null) { return(true); } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始执行分拣任务"; // int ocvProcessID = 1;//zwx,临时 List <int> ocvTestSeqIDS = new List <int>(); int testValStIndex = 2; ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); if (stepRe.ResultCode != 0) { this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; break; } if (this.nodeID == "6002") { //查询MES,当前步次,是OCV2还是OCV4分拣 testValStIndex = 3; if (stepRe.Step < 19) { this.db1ValsToSnd[2] = 1; //OCV2 } else { this.db1ValsToSnd[2] = 2; //OCV4 } #region 判断本地工艺步号 /* * * testValStIndex = 3; * string curMesProcessID = this.productOnlineBll.GetProcessIDOfPallet(this.rfidUID); * if (string.IsNullOrWhiteSpace(curMesProcessID)) * { * * this.db1ValsToSnd[2] = 1; //OCV2 * } * else * { * int curSeq = SysCfg.SysCfgModel.stepSeqs.IndexOf(curMesProcessID); * int ocv2Seq = SysCfg.SysCfgModel.stepSeqs.IndexOf("PS-70"); * if (curSeq <= ocv2Seq) * { * * this.db1ValsToSnd[2] = 1; //OCV2 * } * else * { * * this.db1ValsToSnd[2] = 2; //OCV4 * } * }*/ #endregion } #region 从杭可查询检测数据 /* * if (this.nodeID == "6001") * { * //检测OCV1数据 * ocvTestSeqIDS.Add(1); * } * else if (this.nodeID == "6002") * { * if(this.db1ValsToSnd[2] ==1) * { * ocvTestSeqIDS.Add(2); //检测OCV2数据 * } * else * { * ocvTestSeqIDS.Add(5);//检测OCV4数据 * } * } * else * { * //检测分容,OCV3数据 * ocvTestSeqIDS.Add(3); * ocvTestSeqIDS.Add(4); * } * //查询杭可测试结果 * vals = new List<int>(); * if(SysCfg.SysCfgModel.SimMode) * { * for(int i=0;i<36;i++) * { * vals.Add(1); * } * } * else * { * //List<int> ocvTestSeqIDS = new List<int>(); * * if (!ocvAccess.GetCheckResult(this.rfidUID, ocvTestSeqIDS, ref vals, ref reStr)) * { * if(db1ValsToSnd[0] != 4) * { * logRecorder.AddDebugLog(nodeName,string.Format("查询OCV测试结果失败,{0},{1}",this.rfidUID,reStr)); * } * db1ValsToSnd[0] = 4; * break; * } * } */ #endregion //查询MES分拣数据 vals = new List <int>(); if (SysCfg.SysCfgModel.SimMode) { for (int i = 0; i < 36; i++) { vals.Add(1); } } else { int step = 0; if (this.nodeID == "6001") { step = 9; } else if (this.nodeID == "6002") { if (stepRe.Step < 14) { step = 13; } else { step = 19; } } else { step = 16; } if (!MESGetGraspVals(step, this.rfidUID, ref vals, ref reStr)) { this.currentTaskDescribe = reStr; break; } } //发送分拣参数 for (int i = 0; i < Math.Max(channelSum, vals.Count()); i++) { Int16 re = (short)vals[i]; db1ValsToSnd[testValStIndex + i] = re; } db1ValsToSnd[0] = 2; AddGraspRecord(this.rfidUID, vals); //记录分拣发送详细 currentTaskDescribe = "分拣参数发送完成"; this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { //等待任务完成 currentTaskDescribe = "等待分拣完成"; if (this.db2Vals[1] != 2 && this.db2Vals[1] != 4) { break; } if (this.db2Vals[1] == 4) { AddProduceRecord(this.rfidUID, string.Format("无需分拣模式:{0}", nodeName)); logRecorder.AddDebugLog(nodeName, string.Format("由人工处理,{0}无需挑选放行", this.rfidUID)); } //if (db2Vals[1] == 2) //{ // ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); // if (stepRe.ResultCode != 0) // { // this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; // logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); // break; //zwx,11-16 // } //} UpdateOnlineProductInfo(this.rfidUID); this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 3: { //更新MES步号 ANCStepResult stepRe = MesAcc.GetStep(this.rfidUID); if (stepRe.ResultCode != 0) { this.currentTaskDescribe = "查询MES托盘步次失败:" + stepRe.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx,11-16 } int stepUp = 0; if (this.nodeID == "6001") { stepUp = 10; } else if (this.nodeID == "6002") { if (stepRe.Step <= 14) { stepUp = 14; } else { stepUp = 20; } } else { stepUp = 17; } VMResult re = MesAcc.UpdateStep(stepUp, this.rfidUID); if (re.ResultCode != 0) { this.currentTaskDescribe = "更新MES步号失败," + re.ResultMsg; logRecorder.AddDebugLog(nodeName, this.currentTaskDescribe); break; //zwx,11-16 } db1ValsToSnd[1] = 2; string grasp = ""; if (this.nodeID == "6002") { if (stepRe.Step < 20) { grasp = string.Format("OCV2 分拣完成,更新步次{0}", stepUp); } else { grasp = string.Format("OCV4 分拣完成,更新步次{0}", stepUp); } } else { grasp = string.Format("{0} 分拣完成,更新步次{1}", nodeName, stepUp); } AddProduceRecord(this.rfidUID, string.Format("正常分拣:{0}", grasp)); logRecorder.AddDebugLog(nodeName, string.Format("{0},分拣完成,{1}", this.rfidUID, grasp)); this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 4: { currentTaskDescribe = "分拣流程完成,等待分拣完成信号复位"; if (this.db2Vals[1] != 1) { break; } DevCmdReset(); this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString(); this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; currentTaskPhase = 0; currentTaskDescribe = "等待执行下一个任务"; break; } default: break; } return(true); }