public string GetProductCfgInfo(string cataCode) { string reStr = ""; ProductSizeCfgModel cfg = productCfgBll.GetModel(cataCode); if (cfg == null) { return(reStr); } reStr = string.Format("{0}", cfg.productName); return(reStr); }
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 = "设备空闲"; currentTaskDescribe = "等待有产品信号"; break; } case 2: { if (this.currentStat.Status == EnumNodeStatus.设备故障) { break; } this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备使用中"; //读条码,做校验 currentTaskDescribe = "开始读产品条码"; string boxBarcode = ""; if (SysCfgModel.SimMode) { boxBarcode = SimBarcode; } else { boxBarcode = barcodeRW.ReadBarcode(); } if (boxBarcode == string.Empty || boxBarcode.Length < 26) { db1ValsToSnd[0] = db1StatRfidFailed; this.currentStat.StatDescribe = "无效的条码,位数不足26位!"; currentTaskDescribe = "无效的条码,位数不足26位!"; break; } else { db1ValsToSnd[0] = 0; } logRecorder.AddDebugLog(nodeName, "扫到纸箱条码:" + boxBarcode); //状态赋条码, BarcodeFillDB1(boxBarcode, 3); this.currentStat.ProductBarcode = boxBarcode; string productTypeCode = boxBarcode.Substring(0, 13); ProductSizeCfgModel cfg = productCfgBll.GetModel(productTypeCode); if (cfg == null) { db1ValsToSnd[0] = 8; this.currentStat.StatDescribe = "产品尺寸配置不存在"; logRecorder.AddDebugLog(nodeName, "包装配置不存在," + boxBarcode); currentTaskDescribe = "产品尺寸配置不存在"; checkEnable = false; break; } ProductPacsizeDefModel packSize = packsizeDefBll.GetModel(cfg.packageSize); db1ValsToSnd[1] = (short)packSize.packageSeq; db1ValsToSnd[2] = (short)(cfg.cataSeq % 256); if (db1ValsToSnd[2] == 0) { db1ValsToSnd[2] = 1; } currentTaskPhase++; OutputRecord(this.currentStat.ProductBarcode); break; } case 3: { db1ValsToSnd[0] = db1StatCheckOK; this.currentStat.StatDescribe = "机器人码垛完成"; if (LineMonitorPresenter.DebugMode) { logRecorder.AddDebugLog(this.nodeName, "码垛完成"); } currentTaskDescribe = "机器人码垛完成"; currentTaskPhase++; break; } case 4: { this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程完成"; break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!base.ExeBusiness(ref reStr)) { return(false); } if (db2Vals[0] == 0) { if (currentTaskPhase > 2) { if (!SysCfgModel.SimMode) { if (!AipuObj.CloseDev(ref reStr)) { logRecorder.AddDebugLog(nodeName, "关闭艾普检测设备失败," + reStr); } } } } if (!NodeStatParse(ref reStr)) { return(false); } //SendPrintcodeFromBuf(); if (!checkEnable) { return(true); } switch (currentTaskPhase) { case 1: { checkRe = 0; if (!ProcessStartCheck(3, !SysCfgModel.DebugMode)) { break; } //发送机器人配方 ProductSizeCfgBll productCfg = new ProductSizeCfgBll(); string cataCode = this.currentStat.ProductBarcode.Substring(0, 13); cfgModel = productCfg.GetModel(cataCode); if (cfgModel == null) { if (this.db1ValsToSnd[0] != 6) { 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] = 6; return(true); } this.db1ValsToSnd[2] = (short)cfgModel.robotProg; this.currentTaskPhase++; break; } case 2: { if (!SysCfgModel.SimMode) { float frequenze = 50.0f; // (float)cfgModel.frequency1; float volt = 233.0f; // (float)cfgModel.volt1; if (!AipuObj.SetRunningParam(frequenze, volt, ref reStr)) { logRecorder.AddDebugLog(nodeName, "设置艾普强档检测参数失败," + reStr); break; } logRecorder.AddDebugLog(nodeName, string.Format("设置艾普强档电压/频率参数,{0}V,{1}HZ", volt, frequenze)); //if(!AipuObj.OpenDev(ref reStr)) //{ // logRecorder.AddDebugLog(nodeName, "设置艾普强档检测参数失败," + reStr); // break; //} detectStartTime = System.DateTime.Now; } logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "开始检测,启动艾普检测仪"); this.currentTaskPhase++; break; } case 3: { float frequenze = 50.0f; //(float)cfgModel.frequency1; float volt = 220.0f; //(float)cfgModel.volt2; if (!SysCfgModel.SimMode) { TimeSpan ts = System.DateTime.Now - detectStartTime; if (ts.TotalSeconds > 10) { //开始切换到弱档参数 logRecorder.AddDebugLog(nodeName, string.Format("设置艾普弱档电压/频率参数,{0}V,{1}HZ", volt, frequenze)); if (!AipuObj.SetRunningParam(frequenze, volt, ref reStr)) { logRecorder.AddDebugLog(nodeName, "设置艾普弱档检测参数失败," + reStr); break; } this.currentTaskPhase++; } } else { logRecorder.AddDebugLog(nodeName, string.Format("设置艾普弱档电压/频率参数,{0}V,{1}HZ", volt, frequenze)); this.currentTaskPhase++; } break; } case 4: { 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; } currentTaskPhase++; break; } case 5: { currentTaskDescribe = "开始上传结果到MES"; if (checkRe == 1) { if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } } currentTaskPhase++; break; } case 6: { currentTaskDescribe = "放行"; this.currentStat.StatDescribe = "检测完成"; string checkreStr = "OK"; if (checkRe == 1) { checkreStr = "NG"; db1ValsToSnd[0] = db1StatNG; } else { db1ValsToSnd[0] = db1StatCheckOK; //允许下线 } logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "检测完成," + checkreStr); this.currentStat.StatDescribe = "下线"; checkFinished = true; currentTaskPhase++; break; } case 7: { this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程结束"; break; } } return(true); }
public bool ManualExeBusiness(ref string reStr) { switch (currentTaskPhase) { case 1: { detectCode = ""; cfgModel = null; if (!ProcessStartCheck(3, !SysCfgModel.DebugMode)) { break; } this.currentTask.TaskPhase = this.currentTaskPhase; this.currentTask.TaskParam = rfidUID; this.ctlTaskBll.Update(this.currentTask); ProductSizeCfgBll productCfg = new ProductSizeCfgBll(); string cataCode = this.currentStat.ProductBarcode.Substring(0, 13); cfgModel = productCfg.GetModel(cataCode); if (cfgModel == null) { if (this.db1ValsToSnd[0] != 6) { 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] = 6; return(true); } logRecorder.AddDebugLog(this.nodeName, this.currentStat.ProductBarcode + "开始检测"); this.db1ValsToSnd[2] = (short)cfgModel.robotProg; this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { //等待人工检测完毕, this.currentStat.StatDescribe = "等待人工检测完成"; this.currentTaskDescribe = "等待人工检测完成"; if (this.db2Vals[2] != 1) { break; } currentTaskDescribe = "开始查询安规结果"; DevAccess.AinuoDetectModel detectModel = null; string strDetectVal = ""; if (SysCfgModel.SimMode) { detectModel = GenerateSimDetect(); //currentTaskDescribe = "开始保存本地检测结果"; //checkRe = 0; //if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, detectCode, "", 0)) //{ // Console.WriteLine(string.Format("{0}保存检测数据到本地数据库失败", nodeName)); // break; //} } else { detectModel = AinuoObj.GetDetectResult(ref reStr); //if (detectModel == null) //{ // TimeSpan timeElapse = System.DateTime.Now - detectStartTime; // if (timeElapse.TotalMilliseconds < detectTimeout) // { // break; // } // else // { // detectStartTime = System.DateTime.Now; // logRecorder.AddDebugLog(this.nodeName, string.Format("检测超时,{0}毫秒,重新检测", detectTimeout)); // currentStat.StatDescribe = string.Format("检测超时"); // } //} } if (detectModel == null) { logRecorder.AddDebugLog(nodeName, this.currentStat.ProductBarcode + "检测超时,无数据," + reStr); ThreadBaseModel.Sleep(1000); break; } float designPower = float.Parse(cfgModel.power1); if (!GetDetectResult(this.currentStat.ProductBarcode, detectModel, designPower, ref detectCode, ref strDetectVal, ref checkRe)) { ThreadBaseModel.Sleep(1000); break; } //if (!SysCfgModel.SimMode) //{ // if (!AinuoObj.CloseDev(ref reStr)) // { // logRecorder.AddDebugLog(nodeName, this.currentStat.ProductBarcode + "关闭艾诺检测设备失败," + reStr); // break; // } //} currentTaskDescribe = "开始保存本地检测结果"; if (!string.IsNullOrWhiteSpace(detectCode)) { if (detectCode.Substring(detectCode.Length - 1, 1) == ",") { detectCode = detectCode.Remove(detectCode.Length - 1, 1); } logRecorder.AddDebugLog(nodeName, this.currentStat.ProductBarcode + "故障码:" + detectCode); } if (checkRe > 0) { OutputRecord(this.currentStat.ProductBarcode); } if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, detectCode, strDetectVal, 0)) { Console.WriteLine(string.Format("{0}保存检测数据到本地数据库失败", nodeName)); break; } this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 3: { string checkReStr = "OK"; if (this.nodeID == "2001") { if (checkRe == 1) { //安规1检测完成NG后上传数据 if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } } } else { //安规1检测完成若合格后不上传数据 if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); break; } } 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++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 4: { //流程结束 this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程结束"; // this.currentTaskPhase++; break; } } return(true); }
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); }
// 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); } }
// 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) { MessLossCheck(); base.ExeBusiness(ref reStr); if (!NodeStatParse(ref reStr)) { return(false); } //清理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); // } //} //foreach (string key in removeList) //{ // NodePack.mesQueryStat.Remove(key); //} if (!checkEnable) { return(true); } switch (currentTaskPhase) { case 1: { if (!ProcessStartCheck(3, !SysCfgModel.DebugMode)) { break; } this.currentTask.TaskPhase = this.currentTaskPhase; this.currentTask.TaskParam = rfidUID; this.ctlTaskBll.Update(this.currentTask); //检查是否已经下线,MES离线模式下不判断 if (!SysCfgModel.MesOfflineMode) { int mesDown = mesDA.MesDowned(this.currentStat.ProductBarcode, mesNodeID, ref reStr); if (mesDown == 1) { if (db1ValsToSnd[0] != mesDownedFlag) { 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); } } this.detectStartTime = System.DateTime.Now; logRecorder.AddDebugLog(nodeName, "MES下线查询开始:" + this.currentStat.ProductBarcode); currentTaskDescribe = "MES下线查询开始:" + this.currentStat.ProductBarcode; currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { currentTaskDescribe = "开始查询MES下线是否允许"; int mesRe = 0; if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable) { mesRe = mesDA.MesAssemDown(new string[] { this.currentStat.ProductBarcode, PLProcessModel.SysCfgModel.mesLineID }, ref reStr); //string mesDownQueryMesID = "";// mesNodeID; //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 (0 == mesRe) { logRecorder.AddDebugLog(this.nodeName, string.Format("{0} 下线允许", this.currentStat.ProductBarcode)); currentTaskDescribe = "MES下线允许"; SetMesQueryStat(this.currentStat.ProductBarcode, 2); //启用自动贴标功能 if (PLProcessModel.SysCfgModel.PrienterEnable) { //发送条码 if (!SendPrinterinfo(this.currentStat.ProductBarcode, true)) { break; } } currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); } else { if (reStr.Contains("已下线")) { if (db1ValsToSnd[0] != mesDownedFlag) { string logInfo = string.Format("{0} 已经下线,请检查", this.currentStat.ProductBarcode); logRecorder.AddDebugLog(nodeName, logInfo); } db1ValsToSnd[0] = mesDownedFlag; } else if (2 == mesRe || 3 == 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); currentTaskDescribe = "MES下线允许超时"; if (db1ValsToSnd[0] != mesDownDisable) { logRecorder.AddDebugLog(this.nodeName, currentStat.StatDescribe); } db1ValsToSnd[0] = mesDownDisable; checkEnable = false; break; } } else if (1 == mesRe) { SetMesQueryStat(this.currentStat.ProductBarcode, 3); //MES禁止下线 this.currentStat.StatDescribe = string.Format("{0} :MES禁止下线,因为:{1}", this.currentStat.ProductBarcode, reStr); if (db1ValsToSnd[0] != mesDownDisable) { logRecorder.AddDebugLog(this.nodeName, currentStat.StatDescribe); } currentTaskDescribe = this.currentStat.StatDescribe; db1ValsToSnd[0] = mesDownDisable; checkEnable = false; break; } } break; } case 3: { //查询产品高度参数 string productTypeCode = ""; productTypeCode = this.currentStat.ProductBarcode.Substring(0, 13); ProductSizeCfgModel cfg = productCfgBll.GetModel(productTypeCode); if (cfg == null) { db1ValsToSnd[0] = heightNotCfg; this.currentStat.StatDescribe = "产品未配置"; currentTaskDescribe = "产品未配置"; checkEnable = false; break; } //产品高度信息 //ProductHeightDefModel heightDef = productHeightBll.GetModel(cfg.productHeight); //db1ValsToSnd[2] = (short)heightDef.heightSeq; db1ValsToSnd[2] = (short)cfg.robotProg; graspBegin = true; currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 4: { currentTaskDescribe = "等待有板信号复位"; if (db2Vals[0] != 0 || db2Vals[1] != 0) { //等待抓起 break; } DevCmdReset(); // //解绑 if (!TryUnbind(this.rfidUID, this.currentStat.ProductBarcode)) { currentTaskDescribe = string.Format("解绑失败,RFID:{0},主机条码:{1}", this.rfidUID, this.currentStat.ProductBarcode); logRecorder.AddDebugLog(nodeName, currentTaskDescribe); break; } //下线,高度配方发完,MES入库 if (!MesDatalocalSave(this.currentStat.ProductBarcode, 0, "", "", 1)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } if (!UploadMesdata(true, this.currentStat.ProductBarcode, mesProcessSeq, ref reStr)) { this.currentStat.StatDescribe = "上传MES失败"; logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe); currentTaskDescribe = "上传MES失败"; break; } db1ValsToSnd[0] = db1StatCheckOK; //核对正确,允许搬运 checkFinished = true; currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 5: { logRecorder.AddDebugLog(nodeName, "入箱完成:" + this.currentStat.ProductBarcode); DevCmdReset(); this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "入箱完成"; graspBegin = false; //准备新的流程 currentTaskPhase = 1; 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); }
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: { DevCmdReset(); rfidUID = string.Empty; this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备空闲"; checkFinished = false; currentTaskDescribe = "等待有板信号"; break; } case 2: { checkRetryCounter = 0; 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; } //状态赋条码, this.currentStat.ProductBarcode = productBind.productBarcode; productBind.currentNode = this.nodeName; productBindBll.Update(productBind); string cataCode = productBind.productBarcode.Substring(0, 13); ProductSizeCfgBll productCfgBll = new ProductSizeCfgBll(); ProductSizeCfgModel m = productCfgBll.GetModel(cataCode); if (m == null) { this.ThrowErrorStat(productBind.productBarcode + "产品型号配置不存在", EnumNodeStatus.设备故障); this.currentStat.StatDescribe = "无配置信息:" + cataCode; checkEnable = false; break; } if (m.baseSizeLevel == null) { m.baseSizeLevel = 0; } this.db1ValsToSnd[32] = (short)m.baseSizeLevel; 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; } //查询本地数据库,之前工位是否有不合格项,若有,下线 // 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 (!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; } currentTaskPhase++; break; } case 3: { //插头就绪 currentTaskDescribe = "等待插头就绪"; if (db2Vals[1] == 1) { db1ValsToSnd[31] = 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 4: { //查询检测结果,检测完成或超时 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 = "开始保存本地气密结果"; logRecorder.AddDebugLog(this.nodeName, string.Format("{0}检测数据,{1},{2},{3}", this.currentStat.ProductBarcode, detectRe.DetectVal.ToString(), detectRe.UnitDesc, detectRe.DetectResult)); 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 = "气密超时,开始保存本地气密结果"; if (!MesDatalocalSave(this.currentStat.ProductBarcode, checkRe, checkCode, "0", 0)) { logRecorder.AddLog(new LogModel(this.nodeName, "保存检测数据到本地数据库失败", EnumLoglevel.警告)); break; } checkRe = 1;//超时 db1ValsToSnd[0] = db1StatNG; logRecorder.AddDebugLog(this.nodeName, string.Format("检测超时,{0}毫秒", detectTimeout)); currentStat.StatDescribe = string.Format("检测超时,{0}毫秒", detectTimeout); currentTaskPhase++; break; } } break; } case 5: { string[] mesProcessSeq = new string[] { "RQ-ZA230", "RQ-ZA240", "RQ-ZA220" }; //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 6: { //流程结束 this.currentStat.StatDescribe = "流程完成"; currentTaskDescribe = "流程结束"; // this.currentTaskPhase++; break; } } return(true); }