diff --git a/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs b/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs index 9354aa0..87678dd 100644 --- a/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs +++ b/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs @@ -2,9 +2,11 @@ using MaterialTraceability.Entity.DAO; using MaterialTraceability.Entity.DTO; using MaterialTraceability.Entity.Enum; +using MaterialTraceability.Entity.UpLoad; using MaterialTraceability.SqlSugar; using MaterialTraceability.SqlSugar.ServiceImpl; using MaterialTraceability.WebService; +using MaterialTraceability.WebService.MiFirstOperationForsfcServiceService; using MaterialTraceability.WebService.MiReleaseSfcWithActivityServiceService; using MaterialTraceability.WebService.Param; using MaterialTraceability.WebService.ProcessLotServiceWSService; @@ -94,6 +96,8 @@ namespace MaterialTraceability.Business.Impl private IBaseServices sysClientServices = new BaseServices(); + private IBaseServices upRecordServices = new BaseServices(); + private MesAlarmInfo alarmInfo = new MesAlarmInfo(); private PlcBusiness plcBusiness = new PlcBusiness(); @@ -108,16 +112,149 @@ namespace MaterialTraceability.Business.Impl /// public void UpMaterialBegin(int position) { - throw new NotImplementedException(); + string logStr = position == 3 ? "A放卷轴" : "B放卷轴"; + try + { + LogRefreshEvent?.Invoke(LogType.PlcLog, $"{logStr}涨紧信号触发成功"); + ProEquip proEquip = equipBusiness.Equiplist.Where(x => x.positionId == position).FirstOrDefault(); + if (proEquip == null) + { + LogRefreshEvent?.Invoke(LogType.AlarmLog, $"获取{logStr}读写器设备信息异常"); + return; + } + string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId); + epc = epc.Replace("\0", "").Trim(); + SaveReadRecord(proEquip, epc); + + if (StringExtension.IsBlank(epc)) + { + plcBusiness.writePlc(appConfig.TbAddress.放卷气胀泄气, 1); + plcBusiness.writePlc(position == 3 ? appConfig.TbAddress.放卷RFID异常 : appConfig.TbAddress.放卷RFID异常, 1); + LogHelper.Info($"{logStr}RFID条码信息读取失败,下发PLC报警"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, $"{logStr}RFID条码信息读取失败"); + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = "", + sfc = "", + ea = "", + position = position, + }, + plcStatus = true, + }); + return; + } + LogHelper.Info($"{logStr}RFID条码信息读取成功:{epc}"); + LogRefreshEvent?.Invoke(LogType.RfidLog, $"{logStr}RFID条码信息读取成功,RFID为{epc}"); + //判断RFID标签是否重复 + LogHelper.Info($"{logStr}判断RFID标签是否重复"); + if (BusinessHelper.UpRfidIsRecur(epc, position).Result) + { + + //判断是否已经生产结束 + if (UpMaterialIsEndProduction(epc).Result) + { + plcBusiness.writePlc(appConfig.LyAddress.RFID异常, 1); + LogRefreshEvent?.Invoke(LogType.AlarmLog, String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc)); + LogHelper.Info(String.Format("当前读取的RFID:{0},已经生产结束不允许再次上料", epc)); + return; + } + else + { + Expression> exp = s1 => true; + Expression> order = (x) => x.RecordTime; + ProUpRecord upRecord = upRecordServices.QueryFirst(exp, order, false).Result; + if (upRecord != null) + { + PlcBusiness.writeStrPlc(position == 3 ? appConfig.TbAddress.A放卷SFC : appConfig.TbAddress.B放卷SFC, upRecord.Sfc); + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = epc, + sfc = upRecord.Sfc, + position = position, + }, + plcStatus = true, + }); + } + LogHelper.Info($"{logStr}RFID读取到的条码:{epc};与前一读取相同并且生产未结束,可以继续生产"); + LogRefreshEvent?.Invoke(LogType.RfidLog, $"{logStr}RFID读取到的条码:{epc};与前一读取相同并且生产未结束,可以继续生产"); + LogHelper.Info("冷压放卷流程处理成功"); + //plcBusiness.writePlc(appConfig.LyAddress.放卷OK, 0); + return; + } + } + //读取数据刷新 + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = epc, + //sfc = "", + position = position, + }, + plcStatus = true, + }); + + FJMesBegin(position, epc, true); + } + catch (Exception ex) + { + LogHelper.Info($"{logStr}放卷涨紧流程RFID逻辑处理异常:{ex.Message}"); + plcBusiness.writePlc(position == 3 ? appConfig.TbAddress.放卷RFID异常 : appConfig.TbAddress.放卷RFID异常, 1); + } } /// /// 放卷位结束 /// /// - public void UpMaterialEnd(int position) + public async void UpMaterialEnd(int position) { - throw new NotImplementedException(); + string logStr = position == 3 ? "A放卷轴" : "B放卷轴"; + try + { + LogRefreshEvent?.Invoke(LogType.PlcLog, $"{logStr}结束信号触发成功"); + + ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position); + + if (shaftInfo == null) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, $"{logStr}放卷结束,获取卷轴绑定的信息为空"); + return; + } + + Expression> upExp = s1 => true; + upExp = upExp.And(x => x.Sfc == shaftInfo.bindSfc && x.Rfid == shaftInfo.bindRfid && x.IsProduction == 0); + Expression> upOrder = (x) => x.RecordTime; + ProUpRecord upRecord = await upRecordServices.QueryFirst(upExp, upOrder, false); + if (upRecord == null) + { + LogRefreshEvent?.Invoke(LogType.AlarmLog, $"{logStr}放卷结束,获取上料信息为空"); + return; + } + + //更新放卷信息 + upRecord.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + upRecord.IsProduction = 1; + upRecord.isFinish = 1; + await upRecordServices.Update(upRecord); + LogRefreshEvent?.Invoke(LogType.RfidLog, "生成放卷信息"); + + shaftInfo.bindRfid = string.Empty; + shaftInfo.bindSfc = string.Empty; + shaftInfo.bindEaValue = string.Empty; + shaftInfo.bindTime = string.Empty; + await shaftInfoServices.Update(shaftInfo); + + plcBusiness.writePlc(appConfig.TbAddress.放卷控制下料, 0); + } + catch (Exception ex) + { + LogHelper.Info($"{logStr}放卷结束流程RFID逻辑处理异常:{ex.Message}"); + } } ///add by yinzf /// @@ -126,9 +263,169 @@ namespace MaterialTraceability.Business.Impl /// public void UpBegin(int position) { + string logStr = position == 3 ? "A放卷轴" : "B放卷轴"; + try + { + LogRefreshEvent?.Invoke(LogType.PlcLog, $"{logStr}开始信号触发成功"); + + plcBusiness.writePlc(appConfig.TbAddress.放卷控制下料, 1); + } + catch(Exception ex) + { + LogHelper.Info($"{logStr}放卷结束流程RFID逻辑处理异常:{ex.Message}"); + } + } + + /// + /// 放卷涨紧MES处理 + /// + /// + /// + /// + public async void FJMesBegin(int position, string epc, bool auto) + { + string logStr = position == 3 ? "A放卷轴" : "B放卷轴"; + string sfc = ""; + string qty = ""; + try + { + if (!auto) + { + plcBusiness.writePlc(position == 3 ? appConfig.TbAddress.放卷RFID异常 : appConfig.TbAddress.放卷RFID异常, 0); + plcBusiness.writePlc(position == 3 ? appConfig.TbAddress.放卷MES异常 : appConfig.TbAddress.放卷MES异常, 0); + } + + #region 这里进行MES操作 + LogHelper.Info("调用MES首工序获取SFC接口"); + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES首工序获取SFC接口"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "调用MES首工序获取SFC接口"); + //调MES首工序获取SFC接口 + MiFirstOperationForsfcServiceServiceParam miFirstOperationForsfcServiceServiceParam = new MiFirstOperationForsfcServiceServiceParam() + { + url = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "url"), + site = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "site"), + sfc = "", + processLot = epc, + operation = appConfig.operation, + operationRevision = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "operationRevision"), + resource = appConfig.resource, + user = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "user"), + activity = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "activity"), + modeProcessSfc = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "modeProcessSfc"), + loginUser = "", + password = "", + }; + LogHelper.Info("MES首工序获取SFC接口请求参数:" + JsonChange.ModeToJson(miFirstOperationForsfcServiceServiceParam)); + miFirstOperationForsfcResponse firstOperationForsfcResponse = new miFirstOperationForsfcResponse(); + if (appConfig.isMesFlag == 1) + { + DateTime beginTime = DateTime.Now; + try + { + firstOperationForsfcResponse = MesWebServices.iMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam); + LogHelper.Info("MES首工序获取SFC接口返回参数:" + JsonChange.ModeToJson(firstOperationForsfcResponse)); + + //判断返回结果 + if (firstOperationForsfcResponse.@return.code > 0) + { + LogHelper.Info("MES首工序获取SFC接口请求失败:" + firstOperationForsfcResponse.@return.message); + + plcBusiness.writePlc(appConfig.TbAddress.放卷气胀泄气, 1); + plcBusiness.writePlc(appConfig.TbAddress.放卷MES异常, firstOperationForsfcResponse.@return.code); + LogHelper.Info("MES首工序获取SFC接口调用失败:" + firstOperationForsfcResponse.@return.message); + LogRefreshEvent?.Invoke(LogType.RfidLog, "MES首工序获取SFC接口调用失败"); + LogRefreshEvent?.Invoke(LogType.MesLog, "MES首工序获取SFC接口调用失败" + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message)); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "MES首工序获取SFC接口调用失败" + upLoadBusiness.GetMesMessage(firstOperationForsfcResponse.@return.code, firstOperationForsfcResponse.@return.message)); + LogRefreshEvent?.Invoke(LogType.PlcLog, "MES首工序获取SFC接口调用失败"); + return; + } + sfc = firstOperationForsfcResponse.@return.sfc; + qty = firstOperationForsfcResponse.@return.qty; + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty)); + LogHelper.Info(String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty)); + } + catch (Exception ex) + { + LogHelper.Info("调用MES首工序获取SFC接口异常:" + ex.Message); + + LogRefreshEvent?.Invoke(LogType.AlarmLog, "调用MES首工序获取SFC接口异常:" + ex.Message); + LogRefreshEvent?.Invoke(LogType.MesLog, "调用MES首工序获取SFC接口异常:" + ex.Message); + WebServiceLog.saveMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam, null + , beginTime, ex.Message); + plcBusiness.writePlc(appConfig.TbAddress.放卷气胀泄气, 1); + plcBusiness.writePlc(appConfig.TbAddress.放卷MES异常, 1); + return; + } + } + else + { + sfc = System.Guid.NewGuid().ToString("N").Substring(0, 14); + qty = "2000"; + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("MES首工序获取SFC接口调用成功,SFC:{0};EA:{1}", sfc, qty)); + + } + #endregion + + //向PLC写入SFC膜卷号 + PlcBusiness.writeStrPlc(position == 3 ? appConfig.TbAddress.A放卷SFC : appConfig.TbAddress.B放卷SFC, sfc); + ViewModelRefreshEvent?.Invoke(new ViewModelDto() + { + rfidInfo = new RfidInfoDto() + { + rfid = epc, + sfc = sfc, + position = position, + ea = qty, + }, + plcStatus = true, + }); + + //实时绑定卷轴与RFID信息 + LogHelper.Info($"{logStr}绑定放卷轴与RFID:{epc};获取卷轴信息"); + ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position); + + if (shaftInfo == null || StringExtension.IsBlank(shaftInfo.processId)) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, $"{logStr}绑定卷轴与RFID,获取卷轴信息为空"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, $"{logStr}绑定卷轴与RFID,获取卷轴信息为空"); + LogHelper.Info($"{logStr}绑定卷轴与RFID,获取卷轴信息为空"); + return; + } + LogHelper.Info($"{logStr}获取卷轴信息为:" + JsonChange.ModeToJson(shaftInfo)); + shaftInfo.bindRfid = epc; + shaftInfo.bindSfc = sfc; + shaftInfo.bindEaValue = qty; + shaftInfo.bindTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + await shaftInfoServices.Update(shaftInfo); + //本地保存SFC,上料记录 + ProUpRecord upRecord = new ProUpRecord() + { + Id = System.Guid.NewGuid().ToString(), + MachineId = appConfig.machineId, + PositionId = position, + Rfid = epc, + Sfc = sfc, + eaValue = StringChange.ParseToInt(qty), + IsProduction = 0, + beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + await upRecordServices.Add(upRecord); + + upLoadBusiness.SaveUpRecord(upRecord); + + LogHelper.Info($"{logStr}放卷流程处理成功"); + plcBusiness.writePlc(position == 3 ? appConfig.TbAddress.A放卷OK : appConfig.TbAddress.B放卷OK, 1); + } + catch (Exception ex) + { + LogHelper.Info($"{logStr}放卷流程MES逻辑处理异常:{ex.Message}"); + plcBusiness.writePlc(position == 3 ? appConfig.TbAddress.放卷RFID异常 : appConfig.TbAddress.放卷RFID异常, 1); + } } - //end add + + /// /// 收卷位涨紧 /// @@ -617,6 +914,15 @@ namespace MaterialTraceability.Business.Impl { try { + ///放卷强制下料 + if(position > 2) + { + string logstr = position == 3 ? "A放卷轴" : "B放卷轴"; + LogRefreshEvent?.Invoke(LogType.PlcLog, $"{logstr}强制下料信号触发成功"); + UpMaterialEnd(position); + plcBusiness.writePlc(appConfig.TbAddress.放卷控制下料, 0); + return; + } string logStr = position == 1 ? "A轴" : "B轴"; @@ -793,5 +1099,34 @@ namespace MaterialTraceability.Business.Impl }; upLoadBusiness.SaveReadRecord(readRecord); } + + /// + /// 放卷位物料是否结束生产 + /// + /// + private async Task UpMaterialIsEndProduction(string rfidStr) + { + bool result = false; + + Expression> exp = s1 => true; + exp = exp.And(x => x.Rfid == rfidStr); + Expression> order = s1 => s1.RecordTime; + ProUpRecord upRecord = await upRecordServices.QueryFirst(exp, order, false); + if (upRecord != null) + { + if (StringExtension.IsBlank(upRecord.endTime)) + { + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("当前SFC:{0}放卷结束时间为空,生产未结束", rfidStr)); + result = false; + } + else + { + LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("当前SFC:{0}放卷结束时间为:{1}", rfidStr, upRecord.endTime)); + result = true; + } + } + return result; + } + } } diff --git a/MaterialTraceability.Business/MainBusiness.cs b/MaterialTraceability.Business/MainBusiness.cs index c906eeb..30b62af 100644 --- a/MaterialTraceability.Business/MainBusiness.cs +++ b/MaterialTraceability.Business/MainBusiness.cs @@ -72,7 +72,7 @@ namespace MaterialTraceability.Business } //PLC初始化 - this.PLCInit(); + this.PLCInit(); //初始化设备连接 this.EquipInit(); diff --git a/MaterialTraceability.Business/PlcBusiness.cs b/MaterialTraceability.Business/PlcBusiness.cs index 76f859b..d5fcff7 100644 --- a/MaterialTraceability.Business/PlcBusiness.cs +++ b/MaterialTraceability.Business/PlcBusiness.cs @@ -178,6 +178,71 @@ namespace MaterialTraceability.Business LogHelper.PlcLog("RFID系统写入心跳D9628"); Thread.Sleep(200); + // A放卷涨紧 A轴position设为3 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A放卷涨紧) == 1) + { + LogHelper.PlcLog("B放卷涨紧"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.涨紧信号清除, 1); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.A放卷涨紧, 0); + SignalRefreshEvent?.Invoke(1, 3); + } + + // B放卷涨紧 B轴position设为4 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.B放卷涨紧) == 1) + { + LogHelper.PlcLog("B放卷涨紧"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.B放卷涨紧, 0); + SignalRefreshEvent?.Invoke(1, 4); + } + + // A放卷开始 A轴position设为3 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A放卷开始) == 1) + { + LogHelper.PlcLog("B放卷开始"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.A放卷开始, 0); + SignalRefreshEvent?.Invoke(6, 3); + } + + // B放卷开始 B轴position设为4 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.B放卷开始) == 1) + { + LogHelper.PlcLog("B放卷开始"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.B放卷开始, 0); + SignalRefreshEvent?.Invoke(6, 4); + } + + // A放卷结束 A轴position设为3 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A放卷结束) == 1) + { + LogHelper.PlcLog("B放卷结束"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.A放卷结束, 0); + SignalRefreshEvent?.Invoke(2, 3); + } + + // B放卷结束 B轴position设为4 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.B放卷结束) == 1) + { + LogHelper.PlcLog("B放卷结束"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.B放卷结束, 0); + SignalRefreshEvent?.Invoke(2, 4); + } + + //A轴放卷强制下料 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.放卷强制下料) == 1) + { + LogHelper.PlcLog("A轴放卷强制下料"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.放卷强制下料, 0); + SignalRefreshEvent?.Invoke(5, 3); + } + + //B轴放卷强制下料 + if (plcInstance.readInt32ByAddress(appConfig.TbAddress.放卷强制下料) == 2) + { + LogHelper.PlcLog("B轴放卷强制下料"); + plcInstance.writeInt32ByAddress(appConfig.TbAddress.放卷强制下料, 0); + SignalRefreshEvent?.Invoke(5, 4); + } + // A轴收卷涨紧 A轴position设为1 if (plcInstance.readInt32ByAddress(appConfig.TbAddress.A收卷轴涨紧) == 1) { diff --git a/MaterialTraceability.Entity/Config/TbAddress.cs b/MaterialTraceability.Entity/Config/TbAddress.cs index 42629e2..e84ab8d 100644 --- a/MaterialTraceability.Entity/Config/TbAddress.cs +++ b/MaterialTraceability.Entity/Config/TbAddress.cs @@ -60,5 +60,25 @@ namespace MaterialTraceability.Entity.Config public string 收卷轴米数 = iNIFile.IniReadValue("TBPLcAddress", "收卷轴米数"); + + + public string A放卷涨紧 = iNIFile.IniReadValue("TBPLcAddress", "A放卷涨紧"); + public string B放卷涨紧 = iNIFile.IniReadValue("TBPLcAddress", "B放卷涨紧"); + public string A放卷开始 = iNIFile.IniReadValue("TBPLcAddress", "A放卷开始"); + public string B放卷开始 = iNIFile.IniReadValue("TBPLcAddress", "B放卷开始"); + public string A放卷结束 = iNIFile.IniReadValue("TBPLcAddress", "A放卷结束"); + public string B放卷结束 = iNIFile.IniReadValue("TBPLcAddress", "B放卷结束"); + public string A放卷RFID = iNIFile.IniReadValue("TBPLcAddress", "A放卷RFID"); + public string B放卷RFID = iNIFile.IniReadValue("TBPLcAddress", "B放卷RFID"); + public string A放卷SFC = iNIFile.IniReadValue("TBPLcAddress", "A放卷SFC"); + public string B放卷SFC = iNIFile.IniReadValue("TBPLcAddress", "B放卷SFC"); + public string A放卷OK = iNIFile.IniReadValue("TBPLcAddress", "A放卷OK"); + public string B放卷OK = iNIFile.IniReadValue("TBPLcAddress", "B放卷OK"); + public string 放卷RFID异常 = iNIFile.IniReadValue("TBPLcAddress", "放卷RFID异常"); + public string 放卷MES异常 = iNIFile.IniReadValue("TBPLcAddress", "放卷MES异常"); + public string 放卷气胀泄气 = iNIFile.IniReadValue("TBPLcAddress", "放卷气胀泄气"); + public string 放卷控制下料 = iNIFile.IniReadValue("TBPLcAddress", "放卷控制下料"); + public string 放卷强制下料 = iNIFile.IniReadValue("TBPLcAddress", "放卷强制下料"); + } } diff --git a/MaterialTraceabilityUI/App.config b/MaterialTraceabilityUI/App.config index 049ee2f..5618eb9 100644 --- a/MaterialTraceabilityUI/App.config +++ b/MaterialTraceabilityUI/App.config @@ -9,9 +9,9 @@ - + - + diff --git a/MaterialTraceabilityUI/CoatingProcess.xaml b/MaterialTraceabilityUI/CoatingProcess.xaml index 24260a5..cad778e 100644 --- a/MaterialTraceabilityUI/CoatingProcess.xaml +++ b/MaterialTraceabilityUI/CoatingProcess.xaml @@ -11,53 +11,36 @@ - + - + - - - + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - + + + + + + + - - - @@ -75,14 +58,16 @@ + - + + - + @@ -118,14 +103,47 @@ + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + - + + + @@ -208,74 +226,6 @@ - - @@ -293,28 +243,24 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/MaterialTraceabilityUI/CoatingProcess.xaml.cs b/MaterialTraceabilityUI/CoatingProcess.xaml.cs index e93eafd..9d9214e 100644 --- a/MaterialTraceabilityUI/CoatingProcess.xaml.cs +++ b/MaterialTraceabilityUI/CoatingProcess.xaml.cs @@ -135,6 +135,34 @@ namespace MaterialTraceabilityUI EA_Finish.Dispatcher.BeginInvoke(action); } + else if (viewModelDto.rfidInfo.position == 3) + { + action = () => + { + this.RFID_Position1.Text = "RFID:" + viewModelDto.rfidInfo.rfid; + }; + RFID_Position1.Dispatcher.BeginInvoke(action); + action = () => + { + this.EA_Position1.Text = "EA:"; + }; + EA_Position1.Dispatcher.BeginInvoke(action); + + } + else if (viewModelDto.rfidInfo.position == 4) + { + action = () => + { + this.RFID_Position2.Text = "RFID:" + viewModelDto.rfidInfo.rfid; + }; + RFID_Position2.Dispatcher.BeginInvoke(action); + action = () => + { + this.EA_Position2.Text = "EA:"; + }; + EA_Position2.Dispatcher.BeginInvoke(action); + + } } if (!String.IsNullOrEmpty(viewModelDto.rfidInfo.sfc)) @@ -157,6 +185,24 @@ namespace MaterialTraceabilityUI SFC_Finish.Dispatcher.BeginInvoke(action); } + else if (viewModelDto.rfidInfo.position == 4) + { + action = () => + { + this.SFC_Position1.Text = "SFC:" + viewModelDto.rfidInfo.sfc; + }; + SFC_Position1.Dispatcher.BeginInvoke(action); + + } + else if (viewModelDto.rfidInfo.position == 4) + { + action = () => + { + this.SFC_Position2.Text = "SFC:" + viewModelDto.rfidInfo.sfc; + }; + SFC_Position2.Dispatcher.BeginInvoke(action); + + } } } } @@ -184,45 +230,76 @@ namespace MaterialTraceabilityUI { var info = equipBusiness.Equiplist.FirstOrDefault(); - Action action; + var infos = equipBusiness.Equiplist; - if (info != null) + if(infos != null) { - if (info.IsConnect) + foreach(var item in infos) { - action = () => + App.Current.Dispatcher.Invoke(() => { - this.TestTC.Text = "收卷位设备连接成功"; - this.TestTC.Foreground = Brushes.Green; - }; - TestTC.Dispatcher.BeginInvoke(action); - action = () => - { - string imageUrl = "pack://application:,,,/MaterialTraceabilityUI;component/Assets/Images/正常.png"; - BitmapImage bitmapImage = new BitmapImage(new Uri(imageUrl)); - this.EquipStatusImage.ImageSource = bitmapImage; - }; - EquipStatusImage.Dispatcher.BeginInvoke(action); - } - else - { - action = () => - { - this.TestTC.Text = "收卷位设备连接失败"; - this.TestTC.Foreground = Brushes.Red; - }; - TestTC.Dispatcher.BeginInvoke(action); + if (item.equipName.Contains("收卷")) + { + this.TestTC.Text = $"收卷位设备连接{(item.IsConnect ? "成功" : "失败")}"; + this.TestTC.Foreground = item.IsConnect ? Brushes.Green : Brushes.Red; - action = () => - { - string imageUrl = "pack://application:,,,/MaterialTraceabilityUI;component/Assets/Images/失败-01.png"; - BitmapImage bitmapImage = new BitmapImage(new Uri(imageUrl)); - this.EquipStatusImage.ImageSource = bitmapImage; - }; - EquipStatusImage.Dispatcher.BeginInvoke(action); + string imageUrl = $"pack://application:,,,/MaterialTraceabilityUI;component/Assets/Images/{(item.IsConnect ? "正常" : "失败-01")}.png"; + BitmapImage bitmapImage = new BitmapImage(new Uri(imageUrl)); + this.EquipStatusImage.ImageSource = bitmapImage; + } + else + { + this.TestTC2.Text = $"放卷位设备连接{(item.IsConnect ? "成功" : "失败")}"; + this.TestTC2.Foreground = item.IsConnect ? Brushes.Green : Brushes.Red; + + string imageUrl = $"pack://application:,,,/MaterialTraceabilityUI;component/Assets/Images/{(item.IsConnect ? "正常" : "失败-01")}.png"; + BitmapImage bitmapImage = new BitmapImage(new Uri(imageUrl)); + this.EquipStatusImage2.ImageSource = bitmapImage; + } + }); } } + + //Action action; + + //if (info != null) + //{ + // if (info.IsConnect) + // { + // action = () => + // { + // this.TestTC.Text = "收卷位设备连接成功"; + // this.TestTC.Foreground = Brushes.Green; + // }; + // TestTC.Dispatcher.BeginInvoke(action); + + // action = () => + // { + // string imageUrl = "pack://application:,,,/MaterialTraceabilityUI;component/Assets/Images/正常.png"; + // BitmapImage bitmapImage = new BitmapImage(new Uri(imageUrl)); + // this.EquipStatusImage.ImageSource = bitmapImage; + // }; + // EquipStatusImage.Dispatcher.BeginInvoke(action); + // } + // else + // { + // action = () => + // { + // this.TestTC.Text = "收卷位设备连接失败"; + // this.TestTC.Foreground = Brushes.Red; + // }; + // TestTC.Dispatcher.BeginInvoke(action); + + // action = () => + // { + // string imageUrl = "pack://application:,,,/MaterialTraceabilityUI;component/Assets/Images/失败-01.png"; + // BitmapImage bitmapImage = new BitmapImage(new Uri(imageUrl)); + // this.EquipStatusImage.ImageSource = bitmapImage; + // }; + // EquipStatusImage.Dispatcher.BeginInvoke(action); + // } + //} } /// @@ -1487,6 +1564,33 @@ namespace MaterialTraceabilityUI }; SFC_Finish.Dispatcher.BeginInvoke(action); break; + + case 3: + action = () => + { + this.RFID_Position1.Text = "RFID:" + shaftInfo.bindRfid; + }; + RFID_Position1.Dispatcher.BeginInvoke(action); + + action = () => + { + this.SFC_Position1.Text = "SFC:" + shaftInfo.bindSfc; + }; + SFC_Position1.Dispatcher.BeginInvoke(action); + break; + case 4: + action = () => + { + this.RFID_Position2.Text = "RFID:" + shaftInfo.bindRfid; + }; + RFID_Position2.Dispatcher.BeginInvoke(action); + + action = () => + { + this.SFC_Position2.Text = "SFC:" + shaftInfo.bindSfc; + }; + SFC_Position2.Dispatcher.BeginInvoke(action); + break; default: break; } @@ -1648,5 +1752,22 @@ namespace MaterialTraceabilityUI } } + private void FJ_A_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + WriteInfo write = new WriteInfo("TB", 3); + write.ShowDialog(); + + RefreshMaterialInfo("TB", "3"); + } + + private void FJ_B_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + WriteInfo write = new WriteInfo("TB", 4); + write.ShowDialog(); + + RefreshMaterialInfo("TB", "4"); + } + + } } diff --git a/MaterialTraceabilityUI/WriteInfo.xaml.cs b/MaterialTraceabilityUI/WriteInfo.xaml.cs index bc62bff..cb3d1b0 100644 --- a/MaterialTraceabilityUI/WriteInfo.xaml.cs +++ b/MaterialTraceabilityUI/WriteInfo.xaml.cs @@ -73,7 +73,14 @@ namespace MaterialTraceabilityUI if(processId == "TB") { - tBSignalRead.MesBegin(position,rfidCode,false); + if(position < 3) + { + tBSignalRead.MesBegin(position, rfidCode, false); + } + else + { + tBSignalRead.FJMesBegin(position, rfidCode, false); + } MessageBox.Show("涂布RFID条码信息写入成功"); }else if(processId == "MQ_A") {