private bool GetWeldStr(DBAccess.Model.BatteryModuleModel currMod, ref string weldStr, ref string restr) { try { //StringBuilder strBuild = new StringBuilder(); string str = string.Format("{0},{1},", currMod.tag2.Trim(), this.rfidUID); str += currMod.batModuleID; //foreach (DBAccess.Model.BatteryModuleModel mod in modList) //{ // if (mod.tag2.Trim() == modPosIndex) // { // str += mod.batModuleID; // break; // } //} //strBuild.AppendLine(str); weldStr = str; return(true); } catch (Exception ex) { restr = ex.Message; return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DBAccess.Model.BatteryModuleModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BatteryModule("); strSql.Append("batModuleID,batchName,asmTime,curProcessStage,batPackID,topcapOPWorkerID,downcapOPWorkerID,palletID,palletBinded,topcapWelderID,bottomcapWelderID,checkResult,tag1,tag2,tag3,tag4,tag5)"); strSql.Append(" values ("); strSql.Append("@batModuleID,@batchName,@asmTime,@curProcessStage,@batPackID,@topcapOPWorkerID,@downcapOPWorkerID,@palletID,@palletBinded,@topcapWelderID,@bottomcapWelderID,@checkResult,@tag1,@tag2,@tag3,@tag4,@tag5)"); SqlParameter[] parameters = { new SqlParameter("@batModuleID", SqlDbType.NVarChar, 50), new SqlParameter("@batchName", SqlDbType.NVarChar, 50), new SqlParameter("@asmTime", SqlDbType.DateTime), new SqlParameter("@curProcessStage", SqlDbType.NVarChar, 50), new SqlParameter("@batPackID", SqlDbType.NVarChar, 50), new SqlParameter("@topcapOPWorkerID", SqlDbType.NVarChar, 50), new SqlParameter("@downcapOPWorkerID", SqlDbType.NVarChar, 50), new SqlParameter("@palletID", SqlDbType.NVarChar, 50), new SqlParameter("@palletBinded", SqlDbType.Bit, 1), new SqlParameter("@topcapWelderID", SqlDbType.Int, 4), new SqlParameter("@bottomcapWelderID", SqlDbType.Int, 4), new SqlParameter("@checkResult", SqlDbType.Int, 4), new SqlParameter("@tag1", SqlDbType.NVarChar, 255), new SqlParameter("@tag2", SqlDbType.NVarChar, 255), new SqlParameter("@tag3", SqlDbType.NVarChar, 255), new SqlParameter("@tag4", SqlDbType.NVarChar, 255), new SqlParameter("@tag5", SqlDbType.NVarChar, 255) }; parameters[0].Value = model.batModuleID; parameters[1].Value = model.batchName; parameters[2].Value = model.asmTime; parameters[3].Value = model.curProcessStage; parameters[4].Value = model.batPackID; parameters[5].Value = model.topcapOPWorkerID; parameters[6].Value = model.downcapOPWorkerID; parameters[7].Value = model.palletID; parameters[8].Value = model.palletBinded; parameters[9].Value = model.topcapWelderID; parameters[10].Value = model.bottomcapWelderID; parameters[11].Value = model.checkResult; parameters[12].Value = model.tag1; parameters[13].Value = model.tag2; parameters[14].Value = model.tag3; parameters[15].Value = model.tag4; parameters[16].Value = model.tag5; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DBAccess.Model.BatteryModuleModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BatteryModule set "); strSql.Append("batchName=@batchName,"); strSql.Append("asmTime=@asmTime,"); strSql.Append("curProcessStage=@curProcessStage,"); strSql.Append("batPackID=@batPackID,"); strSql.Append("topcapOPWorkerID=@topcapOPWorkerID,"); strSql.Append("downcapOPWorkerID=@downcapOPWorkerID,"); strSql.Append("palletID=@palletID,"); strSql.Append("palletBinded=@palletBinded,"); strSql.Append("topcapWelderID=@topcapWelderID,"); strSql.Append("bottomcapWelderID=@bottomcapWelderID,"); strSql.Append("checkResult=@checkResult"); strSql.Append(" where batModuleID=@batModuleID "); SqlParameter[] parameters = { new SqlParameter("@batchName", SqlDbType.NVarChar, 50), new SqlParameter("@asmTime", SqlDbType.DateTime), new SqlParameter("@curProcessStage", SqlDbType.NVarChar, 50), new SqlParameter("@batPackID", SqlDbType.NVarChar, 50), new SqlParameter("@topcapOPWorkerID", SqlDbType.NVarChar, 50), new SqlParameter("@downcapOPWorkerID", SqlDbType.NVarChar, 50), new SqlParameter("@palletID", SqlDbType.NVarChar, 50), new SqlParameter("@palletBinded", SqlDbType.Bit, 1), new SqlParameter("@topcapWelderID", SqlDbType.Int, 4), new SqlParameter("@bottomcapWelderID", SqlDbType.Int, 4), new SqlParameter("@checkResult", SqlDbType.Int, 4), new SqlParameter("@batModuleID", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.batchName; parameters[1].Value = model.asmTime; parameters[2].Value = model.curProcessStage; parameters[3].Value = model.batPackID; parameters[4].Value = model.topcapOPWorkerID; parameters[5].Value = model.downcapOPWorkerID; parameters[6].Value = model.palletID; parameters[7].Value = model.palletBinded; parameters[8].Value = model.topcapWelderID; parameters[9].Value = model.bottomcapWelderID; parameters[10].Value = model.checkResult; parameters[11].Value = model.batModuleID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void button1_Click(object sender, EventArgs e) { BatteryModuleBll modBll = new BatteryModuleBll(); DBAccess.Model.BatteryModuleModel model = modBll.GetModelByPalletIDAndTag2("AA080000", "2", "A线模组-工装板绑定"); if (model != null) { MessageBox.Show("model != null"); } }
private void OnModifyMod() { DBAccess.BLL.BatteryModuleBll modBll = new DBAccess.BLL.BatteryModuleBll(); DBAccess.Model.BatteryModuleModel mod = modBll.GetModel(this.textBoxMod.Text); if (mod == null) { MessageBox.Show(string.Format("模块{0}不存在", this.textBoxMod.Text)); return; } int switchLineNo = int.Parse(this.cbxSwitchLine.Text); string[] modExistArray = GetSwitchLineMods(switchLineNo); string modSel = this.listBoxMod.SelectedItem.ToString(); List <string> modList = new List <string>(modExistArray); }
private void OnAddMod() { string strModtoAdd = this.textBoxMod.Text; if (string.IsNullOrWhiteSpace(strModtoAdd)) { return; } DBAccess.BLL.BatteryModuleBll modBll = new DBAccess.BLL.BatteryModuleBll(); DBAccess.Model.BatteryModuleModel mod = modBll.GetModel(strModtoAdd); if (mod == null) { MessageBox.Show(string.Format("模块{0}不存在", strModtoAdd)); return; } int switchLineNo = int.Parse(this.cbxSwitchLine.Text); string[] modExistArray = GetSwitchLineMods(switchLineNo); List <string> modList = new List <string>(modExistArray); if (modList.Contains(strModtoAdd)) { MessageBox.Show(string.Format("模块{0}已经在分档线{1}", strModtoAdd, switchLineNo)); return; } int insertPos = 0; if (this.listBoxMod.SelectedItem != null) { insertPos = this.listBoxMod.SelectedIndex + 1; modList.Insert(insertPos, strModtoAdd); } else { modList.Add(strModtoAdd); } if (UpdateSwitchLineMods(switchLineNo, modList.ToArray())) { MessageBox.Show("增加模块成功"); } else { MessageBox.Show("增加模块失败"); } }
private bool CompleteDescRecord(DBAccess.Model.BatteryModuleModel modBattery, ref string restr) { try { string testResultPath = string.Format(@"\\{0}\MESReport\PullTestResult\{1}_{2}.csv", welderIP, modBattery.palletID, modBattery.batModuleID); if (!System.IO.File.Exists(testResultPath)) { currentTaskDescribe = string.Format(this.nodeName + "铝丝焊结果文件:{0}不存在", testResultPath); return(false); } DataTable dt = CSVFileHelper.OpenCSV(testResultPath); string checkRes = ""; for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j]["Traceability - integrated pull test - passed"].ToString().ToUpper() == "FALSE") { checkRes = "NG"; break; } } if (checkRes == "NG") { modBattery.checkResult = 2; modBattery.palletBinded = false; modBattery.tag3 = this.nodeName; //标识在哪个工位产生的NG,(共有三个工位,1#铝丝焊、2#铝丝焊、DCIR检测) } else { modBattery.checkResult = 1; } modBll.Update(modBattery); return(true); } catch (Exception ex) { restr = ex.Message; return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DBAccess.Model.BatteryModuleModel GetModel(string batModuleID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 batModuleID,batchName,asmTime,curProcessStage,batPackID,topcapOPWorkerID,downcapOPWorkerID,palletID,palletBinded,topcapWelderID,bottomcapWelderID,checkResult,tag1,tag2,tag3,tag4,tag5 from BatteryModule "); strSql.Append(" where batModuleID=@batModuleID "); SqlParameter[] parameters = { new SqlParameter("@batModuleID", SqlDbType.NVarChar, 50) }; parameters[0].Value = batModuleID; DBAccess.Model.BatteryModuleModel model = new DBAccess.Model.BatteryModuleModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DBAccess.Model.BatteryModuleModel DataRowToModel(DataRow row) { DBAccess.Model.BatteryModuleModel model = new DBAccess.Model.BatteryModuleModel(); if (row != null) { if (row["batModuleID"] != null) { model.batModuleID = row["batModuleID"].ToString(); } if (row["batchName"] != null) { model.batchName = row["batchName"].ToString(); } if (row["asmTime"] != null && row["asmTime"].ToString() != "") { model.asmTime = DateTime.Parse(row["asmTime"].ToString()); } if (row["curProcessStage"] != null) { model.curProcessStage = row["curProcessStage"].ToString(); } if (row["batPackID"] != null) { model.batPackID = row["batPackID"].ToString(); } if (row["topcapOPWorkerID"] != null) { model.topcapOPWorkerID = row["topcapOPWorkerID"].ToString(); } if (row["downcapOPWorkerID"] != null) { model.downcapOPWorkerID = row["downcapOPWorkerID"].ToString(); } if (row["palletID"] != null) { model.palletID = row["palletID"].ToString(); } if (row["palletBinded"] != null && row["palletBinded"].ToString() != "") { if ((row["palletBinded"].ToString() == "1") || (row["palletBinded"].ToString().ToLower() == "true")) { model.palletBinded = true; } else { model.palletBinded = false; } } if (row["topcapWelderID"] != null && row["topcapWelderID"].ToString() != "") { model.topcapWelderID = int.Parse(row["topcapWelderID"].ToString()); } if (row["bottomcapWelderID"] != null && row["bottomcapWelderID"].ToString() != "") { model.bottomcapWelderID = int.Parse(row["bottomcapWelderID"].ToString()); } if (row["checkResult"] != null && row["checkResult"].ToString() != "") { model.checkResult = int.Parse(row["checkResult"].ToString()); } if (row["tag1"] != null) { model.tag1 = row["tag1"].ToString(); } if (row["tag2"] != null) { model.tag2 = row["tag2"].ToString(); } if (row["tag3"] != null) { model.tag3 = row["tag3"].ToString(); } if (row["tag4"] != null) { model.tag4 = row["tag4"].ToString(); } if (row["tag5"] != null) { model.tag5 = row["tag5"].ToString(); } } return(model); }
public int UploadMesScrewData(string rfid, string moduCode, ref string reStr) { try { string M_AREA = "Y001"; string M_WORKSTATION_SN = "Y00102201"; string M_DEVICE_SN = ""; string M_UNION_SN = ""; string M_CONTAINER_SN = ""; string M_LEVEL = ""; string M_ITEMVALUE = ""; RootObject rObj = new RootObject(); DBAccess.Model.BatteryModuleModel battery = modBll.GetModel(moduCode); if (battery == null) { reStr = "没有:" + moduCode + "模块"; return(2); } MTDBAccess.Model.dbModel screwModel = blldb.GetModel(moduCode);//获取码头数据 if (screwModel == null) { reStr = this.nodeName + "获取码头拧螺丝数据失败!"; return(2); } //M_LEVEL = battery.tag1; string barcode = battery.batModuleID; M_ITEMVALUE = "正螺丝1扭矩:" + screwModel.正螺丝1马头扭矩 + ":Nm|" + "反螺丝1扭矩:" + screwModel.反螺丝1马头扭矩 + ":Nm|正螺丝2扭矩:" + screwModel.正螺丝2马头扭矩 + ":Nm|" + "反螺丝2扭矩:" + screwModel.反螺丝2马头扭矩 + ":Nm|正螺丝1角度:" + screwModel.正螺丝1马头角度 + ":°|反螺丝1角度:" + screwModel.反螺丝1马头角度 + ":°|正螺丝2角度:" + screwModel.正螺丝2马头角度 + ":°|反螺丝2角度:" + screwModel.反螺丝2马头角度 + ":°";//需要拼接螺丝数据 string strJson = ""; rObj = DevDataUpload(3, M_DEVICE_SN, M_WORKSTATION_SN, barcode, M_UNION_SN, M_CONTAINER_SN, M_LEVEL, M_ITEMVALUE, ref strJson); reStr = rObj.RES; if (rObj.RES.ToUpper().Contains("OK")) { reStr += M_ITEMVALUE; //logRecorder.AddDebugLog(nodeName, string.Format("上传螺丝数据失败:{0}", M_ITEMVALUE) + "-" + rObj.RES); return(0); } else if (rObj.RES.ToUpper().Contains("NG")) { return(1); } else { logRecorder.AddDebugLog(nodeName, string.Format("上传螺丝数据失败:{0}", M_ITEMVALUE + "-" + rObj.RES)); return(2); } } catch (Exception ex) { reStr += ex.Message; return(2); } }
private bool ExeBind(ref string reStr) { if (!devStatusRestore) { devStatusRestore = DevStatusRestore(); } if (!devStatusRestore) { return(false); } if (this.rfidRWList != null && this.rfidRWList.Count() > 0) { this.rfidRW = this.rfidRWList[0]; //临时 } if (db2Vals[1] == 1) { if (this.currentTask != null) { //查询未执行完任务,清掉 if (!ctlTaskBll.ClearTask(string.Format("DeviceID='{0}'", this.nodeID))) { logRecorder.AddDebugLog(nodeName, "清理任务失败"); return(false); } this.currentTask = null; this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.ProductBarcode = ""; this.currentStat.StatDescribe = "设备空闲"; checkFinished = false; currentTaskDescribe = "等待有板信号"; } currentTaskPhase = 0; db1ValsToSnd[3] = 1; db1ValsToSnd[4] = 1; this.rfidUID = string.Empty; //if (!SysCfgModel.SimMode) //{ // (this.rfidRW as DevAccess.RfidCF).ClearBufUID(); //} this.currentStat.Status = EnumNodeStatus.设备空闲; this.currentStat.StatDescribe = "工位空闲"; currentTaskDescribe = ""; return(true); } if (db2Vals[1] == 2) { if (currentTaskPhase == 0) { db1ValsToSnd[3] = 1; db1ValsToSnd[4] = 1; currentTaskPhase = 1; this.currentStat.Status = EnumNodeStatus.设备使用中; this.currentStat.StatDescribe = "工作中"; ControlTaskModel task = new ControlTaskModel(); task.TaskID = System.Guid.NewGuid().ToString("N"); task.TaskParam = string.Empty; task.TaskPhase = 1; task.CreateTime = System.DateTime.Now; task.DeviceID = this.nodeID; task.CreateMode = "自动"; task.TaskStatus = EnumTaskStatus.执行中.ToString(); ctlTaskBll.Add(task); this.currentTask = task; } } //int bindCount = modPalletMax; //this.db1ValsToSnd[2] = (short)modPalletMax; //this.db1ValsToSnd[2] = (short)bindCount; switch (currentTaskPhase) { case 1: { currentTaskDescribe = "开始读RFID"; if (!RfidReadC()) { break; } if (SysCfgModel.SimMode == false) { if (ModuleCodeRequire(ref this.mesReqGroupCode, ref reStr) == false) { Console.WriteLine(this.nodeName + "请求模组二维码失败!" + reStr); break; } else { this.logRecorder.AddDebugLog(this.nodeName, "请求模组二维码成功!" + this.mesReqGroupCode); this.TxtLogRecorder.WriteLog("请求模组二维码成功!" + this.mesReqGroupCode); } //bindCount = 2;//现场条码不正确 //mesReqGroupCode = "123456789202345678988043"; } else { //bindCountGlobal = 4; mesReqGroupCode = "04GPE3VB150E118530000002"; } currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 2: { //int bindCount = 0; if (this.swithBarcode == "") { currentTaskDescribe = "模块二位码没有扫码!"; break; } currentTaskDescribe = "计算工装板绑定模块数量!"; if (SysCfgModel.SimMode == false) { if (CalcuBindCount(mesReqGroupCode, this.swithBarcode, ref this.bindCountGlobal, ref reStr) == false) { currentTaskDescribe = "带绑定模块数量计算错误!" + reStr; return(false); } } else { bindCountGlobal = 2; } this.swithBarcode = ""; this.db1ValsToSnd[2] = (short)bindCountGlobal; //this.db1ValsToSnd[2] = (short)modPalletMax;//测试版本 this.plcRW2.WriteDB("D8500", (short)bindCountGlobal); currentTaskPhase++; this.currentTask.TaskParam = rfidUID; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); logRecorder.AddDebugLog(nodeName, string.Format("读到RFID:{0},开始绑定", this.rfidUID)); this.TxtLogRecorder.WriteLog(string.Format("读到RFID:{0},开始绑定", this.rfidUID)); break; } case 3: { #region 原来绑定流程 //short groupSeq = this.db2Vals[3]; //plNodeModel = plNodeBll.GetModel(nodeID); //List<string> mods = new List<string>(); //switch (groupSeq) //{ // case 1: // { // string[] strArray = plNodeModel.tag1.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); // if (strArray != null && strArray.Count() > 0) // { // mods.AddRange(strArray); // } // break; // } // case 2: // { // string[] strArray = plNodeModel.tag2.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); // if (strArray != null && strArray.Count() > 0) // { // mods.AddRange(strArray); // } // break; // } // case 3: // { // string[] strArray = plNodeModel.tag3.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); // if (strArray != null && strArray.Count() > 0) // { // mods.AddRange(strArray); // } // break; // } // case 4: // { // string[] strArray = plNodeModel.tag4.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); // if (strArray != null && strArray.Count() > 0) // { // mods.AddRange(strArray); // } // break; // } // default: // break; //} #endregion currentTaskDescribe = "扫码中,计划扫码个数:" + bindCountGlobal + ",当前扫码计数:第" + this.qrList.Count() + "个!"; int rqRequire = 0; if (this.plcRW2.ReadDB("D3004", ref rqRequire) == false) //有第二个扫码请求 { break; } NodeDB2Commit(4, (short)rqRequire, ref reStr); if (rqRequire != 1) //有第二个扫码请求 { break; } //扫码请求 string barcode = ""; if (SysCfgModel.SimMode) { barcode = this.SimBarcode; } else { barcode = barcodeRW2.ReadBarcode(); } if (string.IsNullOrWhiteSpace(barcode) == true) { this.readCodeTimes++; if (this.readCodeTimes > 4) { if (this.plcRW2.WriteDB("D3004", 3) == false) { break; } NodeDB2Commit(4, 3, ref reStr); this.readCodeTimes = 0; } break; } if (this.plcRW2.WriteDB("D3004", 2) == false) { break; } NodeDB2Commit(4, 2, ref reStr); this.qrList.Add(barcode); if (this.qrList.Count != bindCountGlobal) { break; } if (this.qrList.Count() < 1) { this.db1ValsToSnd[4] = 3; //this.currentTaskDescribe = string.Format("分档位:{0} 可供绑定的模块为空,", groupSeq); break; } this.currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); break; } case 4: { currentTaskDescribe = "绑定中!"; //绑定 //TryUnbind(this.rfidUID, ref reStr); AddPack(this.mesReqGroupCode, ref reStr); for (int i = 0; i < Math.Min(this.qrList.Count(), modPalletMax); i++) { string modID = this.qrList[i]; DBAccess.Model.BatteryModuleModel mod = modBll.GetModel(modID); if (mod == null) { mod = new DBAccess.Model.BatteryModuleModel(); mod.batModuleID = modID; mod.palletID = this.rfidUID; mod.palletBinded = true; mod.checkResult = 1; mod.batPackID = this.mesReqGroupCode; mod.curProcessStage = nodeName; mod.asmTime = System.DateTime.Now; mod.tag1 = this.db2Vals[3].ToString(); modBll.Add(mod); } else { mod.checkResult = 1; mod.palletBinded = true; mod.palletID = this.rfidUID; mod.curProcessStage = nodeName; mod.batPackID = this.mesReqGroupCode; modBll.Update(mod); } this.currentTaskDescribe = string.Format("绑定,RFID:{0},模块条码:{1}", rfidUID, modID); logRecorder.AddDebugLog(nodeName, string.Format("绑定,RFID:{0},模块条码:{1}", rfidUID, modID)); AddProcessRecord(mod.batModuleID, "模块", "追溯记录", string.Format("绑定,RFID:{0},模块条码:{1}", rfidUID, modID), ""); //AddProcessRecord(mod.batModuleID, this.nodeName, ""); } int removeSum = Math.Min(this.qrList.Count(), modPalletMax); this.qrList.RemoveRange(0, removeSum); //string strMods = ""; //for (int i = 0; i < this.qrList.Count(); i++) //{ // strMods += (this.qrList[i] + ","); //} //switch (groupSeq) //{ // case 1: // { // plNodeModel.tag1 = strMods; // break; // } // case 2: // { // plNodeModel.tag2 = strMods; // break; // } // case 3: // { // plNodeModel.tag3 = strMods; // break; // } // case 4: // { // plNodeModel.tag4 = strMods; // break; // } // default: // break; //} //plNodeBll.Update(plNodeModel); if (this.db2Vals[2] != 2) { break; } if (this.db2Vals[3] < 1 || this.db2Vals[3] > 4) { break; } currentTaskPhase++; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.TxtLogRecorder.WriteLog("工装板数据绑定完成!"); currentTaskDescribe = "绑定完成!"; break; } case 5: { #region MES绑定数据 currentTaskDescribe = "开始上传MES绑定数据!"; string restr = ""; int uploadStatus = UploadDataToMes(2, "M00100101", this.rfidUID, ref restr); if (uploadStatus == 0) //OK { this.logRecorder.AddDebugLog(this.nodeName, "上传MES数据成功:" + restr); } else if (uploadStatus == 1) //NG { this.logRecorder.AddDebugLog(this.nodeName, "上传MES数据成功,返回NG:" + restr); } else { this.logRecorder.AddDebugLog(this.nodeName, "上传MES数据失败:" + restr); //需要重复上传 break; } this.TxtLogRecorder.WriteLog("上传MES数据:工装板号" + this.rfidUID); #endregion currentTaskPhase++; this.db1ValsToSnd[4] = 2; this.currentTask.TaskPhase = this.currentTaskPhase; this.ctlTaskBll.Update(this.currentTask); this.plNodeModel.tag1 = ""; this.plNodeModel.tag2 = ""; this.plNodeModel.tag3 = ""; this.plNodeModel.tag4 = ""; this.plNodeBll.Update(this.plNodeModel); break; } case 6: { currentTaskDescribe = "流程完成"; this.db1ValsToSnd[2] = 0; this.mesReqGroupCode = ""; this.currentTask.TaskPhase = this.currentTaskPhase; this.currentTask.TaskStatus = EnumTaskStatus.已完成.ToString(); this.ctlTaskBll.Update(this.currentTask); this.TxtLogRecorder.WriteLog("工位流程处理完成!"); break; } default: break; } return(true); }
private void ExeSwitch() { string reStr = ""; if (db2Vals[0] == 0) { this.db1ValsToSnd[0] = 0; this.db1ValsToSnd[1] = 0; } if (db2Vals[0] != 1) { return; } //扫码请求 string barcode = ""; if (SysCfgModel.SimMode) { barcode = this.SimBarcode; this.swithBarcode = barcode; } else { barcode = barcodeRW.ReadBarcode(); this.swithBarcode = barcode; } if (string.IsNullOrWhiteSpace(barcode)) { if (this.db1ValsToSnd[0] != 2) { logRecorder.AddDebugLog(nodeName, "读条码失败"); } this.db1ValsToSnd[0] = 2; return; } else { Console.WriteLine(this.nodeName + "读取条码成功:" + barcode); this.TxtLogRecorder.WriteLog("读取条码成功:" + barcode); } DBAccess.Model.BatteryModuleModel mod = modBll.GetModel(barcode); if (mod == null) { if (this.db1ValsToSnd[0] != 3) { LogRecorder.AddDebugLog(nodeName, string.Format("条码{0},产品信息不存在", barcode)); } this.db1ValsToSnd[0] = 3; return; } //分档信息不为数字为字符串,目前测试AAA为1档位 //string pattern = @"^[0-9]*$"; //数字正则 //if (!System.Text.RegularExpressions.Regex.IsMatch(mod.tag1, pattern)) //{ // if (this.db1ValsToSnd[1]!=0) // { // logRecorder.AddDebugLog(nodeName, string.Format("分档字符串:{0}错误,要求为数字,", mod.tag1)); // } // this.db1ValsToSnd[1] = 0; // return; //} //PLNodesBll plNodesBll = new PLNodesBll(); //plNodeModel = plNodesBll.GetModel(this.nodeID); short groupSeq = 0; if (short.TryParse(mod.tag5, out groupSeq) == false) { Console.WriteLine(this.nodeName + "分档信息有误:" + mod.tag5 + ",无法转换为数字!"); return; } //short groupSeq = 1;//测试默认为1档位 bool isNg = false; if (switchUploadMes == false)//保证只传一次 { if (UploadMesLogic(groupSeq, barcode, ref isNg, ref reStr) == false) { return; } switchUploadMes = true; } if (isNg == true)//NG处理 { if (this.plcRW.WriteDB("D9000", 2) == false) { return; } if (this.plcRW2.WriteDB("D9000", 2) == false) { return; } if (!NodeDB2Commit(0, 2, ref reStr))//流程结束 { logRecorder.AddDebugLog(nodeName, "发送PLC数据失败"); } LogRecorder.AddDebugLog(nodeName, "模块二维码:" + barcode + ",MES分析NG,线体服务器流程处理结束!"); return; } else { if (this.plcRW.WriteDB("D9000", 1) == false) { return; } if (this.plcRW2.WriteDB("D9000", 1) == false) { return; } } this.db1ValsToSnd[0] = 1; this.db1ValsToSnd[1] = groupSeq; Console.WriteLine(this.nodeName, 11); switch (groupSeq) { case 1: { string[] modExistArray = plNodeModel.tag1.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (modExistArray != null && modExistArray.Count() > modPalletMax) { this.db1ValsToSnd[0] = 4; this.currentTaskDescribe = string.Format("档位{0}已满,最大允许数量,目前数量{1}", groupSeq, modPalletMax); return; } if (!plNodeModel.tag1.ToUpper().Contains(barcode.ToUpper())) { plNodeModel.tag1 = plNodeModel.tag1 + barcode + ","; LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); this.TxtLogRecorder.WriteLog(string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); } else { LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档缓存数据已经存在,分档完成,档位:{1}", barcode, mod.tag1)); } break; } case 2: { string[] modExistArray = plNodeModel.tag2.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (modExistArray != null && modExistArray.Count() > modPalletMax) { this.db1ValsToSnd[0] = 4; this.currentTaskDescribe = string.Format("档位{0}已满,最大允许数量,目前数量{1}", groupSeq, modPalletMax); return; } if (!plNodeModel.tag2.ToUpper().Contains(barcode.ToUpper())) { plNodeModel.tag2 = plNodeModel.tag2 + barcode + ","; LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); this.TxtLogRecorder.WriteLog(string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); } else { LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档缓存数据已经存在,分档完成,档位:{1}", barcode, mod.tag1)); } break; } case 3: { string[] modExistArray = plNodeModel.tag3.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (modExistArray != null && modExistArray.Count() > modPalletMax) { this.db1ValsToSnd[0] = 4; this.currentTaskDescribe = string.Format("档位{0}已满,最大允许数量,目前数量{1}", groupSeq, modPalletMax); return; } if (!plNodeModel.tag3.ToUpper().Contains(barcode.ToUpper())) { plNodeModel.tag3 = plNodeModel.tag3 + barcode + ","; LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); this.TxtLogRecorder.WriteLog(string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); } else { LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档缓存数据已经存在,分档完成,档位:{1}", barcode, mod.tag1)); } break; } case 4: { string[] modExistArray = plNodeModel.tag4.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (modExistArray != null && modExistArray.Count() > modPalletMax) { this.db1ValsToSnd[0] = 4; this.currentTaskDescribe = string.Format("档位{0}已满,最大允许数量,目前数量{1}", groupSeq, modPalletMax); return; } if (!plNodeModel.tag4.ToUpper().Contains(barcode.ToUpper())) { plNodeModel.tag4 = plNodeModel.tag4 + barcode + ","; LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); this.TxtLogRecorder.WriteLog(string.Format("模块:{0}分档完成,档位:{1}", barcode, mod.tag1)); } else { LogRecorder.AddDebugLog(nodeName, string.Format("模块:{0}分档缓存数据已经存在,分档完成,档位:{1}", barcode, mod.tag1)); } break; } default: break; } plNodeBll.Update(plNodeModel); if (!NodeDB2Commit(0, 2, ref reStr)) { logRecorder.AddDebugLog(nodeName, "发送PLC数据失败"); } switchUploadMes = false; //else //{ // Console.WriteLine("扫码完成信号写入2"); //} }
private void UploadBatteryModToMes(object objModBattery) { try { DBAccess.Model.BatteryModuleModel modBattery = objModBattery as DBAccess.Model.BatteryModuleModel; string M_WORKSTATION_SN = ""; if (this.nodeID == "OPB004") { M_WORKSTATION_SN = "Y00101701"; } else { M_WORKSTATION_SN = "Y00102001"; } if (modBattery.palletBinded == false && modBattery.tag3 != null && modBattery.tag3 != this.nodeName) { string restr = this.nodeName + ":模块没有绑定!"; logRecorder.AddDebugLog(nodeName, string.Format("焊接完成反馈数据处理失败:{0}", restr)); return; } string testResultPath = string.Format(@"\\{0}\MESReport\BondParameters\{1}_{2}.csv", welderIP, modBattery.palletID, modBattery.batModuleID); if (!System.IO.File.Exists(testResultPath)) { string restr = string.Format(this.nodeName + "铝丝焊参数文件:{0}不存在", testResultPath); logRecorder.AddDebugLog(nodeName, string.Format("焊接完成反馈数据处理失败:{0}", restr)); return; } DataTable dt = CSVFileHelper.OpenCSV(testResultPath); string pullTestPath = string.Format(@"\\{0}\MESReport\PullTestResult\{1}_{2}.csv", welderIP, modBattery.palletID, modBattery.batModuleID); if (!System.IO.File.Exists(pullTestPath)) { string restr = string.Format(this.nodeName + "铝丝焊拉力结果参数文件:{0}不存在", testResultPath); logRecorder.AddDebugLog(nodeName, string.Format("焊接完成反馈数据处理失败:{0}", restr)); return; } DataTable dtPull = CSVFileHelper.OpenCSV(pullTestPath); int M_FLAG = 3; string M_DEVICE_SN = ""; string M_SN = modBattery.batModuleID; string M_UNION_SN = ""; string M_CONTAINER_SN = ""; string M_LEVEL = ""; string M_ITEMVALUE = GetItemVal(dt, dtPull); //上传数据 RootObject rObj = new RootObject(); string strJson = ""; rObj = DevDataUpload(M_FLAG, M_DEVICE_SN, M_WORKSTATION_SN, M_SN, M_UNION_SN, M_CONTAINER_SN, M_LEVEL, M_ITEMVALUE, ref strJson); currentTaskDescribe = rObj.RES + "," + M_FLAG + "," + M_WORKSTATION_SN + "," + M_ITEMVALUE + this.nodeName + rObj.CONTROL_TYPE; Console.WriteLine(rObj.RES); Console.WriteLine(M_ITEMVALUE); if (rObj.RES.ToUpper().Contains("NG")) //返回NG处理 { modBattery.checkResult = 2; //NG处理 modBattery.palletBinded = false; //NG要解绑 modBll.Update(modBattery); } logRecorder.AddDebugLog(nodeName, "上传mes数据:" + M_ITEMVALUE); this.WriteTxtLog(modBattery.batModuleID, "上传mes数据:" + M_ITEMVALUE + "返回结果:" + rObj.RES); logRecorder.AddDebugLog(nodeName, string.Format("上传MES,返回结果:{0}", rObj.RES)); } catch (Exception ex) { logRecorder.AddDebugLog(nodeName, string.Format("上传MES错误:{0}", ex.Message)); } }
private void ModuleWeldBuiness(List <DBAccess.Model.BatteryModuleModel> modList, ref bool isAllComplete) { string weldStr = ""; string reStr = ""; Console.WriteLine("weld当前步骤:" + stepIndex); switch (stepIndex) { case 1: { currWorkMod = null; Console.WriteLine("weld1"); //tag3:SENDED记录数据已发送至焊机,COMPLETE为加工完成 string welderSndFile = string.Format(@"\\{0}\MESReport\DeviceInfoLane{1}.txt", welderIP, channelIndex); // @"\\192.168.0.45\MESReport\DeviceInfoLane1.txt"; if (!System.IO.File.Exists(welderSndFile)) { currentTaskDescribe = string.Format("铝丝焊文件:{0}不存在", welderSndFile); return; } Console.WriteLine("weld2"); for (int i = 0; i < modList.Count; i++) { if (modList[i].tag4.ToUpper() == ENUMWeldStatus.SENDED.ToString() || modList[i].tag4.ToUpper() == ENUMWeldStatus.COMPLETE.ToString()) { continue; } currWorkMod = modList[i]; Console.WriteLine("weld66"); if (GetWeldStr(currWorkMod, ref weldStr, ref reStr) == false) { logRecorder.AddDebugLog(nodeName, string.Format("获取模块焊接加工数据失败:{0}", reStr)); continue; } break; } Console.WriteLine("weld3"); if (currWorkMod == null) { return; } Console.WriteLine("weld4"); System.IO.StreamWriter writter = new System.IO.StreamWriter(welderSndFile, false); StringBuilder strBuild = new StringBuilder(); writter.Write(weldStr); writter.Flush(); writter.Close(); logRecorder.AddDebugLog(nodeName, "写入铝丝焊:" + weldStr); currWorkMod.tag4 = ENUMWeldStatus.SENDED.ToString(); modBll.Update(currWorkMod); Console.WriteLine("weld5"); if (NodeDB2Commit(4 + this.channelIndex, 1, ref reStr) == false) //焊接参数写入完成 { break; } Console.WriteLine("weld6"); stepIndex++; break; } case 2: { if (db2Vals[4 + this.channelIndex] != 2) { currentTaskDescribe = "等待PLC读取MES下发的加工数据完成"; break; } //if (NodeDB2Commit(4 + this.channelIndex, 0, ref reStr) == false)//焊接参数写入完成 //{ // break; //} Console.WriteLine("weld7"); if (this.db2Vals[2 + channelIndex] != 2) //有模块加工完成 { currentTaskDescribe = "等待设备工作完成"; return; } if (this.NodeDB2Commit(2 + channelIndex, 1, ref reStr) == false) //复位读写 { return; } Console.WriteLine("weld8"); Thread uploadMesThread = new Thread(new ParameterizedThreadStart(UploadBatteryModToMes)); uploadMesThread.IsBackground = true; uploadMesThread.Start(currWorkMod); Console.WriteLine("weld10"); currWorkMod.tag4 = ENUMWeldStatus.COMPLETE.ToString(); modBll.Update(currWorkMod); if (IsAllModComplete() == true) { Console.WriteLine("weld11"); currWorkMod.tag4 = ""; modBll.Update(currWorkMod); isAllComplete = true; stepIndex = 0; } else { isAllComplete = false; stepIndex = 1; Console.WriteLine("weld12"); } break; } } }
public bool DianjiaoProcess() { Console.WriteLine("点胶当前步骤:" + stepIndex); switch (stepIndex) { case 1: { List <DBAccess.Model.BatteryModuleModel> modList = modBll.GetModelList(string.Format("palletID='{0}' and palletBinded=1", this.dianjiaoDev.RfidUID)); currWorkMod = null; for (int i = 0; i < modList.Count; i++) { if (modList[i].tag4.ToUpper() == ENUMWeldStatus.SENDED.ToString() || modList[i].tag4.ToUpper() == ENUMWeldStatus.COMPLETE.ToString()) { continue; } currWorkMod = modList[i]; break; } string str = string.Format("{0},{1},", currWorkMod.tag2, this.dianjiaoDev.RfidUID); System.IO.StreamWriter writter = new System.IO.StreamWriter(this.inputPath, false, Encoding.Default); writter.Write(str); writter.Flush(); writter.Close(); this.dianjiaoDev.LogRecorder.AddDebugLog(this.dianjiaoDev.NodeName, "写入点胶文件数据:" + str); if (currWorkMod == null) { return(true); } string downloadStatusAddr = addrDic[this.dianjiaoDev.NodeID]; string posAddr = addrDic[this.dianjiaoDev.NodeID + "-" + currWorkMod.tag2]; if (this.dianjiaoDev.PlcRW.WriteDB(downloadStatusAddr, 1) == false) { this.dianjiaoDev.LogRecorder.AddDebugLog(this.dianjiaoDev.NodeName, "地址:" + downloadStatusAddr + "写入失败!"); break; } if (this.dianjiaoDev.PlcRW.WriteDB(posAddr, 1) == false) { this.dianjiaoDev.LogRecorder.AddDebugLog(this.dianjiaoDev.NodeName, "地址:" + downloadStatusAddr + "写入失败!"); break; } currWorkMod.tag4 = ENUMWeldStatus.SENDED.ToString(); modBll.Update(currWorkMod); this.dianjiaoDev.LogRecorder.AddDebugLog(this.dianjiaoDev.NodeName, "点胶位置" + currWorkMod.tag2 + "数据发送完成,更新数据完成!"); stepIndex++; break; } case 2: { this.dianjiaoDev.currentTaskDescribe = "等待位置" + this.currWorkMod.tag2 + ",加工完成!"; if (this.dianjiaoDev.db2Vals[2 + this.dianjiaoDev.channelIndex] != 2) { break; } currWorkMod.tag4 = ENUMWeldStatus.COMPLETE.ToString(); modBll.Update(currWorkMod); if (IsAllModComplete() == true) { List <DBAccess.Model.BatteryModuleModel> modList = modBll.GetModelList(string.Format("palletID='{0}' and palletBinded=1", this.dianjiaoDev.RfidUID)); foreach (DBAccess.Model.BatteryModuleModel mod in modList) { mod.tag4 = ""; modBll.Update(mod); } stepIndex = 0; this.dianjiaoDev.LogRecorder.AddDebugLog(this.dianjiaoDev.NodeName, "点胶流程完成!"); return(true); } else { stepIndex = 1; this.dianjiaoDev.LogRecorder.AddDebugLog(this.dianjiaoDev.NodeName, "位置" + this.currWorkMod.tag2 + "点胶流程完成,进行下一位置点胶!"); } break; } } return(false); }