public override bool ExeBusiness(ref string reStr) { // int nodeStatus = 0; //状态机,0:初始化状态,1:有板进入,2:插头就绪,开始检测,3:检测完成,报警或放行,4:空板进入,放行 if (!NodeStatParse(ref reStr)) { return(false); } if (!checkEnable) { return(true); } switch (currentTaskPhase) { case 1: { checkRetryCounter = 0; db1ValsToSnd[1] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 if (!SysCfgModel.SimMode) { rfidUID = rfidRW.ReadUID(); } else { rfidUID = SimRfidUID; } currentTaskDescribe = "开始读RFID"; if (!string.IsNullOrWhiteSpace(rfidUID)) { db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { db1ValsToSnd[0] = db1StatNG; //this.currentTaskPhase = 5; this.currentStat.StatDescribe = "未投产"; logRecorder.AddDebugLog(nodeName, "未投产,rfid:" + rfidUID); checkEnable = false; break; } //状态赋条码, this.currentStat.ProductBarcode = productBind.productBarcode; productBind.currentNode = this.nodeName; productBindBll.Update(productBind); BarcodeFillDB1(productBind.productBarcode, 2); int reDetectQuery = ReDetectQuery(productBind.productBarcode); if (0 == reDetectQuery) { db1ValsToSnd[0] = db1StatCheckOK; checkEnable = false; logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:OK", productBind.productBarcode)); break; } else if (1 == reDetectQuery) { db1ValsToSnd[0] = db1StatNG; checkEnable = false; logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:NG", productBind.productBarcode)); break; } //查询本地数据库,之前工位是否有不合格项,若有,下线 // if (LineMonitorPresenter.checkPreStation) { if (!PreDetectCheck(productBind.productBarcode)) { db1ValsToSnd[0] = db1StatNG; // logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 在前面工位有检测NG项", productBind.productBarcode)); checkEnable = false; break; } } if (!LossCheck(productBind.productBarcode, ref reStr)) { db1ValsToSnd[0] = db1StatNG; // logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 检测漏项,{1}", productBind.productBarcode, reStr)); checkEnable = false; break; } } else { if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.Status = EnumNodeStatus.无法识别; this.currentStat.StatDescribe = "读RFID卡失败"; break; } //插头就绪 currentTaskDescribe = "等待插头就绪"; if (db2Vals[1] == 1) { //开始检测 currentTaskDescribe = "开始发送启动气密仪命令"; if (!airDetectRW.StartDetect(ref reStr)) { //logRecorder.AddLog() ThrowErrorStat("启动气密检测仪失败" + reStr, EnumNodeStatus.设备故障); break; } this.currentStat.StatDescribe = "开始气密检测"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "开始检测"); currentTaskPhase++; detectStartTime = DateTime.Now; } break; } case 3: { //查询检测结果,检测完成或超时 currentTaskDescribe = "开始查询气密结果"; AirlossDetectModel detectRe = null; detectRe = airDetectRW.QueryResultData(ref reStr); if (detectRe != null) { // int checkRe = 0; //0合格,1:不合格 if (detectRe.DetectResult == "OK") { //db1ValsToSnd[0] = db1StatCheckOK; //所有数据都上传之后再给放行信号 checkRe = 0; } else { checkRe = 1; // db1ValsToSnd[0] = db1StatNG; //检测不合格,下线 OutputRecord(this.currentStat.ProductBarcode); } //先存到本地数据库 checkCode = ""; if (checkRe > 0) { checkCode = this.detectCode; } else { checkCode = ""; } currentTaskDescribe = "开始保存本地气密结果"; if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, checkCode, detectRe.DetectVal.ToString(), 0)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } currentTaskPhase++; } else { TimeSpan timeElapse = System.DateTime.Now - detectStartTime; if (timeElapse.TotalMilliseconds > detectTimeout) { detectStartTime = System.DateTime.Now; logRecorder.AddDebugLog(this.nodeName, string.Format("检测超时,{0}毫秒,重新检测", detectTimeout)); currentStat.StatDescribe = string.Format("检测超时,重新检测"); if (checkRetryCounter < 2) { airDetectRW.StartDetect(ref reStr); } checkRetryCounter++; } if (checkRetryCounter > 2) { currentTaskDescribe = "气密超时,开始保存本地气密结果"; checkRe = 1; //超时 if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, checkCode, "0", 0)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } db1ValsToSnd[0] = db1StatNG; logRecorder.AddDebugLog(this.nodeName, string.Format("检测超时,{0}毫秒", detectTimeout)); currentStat.StatDescribe = string.Format("检测超时,{0}毫秒", detectTimeout); currentTaskPhase++; break; } } break; } case 4: { string[] mesProcessSeq = new string[] { "RQ-Z8005", "RQ-Z8007" }; // string[] mesProcessSeq = new string[] {"MES投产位", "RQ-Z8005", "RQ-Z8007" }; //string[] mesProcessSeq = new string[] { this.mesNodeID}; currentTaskDescribe = "开始上传检测结果(气密2工位NG时才上传)"; if (this.nodeID == "2002") { //气密2,3要求合并,若当前为气密2,则检测NG时立即上传 if (1 == checkRe) { if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } } } else { if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } } string checkReStr = "OK"; currentTaskDescribe = "放行"; if (checkRe == 1) { db1ValsToSnd[0] = db1StatNG; checkReStr = "NG"; } else { db1ValsToSnd[0] = db1StatCheckOK; } logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "检测完成," + checkReStr); this.currentStat.StatDescribe = "气密检测完成," + checkReStr; checkFinished = true; currentTaskPhase++; break; } case 5: { //流程结束 this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程结束"; // this.currentTaskPhase++; break; } } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!base.ExeBusiness(ref reStr)) { return(false); } if (!NodeStatParse(ref reStr)) { return(false); } if (!checkEnable) { return(true); } switch (currentTaskPhase) { case 1: { db1ValsToSnd[1] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 if (string.IsNullOrWhiteSpace(rfidUID)) { if (SysCfgModel.SimMode) { rfidUID = SimRfidUID; } else { rfidUID = rfidRW.ReadUID(); } } currentTaskDescribe = "开始读RFID"; if (string.IsNullOrWhiteSpace(rfidUID)) { this.currentStat.StatDescribe = "读RFID卡失败"; currentTaskDescribe = this.currentStat.StatDescribe; if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; break; } this.currentTask.TaskPhase = this.currentTaskPhase; this.currentTask.TaskParam = rfidUID; this.ctlTaskBll.Update(this.currentTask); db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { if (db2Vals[0] == 1) //有产品 { if (!productChecked) { logRecorder.AddDebugLog(nodeName, "检测到有产品"); } productChecked = true; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { if (db1ValsToSnd[0] != 3) { logRecorder.AddDebugLog(nodeName, "未投产,rfid:" + rfidUID); } db1ValsToSnd[0] = 3; this.currentStat.StatDescribe = "未投产"; checkEnable = false; break; } this.currentStat.ProductBarcode = productBind.productBarcode; logRecorder.AddDebugLog(nodeName, "开始处理维修审核流程," + productBind.productBarcode); productBind.currentNode = this.nodeName; productBindBll.Update(productBind); BarcodeFillDB1(productBind.productBarcode, 2); if (!this.plNodeModel.checkRequired) { if (!ClearLoacalMesData(productBind.productBarcode)) { break; } this.db1ValsToSnd[0] = 1; currentTaskPhase = 4; break; } currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); } else if (db2Vals[0] == 2) //无产品 { if (productChecked) { logRecorder.AddDebugLog(nodeName, "产品离开工位"); } productChecked = false; OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind != null) { this.currentStat.ProductBarcode = productBind.productBarcode; ClearLoacalMesData(this.currentStat.ProductBarcode); //解绑 if (!TryUnbind(this.rfidUID, this.currentStat.ProductBarcode)) { logRecorder.AddDebugLog(nodeName, string.Format("无产品状态,解绑{0}失败", this.currentStat.ProductBarcode)); break; } else { logRecorder.AddDebugLog(nodeName, string.Format("无产品状态,解绑{0}完成", this.currentStat.ProductBarcode)); currentTaskPhase = 4; this.db1ValsToSnd[0] = 1; //放行 } } else { logRecorder.AddDebugLog(nodeName, string.Format("RFID:{0}未绑定状态,无需解绑放行", this.rfidUID)); currentTaskPhase = 4; this.db1ValsToSnd[0] = 1; //放行 //this.currentTask.TaskPhase = this.currentTaskPhase; //this.ctlTaskBll.Update(this.currentTask); break; } } else { //等待有板信号=1或2 break; } break; } case 3: { currentTaskDescribe = "开始查询MES维修审核是否完成"; int mesRe = 0; if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable) { // mesRe = mesDA.MesAssemDown(new string[] { this.currentStat.ProductBarcode, LineMonitorPresenter.mesLineID }, ref reStr); mesRe = mesDA.MesReAssemEnabled(new string[] { this.currentStat.ProductBarcode, PLProcessModel.SysCfgModel.mesLineID }, ref reStr); } if (mesRe == 0) { if (this.db1ValsToSnd[0] != 1) { logRecorder.AddDebugLog(nodeName, string.Format("{0}MES审核完成", this.currentStat.ProductBarcode)); } this.db1ValsToSnd[0] = 1; // logRecorder.AddDebugLog(nodeName, string.Format("MES离线模式,{0}无需审核,完成", this.currentStat.ProductBarcode)); } else { currentTaskDescribe = this.currentStat.ProductBarcode + ",维修审核未完成:" + reStr; if (this.db1ValsToSnd[0] != 4) { logRecorder.AddDebugLog(nodeName, currentTaskDescribe); } this.db1ValsToSnd[0] = 4; break; } ClearLoacalMesData(this.currentStat.ProductBarcode); logRecorder.AddDebugLog(nodeName, string.Format("{0}维修审核完成", this.currentStat.ProductBarcode)); currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 4: { this.db1ValsToSnd[0] = 1; currentTaskDescribe = "审核工位处理完成"; this.currentTask.TaskStatus = EnumTaskStatus.已完成.ToString(); this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } default: break; } return(true); }
// int tempCounter = 0; public override bool ExeBusiness(ref string reStr) { try { PLCRWMx plcRwObj = plcRW as PLCRWMx; // Console.WriteLine("A 产品上线 D3000={0}", PLCRWMx.db2Vals[0]); if (!NodeStatParse(ref reStr)) { return(false); } switch (this.currentTaskPhase) { //db1复位 //case 0: // { // db1ValsToSnd[0] = db1StatCheckNoneed; //空板进入,放行 // this.currentStat.Status = EnumNodeStatus.工位有板; // this.currentStat.ProductBarcode = ""; // this.currentStat.StatDescribe = "空板"; // break; // } case 1: { DevCmdReset(); rfidUID = string.Empty; this.currentStat.Status = EnumNodeStatus.设备空闲; // this.currentStat.ProductBarcode = "";// this.currentStat.StatDescribe = "设备空闲"; checkFinished = false; //Array.Clear(db1ValsToSnd, 0, db1ValsToSnd.Count()); currentTaskDescribe = "等待有板信号"; break; } case 2: { db1ValsToSnd[31] = 1; //流程锁定 //if (this.currentStat.Status == EnumNodeStatus.设备故障) //{ // break; //} this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //读条码,rfid,绑定 string rfidUID = ""; currentTaskDescribe = "开始读RFID"; DateTime dtSt = System.DateTime.Now; if (NodeFactory.SimMode) { rfidUID = this.SimRfidUID; } else { rfidUID = rfidRW.ReadUID(); } if (string.IsNullOrEmpty(rfidUID)) { DateTime dtEnd = DateTime.Now; if (!SysCfgModel.SimMode) { string recvStr = (rfidRW as SgrfidRW).GetRecvBufStr(); string logRfidStr = string.Format("读RFID失败,发送读卡命令:{0},接收判断时间:{1},接收数据:{2}", dtSt.ToString("HH:mm:ss"), dtEnd.ToString("HH:mm:ss"), recvStr); logRecorder.AddDebugLog(nodeName, logRfidStr); } db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.StatDescribe = "读RFID卡失败!"; break; } currentTaskDescribe = "开始读条码"; string barcode = barcodeRW.ReadBarcode().Trim(); if (string.IsNullOrWhiteSpace(barcode)) { db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.StatDescribe = "读条码失败!"; this.currentStat.ProductBarcode = "读条码失败!"; currentTaskDescribe = "读条码失败!"; break; } if (barcode.Length != 26) { db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.StatDescribe = "无效的条码,位数不足26位!"; this.currentStat.ProductBarcode = this.currentStat.StatDescribe; currentTaskDescribe = this.currentStat.StatDescribe; break; } string productTypeCode = barcode.Substring(0, 13); ProductSizeCfgModel cfg = productCfgBll.GetModel(productTypeCode); if (cfg == null) { db1ValsToSnd[0] = 32; currentTaskDescribe = string.Format("产品未配置,物料码{0}", productTypeCode); this.currentStat.StatDescribe = currentTaskDescribe; this.currentStat.Status = EnumNodeStatus.设备故障; checkEnable = false; break; } //db1赋条码 BarcodeFillDB1(barcode, 1); currentStat.ProductBarcode = barcode; // 若已经存在,则解绑 if (!TryUnbind(rfidUID, barcode)) { logRecorder.AddDebugLog(this.nodeName, "解绑错误"); currentTaskDescribe = "解绑错误"; break; } ClearLoacalMesData(barcode); //数据库绑定 if (onlineProductBll.Exists(barcode)) { logRecorder.AddDebugLog(nodeName, "已经存在:" + barcode + ",删除"); onlineProductBll.Delete(barcode); } OnlineProductsModel productBind = new OnlineProductsModel(); productBind.rfidCode = rfidUID; productBind.productBarcode = barcode; productBind.currentNode = this.nodeName; productBind.inputTime = System.DateTime.Now; onlineProductBll.Add(productBind); //OnlineProductsModel productBind = onlineProductBll.GetModel(barcode); //else //{ // productBind.rfidCode = rfidUID; // productBind.inputTime = System.DateTime.Now; // productBind.currentNode = this.nodeName; // onlineProductBll.Update(productBind); //} // Console.WriteLine("产品绑定,RFID UID:{0},整机条码:{1}", rfidUID, barcode); if (LineMonitorPresenter.DebugMode) { string logStr = string.Format("产品绑定,RFID UID:{0},整机条码:{1}", rfidUID, barcode); logRecorder.AddDebugLog(nodeName, logStr); logRecorder.AddDebugLog(nodeName, "产品上线,绑定完成"); } AddInputRecord(barcode); currentTaskDescribe = "产品绑定完成"; db1ValsToSnd[0] = db1StatCheckOK; checkFinished = true; this.currentTaskPhase++; break; } case 3: { //流程完成 this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程完成"; // DevCmdReset(); // this.currentTaskPhase = 1; break; } default: break; } // this.currentStat.StatDescribe = "流程步号:" + currentTaskPhase.ToString(); return(true); } catch (Exception ex) { ThrowErrorStat(ex.ToString(), EnumNodeStatus.设备故障); return(false); } }
public override bool ExeBusiness(ref string reStr) { if (!NodeStatParse(ref reStr)) { return(false); } if (!checkEnable) { return(true); } switch (currentTaskPhase) { //case 0: // { // db1ValsToSnd[0] = db1StatCheckNoneed; //空板进入,放行 // if (this.currentStat.Status != EnumNodeStatus.工位有板) // { // logRecorder.AddDebugLog(nodeName, "空板,放行"); // } // this.currentStat.Status = EnumNodeStatus.工位有板; // this.currentStat.ProductBarcode = ""; // this.currentStat.StatDescribe = "空板"; // break; // } case 1: { DevCmdReset(); rfidUID = string.Empty; this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备空闲"; checkFinished = false; currentTaskDescribe = "等待有板信号"; break; } case 2: { db1ValsToSnd[32] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } // this.db1ValsToSnd[0] = (short)(this.db1ValsToSnd[0] | 64); // this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 DateTime dtSt = System.DateTime.Now; if (!SimMode) { rfidUID = rfidRW.ReadUID(); } else { rfidUID = SimRfidUID; } currentTaskDescribe = "开始读RFID"; if (!string.IsNullOrWhiteSpace(rfidUID)) { db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { // if (this.nodeName == "二次试火") if (GetType().ToString() == "LineNodes.NodeFireTryingB") { db1ValsToSnd[0] |= db1StatNG; // } else { db1ValsToSnd[0] |= bindUnexist; } // this.currentTaskPhase = 4; this.currentStat.StatDescribe = "未投产"; logRecorder.AddDebugLog(nodeName, "未投产,rfid:" + rfidUID); checkEnable = false; break; } productBind.currentNode = this.nodeName; productBindBll.Update(productBind); BarcodeFillDB1(productBind.productBarcode, 2); int reDetectQuery = ReDetectQuery(productBind.productBarcode); if (0 == reDetectQuery) { db1ValsToSnd[0] = db1StatCheckOK; checkEnable = false; logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:OK", productBind.productBarcode)); break; } else if (1 == reDetectQuery) { db1ValsToSnd[0] = db1StatNG; checkEnable = false; logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:NG", productBind.productBarcode)); break; } //状态赋条码, this.currentStat.ProductBarcode = productBind.productBarcode; logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "开始检测"); //查询本地数据库,之前工位是否有不合格项,若有,下线 // if (LineMonitorPresenter.checkPreStation) { if (!PreDetectCheck(productBind.productBarcode)) { // if (this.nodeName == "二次试火") if (GetType().ToString() == "LineNodes.NodeFireTryingB") { db1ValsToSnd[0] |= db1StatNG; // } else { db1ValsToSnd[0] |= preCheckLoss; // } logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 在前面工位有检测NG项", productBind.productBarcode)); checkEnable = false; break; } } if (!LossCheck(productBind.productBarcode, ref reStr)) { // if (this.nodeName == "二次试火") if (GetType().ToString() == "LineNodes.NodeFireTryingB") { db1ValsToSnd[0] |= db1StatNG; // } else { db1ValsToSnd[0] |= preCheckLoss; // } logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 检测漏项,{1}", productBind.productBarcode, reStr)); checkEnable = false; break; } short gasSeq = 0; if (productBind.productBarcode.Trim().Length == 26) { //新物料,直接查询产品配置 string cataCode = productBind.productBarcode.Substring(0, 13); ProductSizeCfgModel m = productCfgBll.GetModel(cataCode); if (m == null) { this.ThrowErrorStat(productBind.productBarcode + "产品型号配置不存在", EnumNodeStatus.设备故障); //if (this.nodeName == "二次试火") if (GetType().ToString() == "LineNodes.NodeFireTryingB") { db1ValsToSnd[0] |= db1StatNG; // } else { db1ValsToSnd[0] |= gasCfgUnexist; } checkEnable = false; break; } GasConfigModel gasCfg = gasCfgBll.GetGascfgByName(m.gasName); if (gasCfg == null) { this.ThrowErrorStat(productBind.productBarcode + "气源配置不存在", EnumNodeStatus.设备故障); // if (this.nodeName == "二次试火") if (GetType().ToString() == "LineNodes.NodeFireTryingB") { db1ValsToSnd[0] |= db1StatNG; // } else { db1ValsToSnd[0] |= gasCfgUnexist; } checkEnable = false; break; } gasSeq = (short)gasCfg.gasSeq; } else { this.ThrowErrorStat(productBind.productBarcode + "无效的条码", EnumNodeStatus.设备故障); db1ValsToSnd[0] |= db1StatNG; // checkEnable = false; break; } db1ValsToSnd[1] = gasSeq; currentTaskPhase++; } else { if (!SysCfgModel.SimMode) { DateTime dtEnd = DateTime.Now; string recvStr = (rfidRW as SgrfidRW).GetRecvBufStr(); string logStr = string.Format("读RFID失败,发送读卡命令:{0},接收判断时间:{1},接收数据:{2}", dtSt.ToString("HH:mm:ss"), dtEnd.ToString("HH:mm:ss"), recvStr); logRecorder.AddDebugLog(nodeName, logStr); } if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.Status = EnumNodeStatus.无法识别; this.currentStat.StatDescribe = "读RFID卡失败"; break; } break; } case 3: { currentTaskDescribe = "等待检测结果"; if (db2Vals[1] == 0) { break; } int checkRe = 0; string detectCodes = ""; if (db2Vals[1] == 1) { checkRe = 0; //合格 //db1ValsToSnd[0] = db1StatCheckOK; } else { checkRe = 1; for (int i = 0; i < 16; i++) { int codeIndex = i + 1; DetectCodeDefModel m = detectCodeDefbll.GetModel(this.processName, codeIndex); if (m != null) { if ((db2Vals[2] & (1 << i)) > 0) { detectCodes += (m.detectCode + ","); } } } if (string.IsNullOrEmpty(detectCodes)) { break; } else { if (detectCodes[detectCodes.Count() - 1] == ',') { detectCodes = detectCodes.Remove(detectCodes.Count() - 1, 1); } //不合格 // db1ValsToSnd[0] = db1StatNG; logRecorder.AddDebugLog(this.nodeName, "故障码:" + detectCodes); } //检测不合格,下线 OutputRecord(this.currentStat.ProductBarcode); } currentTaskDescribe = "开始保存结果到本地"; if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, detectCodes, "", 0)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } currentTaskDescribe = "开始上传结果到MES"; string[] mesProcessSeq = new string[] { "RQ-ZA230", "RQ-ZA240", "RQ-ZA220", "RQ-ZA250", "RQ-ZA251", "RQ-ZA252", "RQ-ZA254", "RQ-ZA260" }; // string[] mesProcessSeq = new string[] { this.mesNodeID }; if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } this.currentStat.StatDescribe = "一次试火检测完成"; string checkReStr = "OK"; currentTaskDescribe = "放行"; if (0 == checkRe) { db1ValsToSnd[0] = db1StatCheckOK; } else { db1ValsToSnd[0] = db1StatNG; checkReStr = "NG"; } logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "检测完成," + checkReStr); checkFinished = true; currentTaskPhase++; break; } case 4: { //流程结束 currentTaskDescribe = "流程结束"; this.currentStat.StatDescribe = "流程完成"; // DevCmdReset(); this.currentTaskPhase++; break; } case 5: { this.currentTaskPhase++; break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { MessLossCheck(); if (!NodeStatParse(ref reStr)) { return(false); } ////临时测试 //if (PLProcessModel.SysCfgModel.PrienterEnable) //{ // string testBarcode = System.Guid.NewGuid().ToString(); // SendPrinterinfo(testBarcode);//异步发送 //} ////临时 if (!checkEnable) { return(true); } switch (currentTaskPhase) { //case 0: // { // db1ValsToSnd[0] = db1StatCheckNoneed; //空板进入,放行 // if (this.currentStat.Status != EnumNodeStatus.工位有板) // { // logRecorder.AddDebugLog(nodeName, "空板,放行"); // } // this.currentStat.Status = EnumNodeStatus.工位有板; // this.currentStat.ProductBarcode = ""; // this.currentStat.StatDescribe = "空板"; // rfidTimeCounterBegin = false; // break; // } case 1: { DevCmdReset(); rfidUID = string.Empty; this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备空闲"; checkRe = 0; checkFinished = false; currentTaskDescribe = "等待有板信号"; rfidTimeCounterBegin = false; break; } case 2: { db1ValsToSnd[31] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 DateTime dtSt = System.DateTime.Now; if (!SimMode) { rfidUID = rfidRW.ReadUID(); } else { rfidUID = SimRfidUID; } currentTaskDescribe = "开始读RFID"; if (!string.IsNullOrWhiteSpace(rfidUID)) { db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { db1ValsToSnd[0] = db1StatNG; // this.currentTaskPhase = 5; this.currentStat.StatDescribe = "未投产"; logRecorder.AddDebugLog(nodeName, "未投产,rfid:" + rfidUID); checkEnable = false; break; } productBind.currentNode = this.nodeName; productBindBll.Update(productBind); BarcodeFillDB1(productBind.productBarcode, 1); int reDetectQuery = ReDetectQuery(productBind.productBarcode); if (0 == reDetectQuery) { db1ValsToSnd[0] = db1StatCheckOK; checkEnable = false; logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:OK", productBind.productBarcode)); break; } else if (1 == reDetectQuery) { db1ValsToSnd[0] = db1StatNG; checkEnable = false; logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:NG", productBind.productBarcode)); break; } //reDetectQuery=2,无记录,继续后面的流程 //状态赋条码, this.currentStat.ProductBarcode = productBind.productBarcode; logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "开始检测"); //查询本地数据库,之前工位是否有不合格项,若有,下线 if (!PreDetectCheck(productBind.productBarcode)) { db1ValsToSnd[0] = 32; // logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 在前面工位有检测NG项", productBind.productBarcode)); checkEnable = false; break; } if (!LossCheck(productBind.productBarcode, ref reStr)) { db1ValsToSnd[0] = 32; // logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 检测漏项,{1}", productBind.productBarcode, reStr)); checkEnable = false; break; } currentTaskPhase++; } else { if (!SysCfgModel.SimMode) { DateTime dtEnd = DateTime.Now; string recvStr = (rfidRW as SgrfidRW).GetRecvBufStr(); string logStr = string.Format("读RFID失败,发送读卡命令:{0},接收判断时间:{1},接收数据:{2}", dtSt.ToString("HH:mm:ss"), dtEnd.ToString("HH:mm:ss"), recvStr); logRecorder.AddDebugLog(nodeName, logStr); } if (!rfidTimeCounterBegin) { //logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); rfidFailSt = System.DateTime.Now; } rfidTimeCounterBegin = true; TimeSpan ts = System.DateTime.Now - rfidFailSt; if (ts.TotalSeconds > SysCfgModel.RfidDelayTimeout) { if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; } this.currentStat.Status = EnumNodeStatus.无法识别; this.currentStat.StatDescribe = "读RFID卡失败"; break; } break; } case 3: { currentTaskDescribe = "等待检测结果"; if (db2Vals[1] == 0) { break; } string detectCodes = ""; if (db2Vals[1] == 1) { //合格 checkRe = 0; } else { checkRe = 1; for (int i = 0; i < 16; i++) { int codeIndex = i + 1; DetectCodeDefModel m = detectCodeDefbll.GetModel(this.processName, codeIndex); if (m != null) { if ((db2Vals[2] & (1 << i)) > 0) { detectCodes += (m.detectCode + ","); } } } if (string.IsNullOrEmpty(detectCodes)) { break; } else { if (detectCodes[detectCodes.Count() - 1] == ',') { detectCodes = detectCodes.Remove(detectCodes.Count() - 1, 1); } //不合格 logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + ",故障码:" + detectCodes); OutputRecord(this.currentStat.ProductBarcode); // break; } } currentTaskDescribe = "开始保存结果到本地"; if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, detectCodes, "", 0)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } string[] mesProcessSeq = new string[] { "RQ-ZA230", "RQ-ZA240", "RQ-ZA220", "RQ-ZA250", "RQ-ZA251", "RQ-ZA252", "RQ-ZA254", "RQ-ZA260", "RQ-ZA270" }; // string[] mesProcessSeq = new string[] { this.mesNodeID }; currentTaskDescribe = "开始上传结果到MES"; if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } currentTaskPhase++; break; } case 4: { currentTaskDescribe = "放行"; this.currentStat.StatDescribe = "外观检测完成"; string checkreStr = "OK"; if (checkRe == 1) { checkreStr = "NG"; db1ValsToSnd[0] = db1StatNG; } else { db1ValsToSnd[0] = db1StatCheckOK; //允许下线 db1ValsToSnd[32] = 3; //两个放行信号 if (PLProcessModel.SysCfgModel.PrienterEnable) { SendPrinterinfo(this.currentStat.ProductBarcode); //异步发送 } } logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "检测完成," + checkreStr); this.currentStat.StatDescribe = "下线"; checkFinished = true; currentTaskPhase++; break; } case 5: { this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程结束"; //DevCmdReset(); //checkFinished = true; break; } default: break; } return(true); }
// int tempCounter = 0; public override bool ExeBusiness(ref string reStr) { try { if (!base.ExeBusiness(ref reStr)) { return(false); } if (!NodeStatParse(ref reStr)) { return(false); } if (!checkEnable) { return(true); } if (this.currentTask == null) { return(true); } switch (this.currentTaskPhase) { case 1: { db1ValsToSnd[1] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //读条码,rfid,绑定 currentTaskDescribe = "开始读RFID"; DateTime dtSt = System.DateTime.Now; if (string.IsNullOrWhiteSpace(rfidUID)) { if (SysCfgModel.SimMode) { rfidUID = this.SimRfidUID; } else { rfidUID = rfidRW.ReadUID(); } } if (string.IsNullOrEmpty(rfidUID)) { DateTime dtEnd = DateTime.Now; string recvStr = (rfidRW as SgrfidRW).GetRecvBufStr(); string logStr = string.Format("读RFID失败,发送读卡命令:{0},接收判断时间:{1},接收数据:{2}", dtSt.ToString("HH:mm:ss"), dtEnd.ToString("HH:mm:ss"), recvStr); logRecorder.AddDebugLog(nodeName, logStr); if (!rfidTimeCounterBegin) { //logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); rfidFailSt = System.DateTime.Now; } rfidTimeCounterBegin = true; TimeSpan ts = System.DateTime.Now - rfidFailSt; if (ts.TotalSeconds > 5) { if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; } this.currentStat.StatDescribe = "读RFID卡失败!"; break; } else { rfidTimeCounterBegin = false; } this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.currentTask.TaskParam = rfidUID; this.barcodeRW.ClearBarcodesBuf(); //清空条码枪缓存 this.ctlTaskBll.Update(this.currentTask); break; } case 2: { currentTaskDescribe = "开始读条码"; string barcode = barcodeRW.ReadBarcode().Trim(); if (string.IsNullOrWhiteSpace(barcode) || barcode.Length != 26) { if (!rfidTimeCounterBegin) { //logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); rfidFailSt = System.DateTime.Now; } rfidTimeCounterBegin = true; TimeSpan ts = System.DateTime.Now - rfidFailSt; if (ts.TotalSeconds > 5) { if (db1ValsToSnd[0] != 3) { logRecorder.AddDebugLog(nodeName, "读条码失败:" + barcode); } db1ValsToSnd[0] = 3; if (!string.IsNullOrWhiteSpace(barcode)) { this.currentStat.StatDescribe = "无效的条码,位数不足26位!"; this.currentStat.ProductBarcode = this.currentStat.StatDescribe; currentTaskDescribe = this.currentStat.StatDescribe; } else { this.currentStat.StatDescribe = "读条码失败!"; this.currentStat.ProductBarcode = "读条码失败!"; currentTaskDescribe = "读条码失败!"; } } break; } //db1赋条码 BarcodeFillDB1(barcode, 2); currentStat.ProductBarcode = barcode; ProductSizeCfgBll productCfg = new ProductSizeCfgBll(); string cataCode = barcode.Substring(0, 13); ProductSizeCfgModel cfgModel = productCfg.GetModel(cataCode); if (cfgModel == null) { if (this.db1ValsToSnd[0] != 4) { // ThrowErrorStat(string.Format("{0}产品配置信息不存在", this.currentStat.ProductBarcode), EnumNodeStatus.设备故障); logRecorder.AddDebugLog(nodeName, string.Format("{0}产品配置信息不存在", this.currentStat.ProductBarcode)); } this.currentStat.StatDescribe = "配置不存在"; // checkEnable = false; this.db1ValsToSnd[0] = 4; break; //return true; } // 若已经存在,则解绑 if (!TryUnbind(rfidUID, barcode)) { string strLog = string.Format("解绑错误,RFID:{0},主机条码:{1}", rfidUID, barcode); logRecorder.AddDebugLog(this.nodeName, strLog); currentTaskDescribe = strLog; break; } ClearLoacalMesData(barcode); //数据库绑定 if (onlineProductBll.Exists(barcode)) { logRecorder.AddDebugLog(nodeName, "已经存在:" + barcode + ",删除"); onlineProductBll.Delete(barcode); } OnlineProductsModel productBind = new OnlineProductsModel(); productBind.rfidCode = rfidUID; productBind.productBarcode = barcode; productBind.currentNode = this.nodeName; productBind.inputTime = System.DateTime.Now; onlineProductBll.Add(productBind); string logStr = string.Format("产品绑定完成,RFID UID:{0},整机条码:{1}", rfidUID, barcode); logRecorder.AddDebugLog(nodeName, logStr); //先存本地,再MES投产 if (SysCfgModel.MesAutodownEnabled) { if (!MesDatalocalSave(barcode, 0, "", "", 0)) { return(false); } } AddInputRecord(barcode); currentTaskDescribe = "产品绑定完成,等待MES投产"; this.currentTaskPhase++; this.currentTask.TaskParam = this.rfidUID + "," + barcode; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 3: { //MES投产 if (SysCfgModel.MesAutodownEnabled) { if (!UploadMesdata(true, this.currentStat.ProductBarcode, new string[] { this.mesNodeID }, ref reStr)) { this.currentStat.StatDescribe = "MES投产失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } currentTaskDescribe = "MES投产完成"; } this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); db1ValsToSnd[0] = db1StatCheckOK; break; } case 4: { //流程完成 this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程完成"; this.currentTask.TaskStatus = EnumTaskStatus.已完成.ToString(); this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; break; } default: break; } // this.currentStat.StatDescribe = "流程步号:" + currentTaskPhase.ToString(); return(true); } catch (Exception ex) { ThrowErrorStat(ex.ToString(), EnumNodeStatus.设备故障); return(false); } }
public override bool ExeBusiness(ref string reStr) { if (!NodeStatParse(ref reStr)) { return(false); } switch (currentTaskPhase) { case 0: { db1ValsToSnd[0] = db1StatCheckNoneed; //空板进入,放行 this.currentStat.Status = EnumNodeStatus.工位有板; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "空板"; break; } case 1: { DevCmdReset(); rfidUID = string.Empty; this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备空闲"; break; } case 2: { if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 if (!SimMode) { rfidUID = rfidRW.ReadUID(); } else { rfidUID = SimRfidUID; } if (!string.IsNullOrWhiteSpace(rfidUID)) { this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { db1ValsToSnd[0] = db1StatRfidFailed; this.currentTaskPhase = 4; this.currentStat.StatDescribe = "未投产"; break; } //查询本地数据库,之前工位是否有不合格项,若有,下线 if (!PreDetectCheck(productBind.productBarcode)) { db1ValsToSnd[0] = db1StatNG; // } barcode = productBind.productBarcode; productBind.currentNode = this.nodeName; productBindBll.Update(productBind); BarcodeFillDB1(productBind.productBarcode, 1); //状态赋条码, this.currentStat.ProductBarcode = productBind.productBarcode; currentTaskPhase++; } else { db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.Status = EnumNodeStatus.无法识别; this.currentStat.StatDescribe = "读RFID卡失败"; break; } if (LineMonitorPresenter.DebugMode) { logRecorder.AddDebugLog(this.nodeName, "读卡完成:" + rfidUID); } break; } case 3: { //查询MES是否允许下线 if (0 != mesDA.MesAssemDown(new string[] { LineMonitorPresenter.mesLineID, barcode }, ref reStr)) { db1ValsToSnd[0] = db1StatNG; //禁止下线 //检测不合格,下线 OutputRecord(this.currentStat.ProductBarcode); } else { db1ValsToSnd[0] = db1StatCheckOK; //允许下线 } //发送条码到贴标机 if (!prienterRW.SndBarcode(barcode, ref reStr)) { ThrowErrorStat("给贴标机发送条码失败", EnumNodeStatus.设备故障); break; } this.currentStat.StatDescribe = "下线"; if (LineMonitorPresenter.DebugMode) { logRecorder.AddDebugLog(this.nodeName, "下线"); } currentTaskPhase++; break; } case 4: { //流程结束 break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { MessLossCheck(); if (!base.ExeBusiness(ref reStr)) { return(false); } if (!NodeStatParse(ref reStr)) { return(false); } //SendPrintcodeFromBuf(); if (!checkEnable) { return(true); } switch (currentTaskPhase) { case 1: { db1ValsToSnd[1] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 if (string.IsNullOrWhiteSpace(rfidUID)) { if (SysCfgModel.SimMode) { rfidUID = SimRfidUID; } else { rfidUID = rfidRW.ReadUID(); } } currentTaskDescribe = "开始读RFID"; if (!string.IsNullOrWhiteSpace(rfidUID)) { this.currentTask.TaskPhase = this.currentTaskPhase; this.currentTask.TaskParam = rfidUID; this.ctlTaskBll.Update(this.currentTask); db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { db1ValsToSnd[0] = db1StatCheckUnbinded; // this.currentTaskPhase = 5; this.currentStat.StatDescribe = "未投产"; logRecorder.AddDebugLog(nodeName, "未投产,rfid:" + rfidUID); checkEnable = false; break; } productBind.currentNode = this.nodeName; productBindBll.Update(productBind); BarcodeFillDB1(productBind.productBarcode, 2); //reDetectQuery=2,无记录,继续后面的流程 //状态赋条码, this.currentStat.ProductBarcode = productBind.productBarcode; logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "开始检测"); //查询本地数据库,之前工位是否有不合格项,若有,下线 if (!SysCfgModel.DebugMode) { int reDetectQuery = ReDetectQuery(productBind.productBarcode); ////if (0 == reDetectQuery) ////{ //// db1ValsToSnd[0] = db1StatCheckOK; ////// checkEnable = false; //// logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:OK", productBind.productBarcode)); //// // break; ////} //else if (1 == reDetectQuery) //{ // db1ValsToSnd[0] = db1StatNG; // // checkEnable = false; // logRecorder.AddDebugLog(nodeName, string.Format("{0}本地已经存在检验记录,检验结果:NG", productBind.productBarcode)); // // break; //} if (!PreDetectCheck(productBind.productBarcode)) { db1ValsToSnd[0] = db1StatCheckPreNG; // logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 在前面工位有检测NG项", productBind.productBarcode)); // checkEnable = false; // break; } if (!LossCheck(productBind.productBarcode, ref reStr)) { db1ValsToSnd[0] = db1StatCheckPreNG; // logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 检测漏项,{1}", productBind.productBarcode, reStr)); // checkEnable = false; // break; } } currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); } else { if (!rfidTimeCounterBegin) { //logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); rfidFailSt = System.DateTime.Now; } rfidTimeCounterBegin = true; TimeSpan ts = System.DateTime.Now - rfidFailSt; if (ts.TotalSeconds > SysCfgModel.RfidDelayTimeout) { if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; } this.currentStat.Status = EnumNodeStatus.无法识别; this.currentStat.StatDescribe = "读RFID卡失败"; break; } break; } case 2: { currentTaskDescribe = "等待检测结果"; if (db2Vals[2] == 0) { break; } string detectCodes = ""; if (db2Vals[2] == 1) { //合格 checkRe = 0; } else { checkRe = 1; detectCodes = GetDetectCodeStr(); if (string.IsNullOrWhiteSpace(detectCodes)) { break; } OutputRecord(this.currentStat.ProductBarcode); } currentTaskDescribe = "开始保存结果到本地"; if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, detectCodes, "", 0)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } currentTaskDescribe = "开始上传结果到MES"; if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 3: { currentTaskDescribe = "放行"; this.currentStat.StatDescribe = "外观检测完成"; string checkreStr = "OK"; if (checkRe == 1) { checkreStr = "NG"; db1ValsToSnd[0] = db1StatNG; } else { db1ValsToSnd[0] = db1StatCheckOK; //允许下线 //if (PLProcessModel.SysCfgModel.PrienterEnable) //{ // SendPrinterinfo(this.currentStat.ProductBarcode);//异步发送 //} } logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "检测完成," + checkreStr); this.currentStat.StatDescribe = "下线"; checkFinished = true; currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 4: { this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程结束"; //DevCmdReset(); //checkFinished = true; break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!NodeStatParse(ref reStr)) { return(false); } switch (currentTaskPhase) { case 1: { DevCmdReset(); rfidUID = string.Empty; this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备空闲"; checkFinished = false; currentTaskDescribe = "等待有板信号"; break; } case 2: { if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 if (!SimMode) { rfidUID = rfidRW.ReadUID(); } else { rfidUID = SimRfidUID; } currentTaskDescribe = "开始读RFID"; if (!string.IsNullOrWhiteSpace(rfidUID)) { db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { db1ValsToSnd[0] = db1StatNG; // this.currentTaskPhase = 5; this.currentStat.StatDescribe = "未投产"; logRecorder.AddDebugLog(nodeName, "未投产,rfid:" + rfidUID); checkEnable = false; break; } currentTaskPhase++; } else { if (!rfidTimeCounterBegin) { //logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); rfidFailSt = System.DateTime.Now; } rfidTimeCounterBegin = true; TimeSpan ts = System.DateTime.Now - rfidFailSt; if (ts.TotalSeconds > SysCfgModel.RfidDelayTimeout) { if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; } this.currentStat.Status = EnumNodeStatus.无法识别; this.currentStat.StatDescribe = "读RFID卡失败"; break; } break; } case 3: { if (PLProcessModel.SysCfgModel.PrienterEnable) { SendPrinterinfo(this.currentStat.ProductBarcode); //异步发送 } currentTaskPhase++; break; } case 4: { this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程结束"; //DevCmdReset(); //checkFinished = true; break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!base.ExeBusiness(ref reStr)) { return(false); } if (!NodeStatParse(ref reStr)) { return(false); } if (!checkEnable) { return(true); } switch (currentTaskPhase) { case 1: { db1ValsToSnd[1] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 if (string.IsNullOrWhiteSpace(rfidUID)) { if (SysCfgModel.SimMode) { rfidUID = SimRfidUID; } else { rfidUID = rfidRW.ReadUID(); } } currentTaskDescribe = "开始读RFID"; if (string.IsNullOrWhiteSpace(rfidUID)) { this.currentStat.StatDescribe = "读RFID卡失败"; if (db1ValsToSnd[0] != db1StatRfidFailed) { logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); } db1ValsToSnd[0] = db1StatRfidFailed; break; } this.currentTask.TaskPhase = this.currentTaskPhase; this.currentTask.TaskParam = rfidUID; this.ctlTaskBll.Update(this.currentTask); db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { db1ValsToSnd[0] = 4; this.currentStat.StatDescribe = "未投产"; logRecorder.AddDebugLog(nodeName, "未投产,rfid:" + rfidUID); checkEnable = false; break; } this.currentStat.ProductBarcode = productBind.productBarcode; productBind.currentNode = this.nodeName; productBindBll.Update(productBind); BarcodeFillDB1(productBind.productBarcode, 2); currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { currentTaskDescribe = "开始判断是否需要进维修"; Int16 checkStat = 0; for (int i = 0; i < SysCfgModel.checkStations.Count(); i++) { string checkNodeName = SysCfgModel.checkStations[i]; string strSql = string.Format("SERIAL_NUMBER='{0}' and AutoStationName='{1}'", this.currentStat.ProductBarcode, checkNodeName); LOCAL_MES_STEP_INFOModel localCheckModel = localMesBasebll.GetLatestModel(strSql); if (localCheckModel == null || (localCheckModel.CHECK_RESULT == 1)) { checkStat |= (Int16)(1 << i); } } int mesRe = 0; string logStr = ""; if (checkStat > 0) { this.db1ValsToSnd[0] = 3; logStr = string.Format("{0} 进入维修分流线,因为有检测NG项", this.currentStat.ProductBarcode); logRecorder.AddDebugLog(nodeName, logStr); } else { if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable) { logRecorder.AddDebugLog(nodeName, "MES下线查询开始:" + this.currentStat.ProductBarcode); mesRe = mesDA.MesAssemDown(new string[] { this.currentStat.ProductBarcode, PLProcessModel.SysCfgModel.mesLineID }, ref reStr); //string mesDownQueryMesID = "";// "DQ-F-0080"; //MES下线许可的MES工位id //if(SysCfgModel.mesLineID=="L10") //{ // mesDownQueryMesID = "DQ-G-0104"; //} //else //{ // // throw new NotImplementedException(); // mesDownQueryMesID = "DQ-H-0104"; //} //mesRe = mesDA.MesDownEnabled(PLProcessModel.SysCfgModel.mesLineID, this.currentStat.ProductBarcode, mesDownQueryMesID, ref reStr); } if (mesRe == 0) { logStr = string.Format("{0} MES下线允许,进入下线位", this.currentStat.ProductBarcode); logRecorder.AddDebugLog(nodeName, logStr); this.db1ValsToSnd[0] = 1; } else if (mesRe == 1) { if (this.db1ValsToSnd[0] != 3) { logStr = string.Format("{0} 进入维修分流线,因为:mes禁止下线,{1}", this.currentStat.ProductBarcode, reStr); logRecorder.AddDebugLog(nodeName, logStr); } this.db1ValsToSnd[0] = 3; } else if (reStr.Contains("已下线")) { if (this.db1ValsToSnd[0] != 3) { logStr = string.Format("{0} ,{1},进入维修分流线", this.currentStat.ProductBarcode, reStr); logRecorder.AddDebugLog(nodeName, logStr); } this.db1ValsToSnd[0] = 3; } else { break; } } //判断MES网络是否断开 if (mesRe != 0) { checkStat |= (1 << 4); } this.db1ValsToSnd[32] = checkStat; currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 3: { currentTaskDescribe = "维修分流完成"; this.currentStat.StatDescribe = "流程完成"; break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { DateTime commSt = System.DateTime.Now; // Console.WriteLine("P1"); MessLossCheck(); // Console.WriteLine("P2"); DateTime commEd = System.DateTime.Now; TimeSpan ts = commEd - commSt; if (ts.TotalMilliseconds > 1000) { // node.LogRecorder.AddDebugLog(node.NodeName, dispCommInfo); CurrentStat.StatDescribe = string.Format("漏项检查周期:{0}毫秒", (int)ts.TotalMilliseconds); } if (this.db2Vals[1] == 1) //纸箱到位 { boxPrepareOK = true; } if (!NodeStatParse(ref reStr)) { return(false); } // Console.WriteLine("P3"); if ((this.db2Vals[1] == 0) && (currentTaskPhase > 1) && boxPrepareOK) { //抓取完毕后,纸箱复位(主要是非正常流程下人工取走纸箱) DevCmdReset(); this.currentStat.StatDescribe = "流程复位"; currentTaskDescribe = "流程复位"; graspBegin = false;//准备新的流程 currentTaskPhase = 1; } //清理MES查询记录字典 List <string> removeList = new List <string>(); foreach (string key in NodePack.mesQueryStat.Keys) { MesStatRecord mesStat = NodePack.mesQueryStat[key]; TimeSpan tmSpan = System.DateTime.Now - mesStat.StatModifyTime; if (tmSpan.TotalSeconds > 60) { removeList.Add(key); } } // Console.WriteLine("P4"); foreach (string key in removeList) { NodePack.mesQueryStat.Remove(key); } // Console.WriteLine("P5"); if (!checkEnable) { return(true); } switch (currentTaskPhase) { case 1: { DevCmdReset(); rfidUID = string.Empty; this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备空闲"; checkFinished = false; boxPrepareOK = false; graspBegin = false; currentTaskDescribe = "等待有板信号"; break; } case 2: { db1ValsToSnd[32] = 1; //流程锁定 if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //开始读卡 DateTime dtSt = System.DateTime.Now; if (!SimMode) { rfidUID = rfidRW.ReadUID(); } else { rfidUID = SimRfidUID; } currentTaskDescribe = "开始读RFID"; if (!string.IsNullOrWhiteSpace(rfidUID)) { db1ValsToSnd[0] = 0; this.currentStat.StatDescribe = "RFID识别完成"; //根据绑定,查询条码,赋条码 OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID); if (productBind == null) { db1ValsToSnd[0] = db1StatNG; this.currentStat.StatDescribe = "未投产"; currentTaskDescribe = "未投产"; //mesQueryStat[this.currentStat.ProductBarcode] = 3;//MES禁止下线 SetMesQueryStat(this.currentStat.ProductBarcode, 3); checkEnable = false; break; } productBind.currentNode = this.nodeName; productBindBll.Update(productBind); //状态赋条码, this.currentStat.ProductBarcode = productBind.productBarcode; BarcodeFillDB1(productBind.productBarcode, 2); SetMesQueryStat(this.currentStat.ProductBarcode, 1); //检查是否已经下线,MES离线模式下不判断 logRecorder.AddDebugLog(nodeName, "查询MES是否已经下线:" + this.currentStat.ProductBarcode); if (!SysCfgModel.MesOfflineMode) { int mesDown = mesDA.MesDowned(this.currentStat.ProductBarcode, mesNodeID, ref reStr); if (mesDown == 1) { string logInfo = string.Format("条码重复,{0} 已经下线,请检查", this.currentStat.ProductBarcode); logRecorder.AddDebugLog(nodeName, logInfo); db1ValsToSnd[0] = mesDownedFlag; checkEnable = false; break; } else if (mesDown == 3) { string logInfo = string.Format("MES数据库访问失败,无法查询是否已经下线,{0},{1}", this.currentStat.ProductBarcode, reStr); logRecorder.AddDebugLog(nodeName, logInfo); } } if (!PreDetectCheck(productBind.productBarcode)) { if (db1ValsToSnd[0] != db1StatNG) { logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 在前面工位有检测NG项", productBind.productBarcode)); } db1ValsToSnd[0] = db1StatNG; currentTaskDescribe = string.Format("{0} 在前面工位有检测NG项", productBind.productBarcode); SetMesQueryStat(this.currentStat.ProductBarcode, 3); //MES禁止下线 // mesQueryStat.Remove(this.currentStat.ProductBarcode); checkEnable = false; break; } if (!LossCheck(productBind.productBarcode, ref reStr)) { if (db1ValsToSnd[0] != db1StatNG) { logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 检测漏项,{1}", productBind.productBarcode, reStr)); } currentTaskDescribe = string.Format("{0} 检测漏项,{1}", productBind.productBarcode, reStr); db1ValsToSnd[0] = db1StatNG; SetMesQueryStat(this.currentStat.ProductBarcode, 3); //MES禁止下线 //mesQueryStat.Remove(this.currentStat.ProductBarcode); checkEnable = false; break; } this.detectStartTime = System.DateTime.Now; logRecorder.AddDebugLog(nodeName, "MES下线查询开始:" + this.currentStat.ProductBarcode); currentTaskDescribe = "MES下线查询开始:" + this.currentStat.ProductBarcode; currentTaskPhase++; } else { currentTaskDescribe = "读RFID卡失败"; if (!SysCfgModel.SimMode) { DateTime dtEnd = DateTime.Now; string recvStr = (rfidRW as SgrfidRW).GetRecvBufStr(); string logStr = string.Format("读RFID失败,发送读卡命令:{0},接收判断时间:{1},接收数据:{2}", dtSt.ToString("HH:mm:ss"), dtEnd.ToString("HH:mm:ss"), recvStr); logRecorder.AddDebugLog(nodeName, logStr); } //if (db1ValsToSnd[0] != db1StatRfidFailed) //{ // logRecorder.AddDebugLog(nodeName, "读RFID卡失败"); //} db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.Status = EnumNodeStatus.无法识别; this.currentStat.StatDescribe = "读RFID卡失败"; break; } break; } case 3: { currentTaskDescribe = "开始查询MES下线是否允许"; int mesRe = 0; if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable) { mesRe = mesDA.MesAssemDown(new string[] { this.currentStat.ProductBarcode, LineMonitorPresenter.mesLineID }, ref reStr); } //int mesRe = mesDA.MesAssemDown(new string[] { this.currentStat.ProductBarcode, LineMonitorPresenter.mesLineID }, ref reStr); if (0 != mesRe) { int delayTimeOut = SysCfgModel.MesTimeout; //20;//最多允许延迟10秒 TimeSpan timeElapse = System.DateTime.Now - detectStartTime; if (timeElapse.TotalMilliseconds > delayTimeOut * 1000) { SetMesQueryStat(this.currentStat.ProductBarcode, 3); //MES禁止下线 this.currentStat.StatDescribe = string.Format("{0} :MES预下线查询超时({1}秒),{2}", this.currentStat.ProductBarcode, delayTimeOut, reStr); logRecorder.AddDebugLog(this.nodeName, currentStat.StatDescribe); currentTaskDescribe = "MES下线允许超时"; //超时,通知外观检测工位 db1ValsToSnd[0] = db1StatNG; checkEnable = false; break; } } else { logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 下线允许", this.currentStat.ProductBarcode)); currentTaskDescribe = "MES下线允许"; SetMesQueryStat(this.currentStat.ProductBarcode, 2); //下线,高度配方发完,MES入库 if (!MesDatalocalSave(this.currentStat.ProductBarcode, 0, "", "", 1)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } string[] mesProcessSeq = new string[] { "RQ-ZA280" }; if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); currentTaskDescribe = "上传MES失败"; break; } //查询产品高度参数 string productTypeCode = ""; if (this.currentStat.ProductBarcode.Count() == 26) { productTypeCode = this.currentStat.ProductBarcode.Substring(0, 13); } else { productTypeCode = ""; } ProductSizeCfgModel cfg = productCfgBll.GetModel(productTypeCode); if (cfg == null) { db1ValsToSnd[0] = 32; currentTaskDescribe = string.Format("产品未配置,物料码{0}", productTypeCode); this.currentStat.StatDescribe = currentTaskDescribe; this.currentStat.Status = EnumNodeStatus.设备故障; checkEnable = false; break; } //产品高度信息 // ProductHeightDefModel heightDef = productHeightBll.GetModel(cfg.productHeight); if (cfg.baseSizeLevel == null) { cfg.baseSizeLevel = 0; } db1ValsToSnd[33] = (short)cfg.baseSizeLevel; db1ValsToSnd[1] = short.Parse(cfg.tag1); //(short)heightDef.heightSeq; graspBegin = true; currentTaskPhase++; } break; } case 4: { currentTaskDescribe = "等待有板信号复位"; if (db2Vals[0] != 0) { //等待抓起 break; } //解绑 TryUnbind(this.rfidUID, this.currentStat.ProductBarcode); DevCmdReset(); // currentTaskDescribe = "等待纸箱信号"; currentTaskPhase++; break; } case 5: { //读条码,做校验 if (db2Vals[1] != 1) //纸箱到位后才启动条码枪 { break; } boxPrepareOK = true; //启用自动贴标功能 if (PLProcessModel.SysCfgModel.PrienterEnable) { string boxBarcode = ""; if (SysCfgModel.SimMode) { boxBarcode = SimBarcode; } else { boxBarcode = barcodeRW.ReadBarcode(); } if (boxBarcode == string.Empty || boxBarcode.Length < 26) { db1ValsToSnd[0] = barcodeCompareFailed; this.currentStat.StatDescribe = "无效的条码,位数不足26位!"; currentTaskDescribe = string.Format("纸箱条码校验错误,无效的条码,位数不足26位{0}", boxBarcode); break; } //校验纸箱条码跟主机条码是否一致 if (boxBarcode != this.currentStat.ProductBarcode) { this.currentStat.StatDescribe = "纸箱跟主机条码不同"; currentTaskDescribe = string.Format("纸箱条码校验错误,主机:{0},纸箱{1}", this.currentStat.ProductBarcode, boxBarcode); if (db1ValsToSnd[0] != barcodeCompareFailed) { logRecorder.AddDebugLog(nodeName, currentTaskDescribe); } db1ValsToSnd[0] = barcodeCompareFailed; break; } logRecorder.AddDebugLog(nodeName, "纸箱条码验证通过:" + boxBarcode); currentTaskDescribe = "纸箱条码验证通过:" + boxBarcode; } currentTaskPhase++; break; } case 6: { db1ValsToSnd[0] = db1StatCheckOK; //核对正确,允许搬运 this.currentStat.StatDescribe = "装箱核对检测完成"; currentTaskDescribe = "装箱核对检测完成"; checkFinished = true; currentTaskPhase++; break; } case 7: { currentTaskDescribe = "等待纸箱信号复位"; if (db2Vals[1] != 0) { break; } logRecorder.AddDebugLog(nodeName, "入箱完成:" + this.currentStat.ProductBarcode); DevCmdReset(); this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "入箱完成"; graspBegin = false; //准备新的流程 boxPrepareOK = false; currentTaskPhase = 1; break; } default: break; } return(true); }