int GetBatteryInfoFromMES(string rfid, ref string retString, ref string[] singleSNCollect) { string sn = string.Empty; sn = MESWCFManage.Inst().GetSNByRFID(this.rfidUID); if (sn.Length <= 0) { retString = "从MES中获取的条码SN为空"; // 将PLC对应的点设置为 电池为空 return(1); } string[] snCollect = sn.Split(','); if (snCollect.Length != this.snSize) { retString = string.Format("从MES中获取的条码SN个数不正确:等待获取 {0},实际获取 {1}", this.snSize, singleSNCollect.Length); return(2); } // 检查每个SN码是否正确START // 检查每个SN码是否正确END return(0); }
int GetBatteryInfoFromMES(string rfid, ref string retString, ref string[] singleSNCollect) { string sn = string.Empty; if (mesenable == 0) { for (int i = 0; i < snSize; i++) { singleSNCollect[i] = "HSK" + System.DateTime.Now.ToString("yyyyMMdd") + (i + 1).ToString(); } return(0); } else { sn = MESWCFManage.Inst().GetSNByRFID(this.rfidUID); } if (sn.Length <= 0) { retString = "从MES中获取的条码SN为空"; return(1); } string[] snCollect = sn.Split(','); if (snCollect.Length > this.snSize) { retString = string.Format("从MES中获取的条码SN个数不正确:等待获取 {0},实际获取 {1}", this.snSize, snCollect.Length); return(2); } for (int i = 0; i < snCollect.Length; i++) { singleSNCollect[i] = snCollect[i]; } return(0); }
bool ReportBarcode(ref List <string> barcodes) { bool ret = true; if (mesenable != 0) { string reportStr = string.Empty; List <string> subList = barcodes.FindAll(ListFind2); reportStr += subList[0] + "="; subList = barcodes.FindAll(ListFind3); foreach (string str in subList) { reportStr += str + ","; } reportStr = reportStr.Substring(0, reportStr.Length - 1); ret = MESWCFManage.Inst().ScanBind20(reportStr); } return(ret); }
public override bool ExeBusiness(ref string reStr) { if (!nodeEnabled) { return(true); } // 查看此节点是否有任务在执行或排队 if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } if (db2Vals[0] != 2) { db1ValsToSnd[1] = 1; } //任务撤销 if (db2Vals[1] == 3 && db1ValsToSnd[0] != 3) { if (this.currentTask != null && this.currentTaskPhase > 0) { this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString(); this.currentTask.FinishTime = System.DateTime.Now; ctlTaskBll.Update(this.currentTask); logRecorder.AddDebugLog(this.nodeName, "装载任务撤销"); currentTaskDescribe = "装载任务撤销"; this.currentTask = null; this.currentTaskPhase = 0; } Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); db1ValsToSnd[0] = 3;// return(true); } if (db1ValsToSnd[0] == 3 && db2Vals[1] == 1) { //任务撤销命令复位,应答也复位 db1ValsToSnd[0] = 1; } if (!FillTaskRequire(ref reStr)) { return(false); } if (this.currentTask == null) { return(true); } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始执行装载任务"; this.db1ValsToSnd[1] = 2; this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { currentTaskDescribe = "将RFID上报MES系统"; // ADD if (!SysCfg.SysCfgModel.SimMode) { if (!MESWCFManage.Inst().UpLoadRID(this.rfidUID)) { if (this.db1ValsToSnd[0] != 4 && this.currentTaskPhase == 1) { logRecorder.AddDebugLog(nodeName, "读到托盘号后,RFID上报MES系统失败!"); } this.db1ValsToSnd[0] = 4; break; } } //if (this.db1ValsToSnd[0] == 4) //{ // //装载错误状态 // break; //} this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); logRecorder.AddDebugLog(nodeName, "RFID上报MES完成,等待电池条码数据"); break; } case 3: { //等待扫码完成 currentTaskDescribe = "RFID上报MES完成,等待电池条码数据"; if (db2Vals[1] != 2) { break; } int ret = 0; string[] singleSNCollect = new string[snSize]; if (SysCfg.SysCfgModel.SimMode) { //生成模拟数据 GenerateSimBatterys(ref singleSNCollect); } else { // 从MES中获取电池信息 ret = GetBatteryInfoFromMES(this.rfidUID, ref reStr, ref singleSNCollect); if (ret != 0) { currentTaskDescribe = string.Format(" 装载错误{0}", reStr); if (ret == 1) { this.db1ValsToSnd[0] = 5; } else if (ret == 2) { this.db1ValsToSnd[0] = 4; } logRecorder.AddDebugLog(nodeName, currentTaskDescribe); break; } } bool insertFlag = InsertToDB(singleSNCollect); if (insertFlag == false) { logRecorder.AddDebugLog(nodeName, "数据库更新失败"); currentTaskDescribe = "数据库更新失败"; break; } //自动装载都是1次装载 //string sndStr = ""; //if (!hkAccess.BatteryFill(0, this.rfidUID, batteryList, ref sndStr, ref reStr)) //{ // logRecorder.AddDebugLog(nodeName, string.Format(" 装载错误:{0},发送数据:{1}", reStr, sndStr)); // this.db1ValsToSnd[0] = 4;//装载错误 // currentTaskDescribe = string.Format(" 装载错误{0}", reStr); // break; //} logRecorder.AddDebugLog(nodeName, string.Format(" 装载成功{0}", rfidUID)); AddProduceRecord(this.rfidUID, string.Format("装载:{0}", nodeName)); this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.db1ValsToSnd[0] = 2; logRecorder.AddDebugLog(nodeName, "托盘跟电池条码数据绑定完成,等待完成信号复位"); break; } case 4: { currentTaskDescribe = "托盘跟电池条码数据绑定完成,等待完成信号复位"; if (this.db2Vals[1] != 1) { break; } DevCmdReset(); this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString(); this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; currentTaskPhase = 0; logRecorder.AddDebugLog(nodeName, "等待执行下一个任务"); currentTaskDescribe = "等待执行下一个任务"; //等待扫码完成 break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!nodeEnabled) { return(true); } // 查看此节点是否有任务在执行或排队 if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } //任务撤销 if (db2Vals[1] == 3) { if (this.currentTask != null && this.currentTaskPhase > 0) { this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString(); this.currentTask.FinishTime = System.DateTime.Now; ctlTaskBll.Update(this.currentTask); this.logRecorder.AddDebugLog(this.nodeName, "装载任务撤销"); currentTaskDescribe = "装载任务撤销"; this.currentTask = null; this.currentTaskPhase = 0; } //Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); this.db1ValsToSnd[0] = 3;// return(true); } if (db2Vals[1] == 1) { db1ValsToSnd[0] = 1; db1ValsToSnd[1] = 1; NodeCmdCommit(false, ref reStr); } if (db1ValsToSnd[0] == 3) { //任务撤销命令复位,应答也复位 this.db1ValsToSnd[0] = 1; return(true); } if (!FillTaskRequire(ref reStr)) { return(false); } if (this.currentTask == null) { return(true); } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = "开始执行装载任务"; this.db1ValsToSnd[1] = 2; this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "将RFID上报MES系统"); break; } case 2: { currentTaskDescribe = this.rfidUID + "将RFID上报MES系统"; if (!SysCfg.SysCfgModel.SimMode) { if (mesenable != 0) { if (!MESWCFManage.Inst().UpLoadRID(this.rfidUID)) { if (this.db1ValsToSnd[0] != 4 && this.currentTaskPhase == 1) { this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "装载,读到托盘号后,RFID上报MES系统失败!"); } this.db1ValsToSnd[0] = 4; break; } } } //// 将读卡请求复位START //this.db1ValsToSnd[1] = 1; //// 将读卡请求复位END this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "装载,RFID上报MES完成,等待装载完成"); break; } case 3: { //等待扫码完成 currentTaskDescribe = this.rfidUID + "装载,RFID上报MES完成,等待装载完成"; if (db2Vals[1] != 2) { break; } //// 将读卡请求复位START this.db1ValsToSnd[1] = 1; //// 将读卡请求复位END int ret = 0; string[] singleSNCollect = new string[snSize]; if (SysCfg.SysCfgModel.SimMode) { //生成模拟数据 GenerateSimBatterys(ref singleSNCollect); } else { // 从MES中获取电池信息 ret = GetBatteryInfoFromMES(this.rfidUID, ref reStr, ref singleSNCollect); if (ret != 0) { currentTaskDescribe = this.rfidUID + "装载错误 " + reStr; if (this.db1ValsToSnd[0] != 5 && this.db1ValsToSnd[0] != 4) { this.logRecorder.AddDebugLog(nodeName, currentTaskDescribe); } if (ret == 1) { this.db1ValsToSnd[0] = 5; } else if (ret == 2) { this.db1ValsToSnd[0] = 4; } break; } } currentTaskDescribe = this.rfidUID + "装载,从MES中获取电芯信息完成"; this.logRecorder.AddDebugLog(nodeName, "从MES中获取电芯信息完成"); // 将信息放入到OnLine数据库 bool insertFlag = InsertToDB(singleSNCollect); if (insertFlag == false) { this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "数据库更新失败"); currentTaskDescribe = this.rfidUID + "装载,数据库更新失败"; break; } AddProduceRecord(this.rfidUID, this.mesProcessStepID[0]); this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.db1ValsToSnd[0] = 2; this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "等待完成信号复位"); break; } case 4: { currentTaskDescribe = this.rfidUID + "装载,等待完成信号复位"; if (this.db2Vals[1] != 1) { break; } currentTaskDescribe = this.rfidUID + "装载,DB1信号复位"; this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "DB1信号复位"); // 需将读卡请求复位START this.db1ValsToSnd[0] = 1; this.db1ValsToSnd[1] = 1; // 将读卡请求复位END this.currentTask.FinishTime = System.DateTime.Now; this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString(); this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; currentTaskPhase = 0; this.logRecorder.AddDebugLog(nodeName, "等待执行下一个任务"); currentTaskDescribe = "等待执行下一个任务"; //等待扫码完成 break; } default: break; } return(true); }
public override bool ExeBusiness(ref string reStr) { if (!nodeEnabled) { return(true); } // 查看此节点是否有任务在执行或排队 if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } //if (db2Vals[0] != 2) //{ // db1ValsToSnd[0] = 1; // db1ValsToSnd[1] = 1; //} //任务撤销 if (db2Vals[1] == 3) { if (this.currentTask != null && this.currentTaskPhase > 0) { this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.任务撤销.ToString(); this.currentTask.FinishTime = System.DateTime.Now; ctlTaskBll.Update(this.currentTask); this.logRecorder.AddDebugLog(this.nodeName, "卸载任务撤销"); currentTaskDescribe = "卸载任务撤销"; this.currentTask = null; this.currentTaskPhase = 0; } //Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count()); db1ValsToSnd[0] = 1; db1ValsToSnd[1] = 2; return(true); } if (!FillTaskRequire(ref reStr)) { return(false); } if (this.currentTask == null) { return(true); } switch (this.currentTaskPhase) { case 1: { currentTaskDescribe = this.rfidUID + "开始执行卸载任务,RFID上报MES系统"; //将RFID上报MES系统 if (!SysCfg.SysCfgModel.SimMode) { if (mesenable != 0) { if (!MESWCFManage.Inst().ReturnRFIDA(this.rfidUID)) { if (reportFlag == 0) { this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "读到托盘号后,RFID上报MES系统失败"); reportFlag = 1; } break; } } } reportFlag = 0; this.db1ValsToSnd[0] = 2; this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "等待参数写入...."); break; } case 2: { currentTaskDescribe = this.rfidUID + "卸载等待参数写入"; // ADD if (!SysCfg.SysCfgModel.SimMode) { //将参数写入到PLC中 START if (!WriteDataToPLC(this.rfidUID)) { return(false); } // 将参数写入到PLC中 END } this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "参数写入完成,等待卸载完成..."); currentTaskDescribe = this.rfidUID + "参数写入完成"; this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 3: { currentTaskDescribe = this.rfidUID + "卸载中,等待完成...."; // 等待卸载完成 if (this.db2Vals[1] != 2) { break; } // 参数写入完成后 就需将读卡请求复位START this.db1ValsToSnd[0] = 2; // 参数写入完成后 就需将读卡请求复位END //更新OnLine数据库 START // 完成卸载 ,从OnLine 数据库中 解绑 if (!productOnlineBll.UnbindPallet(this.rfidUID, ref reStr)) { this.logRecorder.AddDebugLog(nodeName, this.rfidUID + " " + reStr); return(false); } // 更新OnLine数据库 END // 卸载完成置2,其他所有数据复位 START Array.Clear(db1ValsToSnd, 0, db1ValsToSnd.Count()); db1ValsToSnd[1] = 2; // 卸载完成置2,其他所有数据复位 END this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.logRecorder.AddDebugLog(nodeName, this.rfidUID + "更新数据库成功,等待卸载完成信号复位"); break; } case 4: { currentTaskDescribe = this.rfidUID + "等待卸载完成信号复位"; // 等待卸载完成 if (this.db2Vals[1] != 1) { break; } //收到卸载完成信号复位时,把卸载处理完成信号复位START db1ValsToSnd[1] = 1; db1ValsToSnd[0] = 1; //收到卸载完成信号复位时,把卸载处理完成信号复位END this.currentTask.TaskStatus = SysCfg.EnumTaskStatus.已完成.ToString(); this.currentTask.FinishTime = System.DateTime.Now; this.ctlTaskBll.Update(this.currentTask); this.currentTask = null; currentTaskPhase = 0; this.logRecorder.AddDebugLog(nodeName, "等待执行下一个任务"); currentTaskDescribe = "等待执行下一个任务"; break; } default: break; } return(true); }