public bool GetRepairProcessParamByCode(string moduleCode, ref RepairProcessParam repairProcessParam, ref string restr) { try { repairProcessParam = new RepairProcessParam(); if (SysCfgModel.IsRequireRequireFromMes == false) { repairProcessParam.StartDevStation = SysCfgModel.StartWorkStationID; repairProcessParam.ProcessNum = SysCfgModel.ProcessID; restr = "获取MES返修流程参数成功:开始工位编号:" + repairProcessParam.StartDevStation + ",流程参数:" + repairProcessParam.ProcessNum; return(true); } string M_WORKSTATION_SN = ""; string M_DEVICE_SN = ""; string M_UNION_SN = ""; string M_CONTAINER_SN = ""; string M_LEVEL = ""; string M_ITEMVALUE = ""; int flag = 16; RootObject rObj = new RootObject(); //List<DBAccess.Model.BatteryModuleModel> modelList = modBll.GetModelList(string.Format("palletID='{0}' and palletBinded=1", rfid)); //modBll.GetModelByPalletID(this.rfidUID, this.nodeName); //if (modelList == null || modelList.Count == 0) //{ // restr = "获取返修加工参数失败,工装板上的模块数量为空:" + rfid; // return false; //} //foreach (DBAccess.Model.BatteryModuleModel bat in modelList) //{ string barcode = moduleCode; string strJson = ""; rObj = WShelper.DevDataUpload(flag, M_DEVICE_SN, M_WORKSTATION_SN, barcode, M_UNION_SN, M_CONTAINER_SN, M_LEVEL, M_ITEMVALUE, ref strJson, ""); restr = rObj.RES; List <ContentDetail> content = rObj.M_COMENT;; if (content != null && content.Count > 0) { if (repairProcessParam.StartDevStation == "" || repairProcessParam.ProcessNum == "") { restr = "二维码:" + barcode + "请求起始工位及流程代号失败,返回起始工位号或者流程代码为空:" + restr; return(false); } repairProcessParam.StartDevStation = content[0].M_WORKSTATION_SN; repairProcessParam.ProcessNum = content[0].M_ROUTE; restr = "获取MES返修流程参数成功:开始工位编号:" + repairProcessParam.StartDevStation + ",流程参数:" + repairProcessParam.ProcessNum; } else { restr = "二维码:" + barcode + "请求起始工位及流程代号失败,MES返回ContentDetail数据为空:" + restr; return(false); } //} this.repairParam = repairProcessParam; return(true); } catch (Exception ex) { restr = ex.ToString(); return(false); } }
public virtual bool DevWarnMonitor(ref string reStr) { if (PlcRW == null) { reStr = "PLC通信对象不存在"; return(false); } if (!SysCfgModel.SimMode) { if (!PlcRW.ReadMultiDB(this.dbStartAddr, this.dbBlockNum * 16, ref dbVals)) { reStr = devName + "PLC未通信上"; Console.WriteLine(this.devName + "读取报警地址失败!");//测试 return(false); } } //if (dbVals[0] > 0)//测试用 //{ // dbVals[0] = 0; // dbVals[1] = 0; //} //else //{ // dbVals[0] = 255; // dbVals[1] = 255; //} //Console.WriteLine(this.devName + dbVals[0].ToString() + "," + dbVals[1].ToString()); foreach (string key in devWarnList.Keys) { DevWarnItemModel warnItem = devWarnList[key]; string[] plcAddrArray = warnItem.PlcAddr.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); int blockIndex = int.Parse(plcAddrArray[0].Substring(1)) - int.Parse(this.dbStartAddr.Substring(1)); int bitIndex = int.Parse(plcAddrArray[1]); int val = dbVals[blockIndex * 16 + bitIndex];//(dbVals[blockIndex]>>bitIndex)&0x01; if (val != warnItem.WarnStat) { DevWarnRecordModel warnRecord = new DevWarnRecordModel(); warnRecord.devID = this.devID; warnRecord.plcAddr = warnItem.PlcAddr; warnRecord.recordID = System.Guid.NewGuid().ToString(); warnRecord.recordTime = System.DateTime.Now; warnRecord.warnStat = val; string areaLine = "L001"; string reJsonStr = ""; if (val == 0) { warnRecord.warnInfo += "已清除"; if (!string.IsNullOrWhiteSpace(this.mesID) && !string.IsNullOrWhiteSpace(warnItem.MesWarnID)) { RootObject rObj = WShelper.DevErrorUpload(mesID, areaLine, warnItem.MesWarnID, 1, ref reJsonStr); if (LogRecorder != null) { LogRecorder.AddDebugLog(devName, string.Format("报警{0}复位,上传MES,返回结果:{1}", warnItem.WarnInfo, rObj.RES)); } } } else { warnRecord.warnInfo = warnItem.WarnInfo; if (!string.IsNullOrWhiteSpace(this.mesID) && !string.IsNullOrWhiteSpace(warnItem.MesWarnID)) { RootObject rObj = WShelper.DevErrorUpload(mesID, areaLine, warnItem.MesWarnID, 0, ref reJsonStr); if (LogRecorder != null) { LogRecorder.AddDebugLog(devName, string.Format("报警{0}发生,上传MES,返回结果:{1}", warnItem.WarnInfo, rObj.RES)); } } } devWarnrecordBll.Add(warnRecord); Console.WriteLine(this.devName + ":" + warnRecord.warnInfo + "-》添加报警记录成功!"); warnItem.WarnStat = val; } } return(true); }