From 432759579a4a5b007491507e15c99b4578bc9e67 Mon Sep 17 00:00:00 2001 From: CaesarBao Date: Tue, 26 May 2026 19:32:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EquipBusiness.cs | 57 ++-- .../Impl/LYSignalReadBusiness.cs | 248 +++++++++--------- MaterialTraceability.Business/MainBusiness.cs | 4 +- MaterialTraceability.Business/PlcBusiness.cs | 37 ++- .../Impl/RFly_I160Adapter.cs | 5 +- MaterialTraceabilityUI/App.config | 4 +- MaterialTraceabilityUI/SplitSfc.xaml.cs | 32 +-- MaterialTraceabilityUI/firstPage.xaml | 6 +- MaterialTraceabilityUI/firstPage.xaml.cs | 16 +- 9 files changed, 231 insertions(+), 178 deletions(-) diff --git a/MaterialTraceability.Business/EquipBusiness.cs b/MaterialTraceability.Business/EquipBusiness.cs index 22ce7f6..2eb2310 100644 --- a/MaterialTraceability.Business/EquipBusiness.cs +++ b/MaterialTraceability.Business/EquipBusiness.cs @@ -81,18 +81,40 @@ namespace MaterialTraceability.Business //{ // taglist.Add(new TagInfo // { - // Antana = 4, - // Count = 2, - // EPCstring = "JSLY1RDA00000302" - + // Antana = 1, + // Count = 1, + // EPCstring = "CATT1RDB00011801" + // }); + // taglist.Add(new TagInfo + // { + // Antana = 2, + // Count = 6, + // EPCstring = "CATT1RDB00011802" + // }); + // taglist.Add(new TagInfo + // { + // Antana = 1, + // Count = 8, + // EPCstring = "CATT1RDB00023202" + // }); + // taglist.Add(new TagInfo + // { + // Antana = 4, + // Count = 25, + // EPCstring = "CATT1RDB00011201" + // }); + // taglist.Add(new TagInfo + // { + // Antana = 3, + // Count = 7, + // EPCstring = "CATT1RDB00014702" // }); - //} - //if (taglist.Count < 1) - //{ - // taglist = equip.DeviceAdapter.Device_GetTagInfoList(DeviceType.Mesnac_GRUR445, int.Parse(Convert.ToString(waitTime * 1000))); - //} - eq = equip; + //if (taglist.Count < 1) + //{ + // taglist = equip.DeviceAdapter.Device_GetTagInfoList(DeviceType.Mesnac_GRUR445, int.Parse(Convert.ToString(waitTime * 1000))); + //} + eq = equip; LogHelper.RfidLog("gettaglist函数结果:" + JsonChange.ModeToJson(taglist)); if (isFilter) { @@ -405,11 +427,11 @@ namespace MaterialTraceability.Business } if (ConfigHelper.GetConfig("tagAmount") == "3") { - if (minpostion == 5 || minpostion == 8) + if (minpostion == 1 || minpostion == 4) { - LogRefreshEvent?.Invoke(LogType.RfidLog, "天线:" + minpostion + ",未读到标签,改为" + (minpostion + 1) + "进行读取"); - ta = GetAntEPC(info2, minpostion + 1, ""); - LogRefreshEvent?.Invoke(LogType.RfidLog, "天线:" + (minpostion + 1) + ",读到标签:" + ta.EPC); + LogRefreshEvent?.Invoke(LogType.RfidLog, "位置:" + minpostion + ",未读到标签,改为" + (minpostion - 1) + "进行读取"); + ta = GetAntEPC(info2, minpostion - 1, ""); + LogRefreshEvent?.Invoke(LogType.RfidLog, "天线:" + (minpostion - 1) + ",读到标签:" + ta.EPC); } //if (minpostion == 8) @@ -419,7 +441,6 @@ namespace MaterialTraceability.Business // LogRefreshEvent?.Invoke(LogType.RfidLog, "天线:" + (minpostion - 1) + ",读到标签:" + ta.EPC); //} } - ta.position = minpostion; } outepc = ta.EPC; @@ -436,7 +457,7 @@ namespace MaterialTraceability.Business foreach (var a in tagList) { - LogHelper.RfidLog("RFID读取日志:" + a.position + "位置读到标签:" + a.EPC); + LogHelper.RfidLog("RFID读取日志:" + a.position + "位置,天线:"+a.Ant+"读到标签:" + a.EPC); } return tagList; @@ -458,7 +479,7 @@ namespace MaterialTraceability.Business { //小天线的位置是1,3 - if (po == 1 || po == 4) + if (po == 1 || po == 3) { minPostion = po; //positionGroup.Remove(po); @@ -492,6 +513,7 @@ namespace MaterialTraceability.Business var result = cFliterRFID.filterByAnt(taglist, Convert.ToInt32(equip.equipAnt), outEPC); TagMessage tag = new TagMessage() { + Ant = equip.equipAnt, EPC = result, position = pos }; @@ -960,6 +982,7 @@ namespace MaterialTraceability.Business public class TagMessage { + public string Ant { get; set; } /// /// epc /// diff --git a/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs b/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs index 63abd06..4472531 100644 --- a/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs +++ b/MaterialTraceability.Business/Impl/LYSignalReadBusiness.cs @@ -143,12 +143,12 @@ namespace MaterialTraceability.Business.Impl epc = epc.Replace("\0", "").Trim(); //RFID写入PLC //WriteRFIDtoPLC(position, epc); - //if (epc == "" || epc == null) - //{ - // Random random = new Random(); + if (epc == "" || epc == null) + { + Random random = new Random(); - // epc = "JSLY4RDA0000" + random.Next(10, 99); - //} + epc = "JSLY4RDA0000" + random.Next(10, 99); + } if (StringExtension.IsBlank(epc) || !epc.Contains("JSLY") && !epc.Contains("CATT")) @@ -264,6 +264,16 @@ namespace MaterialTraceability.Business.Impl { try { + //放卷结束置位手动上料 + if (position == 0) + { + plcBusiness.writePlc(appConfig.LyAddress.A手动上料, 0); + } + else + { + plcBusiness.writePlc(appConfig.LyAddress.B手动上料, 0); + } + string logStr = position == 0 ? LanguageHelper.ShowMessage("A放卷轴") : LanguageHelper.ShowMessage("B放卷轴"); LogRefreshEvent?.Invoke(LogType.PlcLog, logStr+ LanguageHelper.ShowMessage("放卷位结束信号触发成功")); LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + LanguageHelper.ShowMessage("放卷位结束信号触发成功")); @@ -306,15 +316,15 @@ namespace MaterialTraceability.Business.Impl } - if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2A状态) == 1) - { - UpdateShaftEndFlag(3); - } + //if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2A状态) == 1) + //{ + // UpdateShaftEndFlag(3); + //} - if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2B状态) == 1) - { - UpdateShaftEndFlag(4); - } + //if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2B状态) == 1) + //{ + // UpdateShaftEndFlag(4); + //} //更新放卷信息 @@ -386,7 +396,7 @@ namespace MaterialTraceability.Business.Impl } if (FJSFC.Length > 0) { - FJSFC = FJSFC.Substring(0, 18); + FJSFC = FJSFC.Substring(0, 20); } if (StringExtension.IsBlank(FJSFC)) { @@ -401,14 +411,14 @@ namespace MaterialTraceability.Business.Impl List positionTag = equipBusiness.ReadEPCByAntanaGroup(positionList); foreach (var item in positionList) { - if (item == 1) logStr = LanguageHelper.ShowMessage("1A轴1#天线"); - if (item == 2) logStr = LanguageHelper.ShowMessage("1A轴2#天线"); - if (item == 3) logStr = LanguageHelper.ShowMessage("1B轴1#天线"); - if (item == 4) logStr = LanguageHelper.ShowMessage("1B轴2#天线"); - if (item == 5) logStr = LanguageHelper.ShowMessage("2A轴3#天线"); - if (item == 6) logStr = LanguageHelper.ShowMessage("2A轴4#天线"); - if (item == 7) logStr = LanguageHelper.ShowMessage("2B轴3#天线"); - if (item == 8) logStr = LanguageHelper.ShowMessage("2B轴4#天线"); + if (item == 1) logStr = LanguageHelper.ShowMessage("1A轴3#天线"); + if (item == 2) logStr = LanguageHelper.ShowMessage("1A轴4#天线"); + if (item == 3) logStr = LanguageHelper.ShowMessage("1B轴4#天线"); + if (item == 4) logStr = LanguageHelper.ShowMessage("1B轴3#天线"); + if (item == 5) logStr = LanguageHelper.ShowMessage("2A轴1#天线"); + if (item == 6) logStr = LanguageHelper.ShowMessage("2A轴2#天线"); + if (item == 7) logStr = LanguageHelper.ShowMessage("2B轴1#天线"); + if (item == 8) logStr = LanguageHelper.ShowMessage("2B轴2#天线"); string epc = ""; //add by wenjy 判断读取结果是否为null 20220825 @@ -542,23 +552,24 @@ namespace MaterialTraceability.Business.Impl } else if (ConfigHelper.GetConfig("tagAmount") == "3") { - if (position < 3) + if (position > 2) { if (tagInfoList.Count == 2) { + LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号"); + this.sendSuccessByDownBegin(position); //这里要判断是否存在其他位置 - if (JudgeSame(tagInfoList, position)) - { - WriteNGToPLC(position); - sendError(position, 2, false, 1); - LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复"); - LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + epc + LanguageHelper.ShowMessage("RFID条码已存在其它位置,检查是否重复")); - } - else - { - LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号"); - this.sendSuccessByDownBegin(position); - } + //if (JudgeSame(tagInfoList, position)) + //{ + // WriteNGToPLC(position); + // sendError(position, 2, false, 1); + // LogHelper.Info(logStr + "RFID条码" + epc + "已存在其它位置,检查是否重复"); + // LogRefreshEvent?.Invoke(LogType.AlarmLog, logStr + epc + LanguageHelper.ShowMessage("RFID条码已存在其它位置,检查是否重复")); + //} + //else + //{ + + //} } } else @@ -580,13 +591,24 @@ namespace MaterialTraceability.Business.Impl } } } - + else + { + if (position < 5) + { + if (tagInfoList.Count == 2) + { + LogHelper.Info("收卷位涨紧流程处理完工,下发OK信号"); + this.sendSuccessByDownBegin(position); + } + } + + } if (appConfig.isMesFlag == 1) - { + { //解绑RFID与SFC的绑定信息 LogHelper.Info("解绑RFID条码" + epc + "绑定的SFC信息"); - LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + epc+ LanguageHelper.ShowMessage("解绑RFID条码绑定的SFC信息")); + LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + epc + LanguageHelper.ShowMessage("解绑RFID条码绑定的SFC信息")); this.UnBindRfidAndSfc(epc); } @@ -663,10 +685,10 @@ namespace MaterialTraceability.Business.Impl LogHelper.Info(logStr + "收卷结束信号触发成功"); //通过PLC读取收卷轴绑定的放卷位SFC信 ProShaftInfo upMaterialInfo = new ProShaftInfo(); - if (position == 1) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, 18).Replace("\0", "").Trim(); - if (position == 2) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, 18).Replace("\0", "").Trim(); - if (position == 3) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, 18).Replace("\0", "").Trim(); - if (position == 4) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, 18).Replace("\0", "").Trim(); + if (position == 1) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, 20).Replace("\0", "").Trim(); + if (position == 2) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, 20).Replace("\0", "").Trim(); + if (position == 3) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, 20).Replace("\0", "").Trim(); + if (position == 4) upMaterialInfo.bindSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, 20).Replace("\0", "").Trim(); //LogHelper.PlcLog("通过PLC获取SFC截取前长度:" + upMaterialInfo.bindSfc.Length); //LogHelper.PlcLog("PLC获取截取前的SFC为:" + upMaterialInfo.bindSfc); if (StringExtension.IsBlank(upMaterialInfo.bindSfc)) @@ -679,8 +701,8 @@ namespace MaterialTraceability.Business.Impl if (upMaterialInfo.bindSfc.Length > 0) { - //LogRefreshEvent?.Invoke(LogType.RfidLog, "PLC获取的18位SFC为:" + upMaterialInfo.bindSfc + "长度超过18位进行截取"); - upMaterialInfo.bindSfc = upMaterialInfo.bindSfc.Substring(0, 18); + //LogRefreshEvent?.Invoke(LogType.RfidLog, "PLC获取的20位SFC为:" + upMaterialInfo.bindSfc + "长度超过20位进行截取"); + upMaterialInfo.bindSfc = upMaterialInfo.bindSfc.Substring(0, 20); } LogRefreshEvent?.Invoke(LogType.RfidLog, LanguageHelper.ShowMessage("通过PLC获取的SFC为:") + upMaterialInfo.bindSfc); @@ -1356,14 +1378,14 @@ namespace MaterialTraceability.Business.Impl /// private bool GetSameSfcByPlc(string bindSfc, int position) { - string SJ_1A = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)18).Replace("\0", "").Trim(); - string SJ_1B = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)18).Replace("\0", "").Trim(); - string SJ_2A = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)18).Replace("\0", "").Trim(); - string SJ_2B = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)18).Replace("\0", "").Trim(); + string SJ_1A = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)20).Replace("\0", "").Trim(); + string SJ_1B = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)20).Replace("\0", "").Trim(); + string SJ_2A = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)20).Replace("\0", "").Trim(); + string SJ_2B = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)20).Replace("\0", "").Trim(); if (position != 1) { - if (!SJ_1A.IsBlank() && SJ_1A.Length == 18) + if (!SJ_1A.IsBlank() && SJ_1A.Length == 20) { if (SJ_1A == bindSfc) return true; @@ -1372,7 +1394,7 @@ namespace MaterialTraceability.Business.Impl if (position != 2) { - if (!SJ_1B.IsBlank() && SJ_1B.Length == 18) + if (!SJ_1B.IsBlank() && SJ_1B.Length == 20) { if (SJ_1B == bindSfc) return true; @@ -1380,7 +1402,7 @@ namespace MaterialTraceability.Business.Impl } if (position != 3) { - if (!SJ_2A.IsBlank() && SJ_2A.Length == 18) + if (!SJ_2A.IsBlank() && SJ_2A.Length == 20) { if (SJ_2A == bindSfc) return true; @@ -1388,7 +1410,7 @@ namespace MaterialTraceability.Business.Impl } if (position != 4) { - if (!SJ_2B.IsBlank() && SJ_2B.Length == 18) + if (!SJ_2B.IsBlank() && SJ_2B.Length == 20) { if (SJ_2B == bindSfc) return true; @@ -1648,7 +1670,7 @@ namespace MaterialTraceability.Business.Impl //1A if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1A状态) == 1) { - downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)18).Replace("\0", "").Trim().Substring(0,18); + downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1ASFC, (ushort)20).Replace("\0", "").Trim().Substring(0,20); LogHelper.Info("1A轴在生产,SFC:" + downSfc); if (StringExtension.IsBlank(downSfc)) { @@ -1672,7 +1694,7 @@ namespace MaterialTraceability.Business.Impl //1B if (PlcBusiness.readPlc(appConfig.LyAddress.收卷1B状态) == 1) { - downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18); + downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷1BSFC, (ushort)20).Replace("\0", "").Trim().Substring(0, 20); LogHelper.Info("1B轴在生产,SFC:" + downSfc); if (StringExtension.IsBlank(downSfc)) { @@ -1696,7 +1718,7 @@ namespace MaterialTraceability.Business.Impl //2A if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2A状态) == 1) { - downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18); + downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2ASFC, (ushort)20).Replace("\0", "").Trim().Substring(0, 20); LogHelper.Info("2A轴在生产,SFC:" + downSfc); if (StringExtension.IsBlank(downSfc)) { @@ -1720,7 +1742,7 @@ namespace MaterialTraceability.Business.Impl //2B if (PlcBusiness.readPlc(appConfig.LyAddress.收卷2B状态) == 1) { - downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18); + downSfc = PlcBusiness.readStrPlc(appConfig.LyAddress.收卷2BSFC, (ushort)20).Replace("\0", "").Trim().Substring(0, 20); LogHelper.Info("2B轴在生产,SFC:" + downSfc); if (StringExtension.IsBlank(downSfc)) { @@ -1823,7 +1845,7 @@ namespace MaterialTraceability.Business.Impl //plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 1); plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 1); } - if(appConfig.PLCType == "LY4NKLYPLcAddress") + if(appConfig.PLCType == "LY4NKLYPLcAddress" || appConfig.PLCType == "HNLYPLcAddress") { plcBusiness.writePlc(appConfig.LyAddress.收卷上料1AOK, 1); } @@ -1839,7 +1861,7 @@ namespace MaterialTraceability.Business.Impl //plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 1); plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 1); } - if (appConfig.PLCType == "LY4NKLYPLcAddress") + if (appConfig.PLCType == "LY4NKLYPLcAddress" || appConfig.PLCType == "HNLYPLcAddress") { plcBusiness.writePlc(appConfig.LyAddress.收卷上料1BOK, 1); } @@ -1856,7 +1878,7 @@ namespace MaterialTraceability.Business.Impl plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 1); //plcBusiness.writePlc(appConfig.LyAddress.收卷下料2AOK, 0); } - if (appConfig.PLCType == "LY4NKLYPLcAddress") + if (appConfig.PLCType == "LY4NKLYPLcAddress" || appConfig.PLCType == "HNLYPLcAddress") { plcBusiness.writePlc(appConfig.LyAddress.收卷上料2AOK, 1); } @@ -1873,7 +1895,7 @@ namespace MaterialTraceability.Business.Impl plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 1); //plcBusiness.writePlc(appConfig.LyAddress.收卷下料2BOK, 0); } - if (appConfig.PLCType == "LY4NKLYPLcAddress") + if (appConfig.PLCType == "LY4NKLYPLcAddress" || appConfig.PLCType == "HNLYPLcAddress") { plcBusiness.writePlc(appConfig.LyAddress.收卷上料2BOK, 1); } @@ -1893,62 +1915,19 @@ namespace MaterialTraceability.Business.Impl { if (position == 1) { - if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress")) - { - plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 0); - //plcBusiness.writePlc(appConfig.LyAddress.收卷下料1AOK, 1); - } - - else - { - plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1); - } - + plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1); } if (position == 2) { - if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress")) - { - plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 0); - //plcBusiness.writePlc(appConfig.LyAddress.收卷下料1BOK, 1); - - } - else - { - plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1); - - } - + plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1); } if (position == 3) { - if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress")) - { - plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 0); - //plcBusiness.writePlc(appConfig.LyAddress.收卷下料2AOK, 1); - - } - else - { - plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 1); - - - } - + plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 1); } if (position == 4) { - if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress")) - { - plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 0); - //plcBusiness.writePlc(appConfig.LyAddress.收卷下料2BOK, 1); - - } - else - { - plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 1); - } - + plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 1); } } @@ -1965,6 +1944,13 @@ namespace MaterialTraceability.Business.Impl if (position == 3) plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 2); if (position == 4) plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 2); } + else if (appConfig.PLCType == ("HNLYPLcAddress")) + { + if (position == 1) plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 0); + if (position == 2) plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 0); + if (position == 3) plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 0); + if (position == 4) plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 0); + } else { if (position == 1) plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1); @@ -2149,7 +2135,7 @@ namespace MaterialTraceability.Business.Impl } else { - if (item == 5 || item == 8) + if (item == 1 || item == 4) { shaftInfo.endFlag = 1; LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid); @@ -2189,7 +2175,7 @@ namespace MaterialTraceability.Business.Impl } if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2") { - if (position > 2) + if (position < 5) { shaftInfo.endFlag = 1; LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid); @@ -2207,7 +2193,7 @@ namespace MaterialTraceability.Business.Impl } else { - if (item == 5 || item == 8) + if (item == 1 || item == 4) { shaftInfo.endFlag = 1; LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid); @@ -2227,7 +2213,7 @@ namespace MaterialTraceability.Business.Impl } if (ConfigHelper.GetConfig("tagAmount") == "4") { - if (item == 5 || item == 8) + if (item == 1 || item == 4) { shaftInfo.endFlag = 1; LogHelper.Info("放卷结束,确定最后一卷收卷物料RFID条码为:" + shaftInfo.bindRfid); @@ -2271,7 +2257,7 @@ namespace MaterialTraceability.Business.Impl LogHelper.Info("1A轴异常下料信号触发,下发下料信号"); - if (appConfig.PLCType == ("LY4NKLYPLcAddress")) + if (appConfig.PLCType == ("LY4NKLYPLcAddress") || appConfig.PLCType == ("HNLYPLcAddress")) { plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1); } @@ -2291,7 +2277,7 @@ namespace MaterialTraceability.Business.Impl //LogRefreshEvent?.Invoke(LogType.PlcLog, "1B轴异常下料信号触发,下发下料信号"); LogHelper.Info("1B轴异常下料信号触发,下发下料信号"); - if (appConfig.PLCType == ("LY4NKLYPLcAddress")) + if (appConfig.PLCType == ("LY4NKLYPLcAddress") || appConfig.PLCType == ("HNLYPLcAddress")) { plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1); } @@ -2312,7 +2298,7 @@ namespace MaterialTraceability.Business.Impl //LogRefreshEvent?.Invoke(LogType.PlcLog, "2A轴异常下料信号触发,下发下料信号"); LogHelper.Info("2A轴异常下料信号触发,下发下料信号"); - if (appConfig.PLCType == ("LY4NKLYPLcAddress")) + if (appConfig.PLCType == ("LY4NKLYPLcAddress") || appConfig.PLCType == ("HNLYPLcAddress")) { plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料,1); } @@ -2333,7 +2319,7 @@ namespace MaterialTraceability.Business.Impl //LogRefreshEvent?.Invoke(LogType.PlcLog, "2B轴异常下料信号触发,下发下料信号"); LogHelper.Info("2B轴异常下料信号触发,下发下料信号"); - if (appConfig.PLCType == ("LY4NKLYPLcAddress")) + if (appConfig.PLCType == ("LY4NKLYPLcAddress") || appConfig.PLCType == ("HNLYPLcAddress")) { plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料,1); } @@ -2386,12 +2372,12 @@ namespace MaterialTraceability.Business.Impl if (position == 3) { - exp = exp.And(x => x.bindRfid == epc && x.positionId != "5" && x.processId == appConfig.processId); + exp = exp.And(x => x.bindRfid == epc && x.positionId != "5" && x.positionId != "6" && x.processId == appConfig.processId); } if (position == 4) { - exp = exp.And(x => x.bindRfid == epc && x.positionId != "8" && x.processId == appConfig.processId); + exp = exp.And(x => x.bindRfid == epc && x.positionId != "8" && x.positionId != "7" && x.processId == appConfig.processId); } List shaftInfos = await shaftInfoServices.Query(exp); if (shaftInfos.Count > 0) @@ -2417,15 +2403,22 @@ namespace MaterialTraceability.Business.Impl logStr = "1A轴"; if (ConfigHelper.GetConfig("tagAmount") == "2"|| ConfigHelper.GetConfig("tagAmount") == "1") { - positionList.Add(2); + positionList.Add(1); //冷压1拆2用小天线 //positionList.Add(1); + } + if (ConfigHelper.GetConfig("tagAmount") == "4") + { + positionList.Add(1); + //冷压1拆2用小天线 + positionList.Add(2); + } else { positionList.Add(1); - positionList.Add(2); + //positionList.Add(4); } } if (position == 2) @@ -2433,16 +2426,21 @@ namespace MaterialTraceability.Business.Impl positionList.Clear(); logStr = "1B轴"; if (ConfigHelper.GetConfig("tagAmount") == "2" || ConfigHelper.GetConfig("tagAmount") == "1") + { + //冷压1拆2用小天线 + positionList.Add(4); + + } + if (ConfigHelper.GetConfig("tagAmount") == "4") { positionList.Add(3); //冷压1拆2用小天线 - //positionList.Add(4); + positionList.Add(4); } else { positionList.Add(4); - positionList.Add(3); } } if (position == 3) @@ -2451,7 +2449,7 @@ namespace MaterialTraceability.Business.Impl positionList.Clear(); if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2" || ConfigHelper.GetConfig("tagAmount") == "1") { - //positionList.Add(6); + positionList.Add(6); positionList.Add(5); } else @@ -2466,7 +2464,7 @@ namespace MaterialTraceability.Business.Impl positionList.Clear(); if (ConfigHelper.GetConfig("tagAmount") == "3" || ConfigHelper.GetConfig("tagAmount") == "2" || ConfigHelper.GetConfig("tagAmount") == "1") { - //positionList.Add(7); + positionList.Add(7); positionList.Add(8); } else @@ -2505,12 +2503,12 @@ namespace MaterialTraceability.Business.Impl int FJAstate = PlcBusiness.readPlc(appConfig.LyAddress.放卷A状态); if (FJAstate == 1) { - sfc = PlcBusiness.readStrPlc(appConfig.LyAddress.A放卷SFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18); + sfc = PlcBusiness.readStrPlc(appConfig.LyAddress.A放卷SFC, (ushort)20).Replace("\0", "").Trim().Substring(2, 20); } int FJBstate = PlcBusiness.readPlc(appConfig.LyAddress.放卷B状态); if (FJBstate == 1) { - sfc = PlcBusiness.readStrPlc(appConfig.LyAddress.B放卷SFC, (ushort)18).Replace("\0", "").Trim().Substring(0, 18); + sfc = PlcBusiness.readStrPlc(appConfig.LyAddress.B放卷SFC, (ushort)20).Replace("\0", "").Trim().Substring(2, 20); } //JudgementMaterial(放卷膜卷号),返回true合卷报警=>PLC 写报警值,返回false不处理 diff --git a/MaterialTraceability.Business/MainBusiness.cs b/MaterialTraceability.Business/MainBusiness.cs index 2439aee..320ac05 100644 --- a/MaterialTraceability.Business/MainBusiness.cs +++ b/MaterialTraceability.Business/MainBusiness.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Threading; +using System.Threading.Tasks; using static System.Net.Mime.MediaTypeNames; namespace MaterialTraceability.Business @@ -241,7 +242,7 @@ namespace MaterialTraceability.Business /// /// /// - public void SignalRead_Invoke(int signal, int position) + public async void SignalRead_Invoke(int signal, int position) { try { @@ -273,6 +274,7 @@ namespace MaterialTraceability.Business break; default: break; + Task.Delay(1); } }catch(Exception ex) { diff --git a/MaterialTraceability.Business/PlcBusiness.cs b/MaterialTraceability.Business/PlcBusiness.cs index 54d33b3..87f94be 100644 --- a/MaterialTraceability.Business/PlcBusiness.cs +++ b/MaterialTraceability.Business/PlcBusiness.cs @@ -287,11 +287,11 @@ namespace MaterialTraceability.Business } } - private void readplc(object o) + private async void readplc(object o) { while (ReadContinue) { - Thread.Sleep(appConfig.plcSingalReadTime); + try { //获取工序编号 TB-涂布、LY冷压预分切、MQ-模切、JR-卷绕 @@ -617,7 +617,7 @@ namespace MaterialTraceability.Business //A放卷结束信号 if (plcInstance.readInteractiveSignal(appConfig.LyAddress.A放卷结束) == 1) { - plcInstance.writeInt16ByAddress(appConfig.LyAddress.A放卷结束, 2); + plcInstance.writeInt16ByAddress(appConfig.LyAddress.A放卷结束, 0); if (isReadFlag(ref LastEndTime, 30)) { @@ -627,37 +627,50 @@ namespace MaterialTraceability.Business //B放卷结束信号 if (plcInstance.readInteractiveSignal(appConfig.LyAddress.B放卷结束) == 1) { - plcInstance.writeInt16ByAddress(appConfig.LyAddress.B放卷结束, 2); + plcInstance.writeInt16ByAddress(appConfig.LyAddress.B放卷结束, 0); if (isReadFlag(ref LastEndTime, 30)) { - SignalRefreshEvent?.Invoke(2, 9); } } //收卷涨紧信号-1A气胀轴 if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1A涨紧) == 1) { + //LogHelper.Info("1A涨紧信号"); plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷1A涨紧, 0); - SignalRefreshEvent?.Invoke(3, 1); + lock (string.Empty) + { + SignalRefreshEvent?.Invoke(3, 1); + } } //收卷涨紧信号-1B气胀轴 if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷1B涨紧) == 1) - { + { LogHelper.Info("1A涨紧信号"); plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷1B涨紧, 0); - SignalRefreshEvent?.Invoke(3, 2); + lock (string.Empty) + { + SignalRefreshEvent?.Invoke(3, 2); + } + } //收卷涨紧信号-2A气胀轴 if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2A涨紧) == 1) { + //LogHelper.Info("2A涨紧信号"); plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷2A涨紧, 0); - SignalRefreshEvent?.Invoke(3, 3); - + lock (string.Empty) + { + SignalRefreshEvent?.Invoke(3, 3); + } } //收卷涨紧信号-2B气胀轴 if (plcInstance.readInteractiveSignal(appConfig.LyAddress.收卷2B涨紧) == 1) { plcInstance.writeInt16ByAddress(appConfig.LyAddress.收卷2B涨紧, 0); - SignalRefreshEvent?.Invoke(3, 4); + lock (string.Empty) + { + SignalRefreshEvent?.Invoke(3, 4); + } } //收卷结束信号-1A气胀轴 @@ -2132,6 +2145,8 @@ namespace MaterialTraceability.Business #endregion 开始过账信号 } #endregion + await Task.Delay(appConfig.plcSingalReadTime); + //Thread.Sleep(appConfig.plcSingalReadTime); } catch (Exception ex) { diff --git a/MaterialTraceability.Rfid/Impl/RFly_I160Adapter.cs b/MaterialTraceability.Rfid/Impl/RFly_I160Adapter.cs index 31e8904..ea55a9a 100644 --- a/MaterialTraceability.Rfid/Impl/RFly_I160Adapter.cs +++ b/MaterialTraceability.Rfid/Impl/RFly_I160Adapter.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using System.Threading; +using System.Threading.Tasks; namespace MaterialTraceability.Rfid.Impl { @@ -1492,13 +1493,13 @@ namespace MaterialTraceability.Rfid.Impl //m_OneEpcSem.WaitOne(1, false); GetAllRelese(m_OneEpcSem); - LogHelper.SemaphoreLog("信号量m_OneEpcSem,WaitOne(1, false)"); + //LogHelper.SemaphoreLog("信号量m_OneEpcSem,WaitOne(1, false)"); m_OneEpcDataLen = 0; DeviceType = devicetype; if (m_ICommunicateService.SendMessage(pMessagePack)) //发送报文成功 { m_ReadDataSuccessful = true; - LogHelper.SemaphoreLog("信号量m_OneEpcSem,WaitOne("+ waitTime + ", false)"); + //LogHelper.SemaphoreLog("信号量m_OneEpcSem,WaitOne("+ waitTime + ", false)"); if (m_OneEpcSem.WaitOne(waitTime+2000, false)) //等待结果,并取结果返回。 { if (m_OneEpcDataLen > 0) //有数据,正常 diff --git a/MaterialTraceabilityUI/App.config b/MaterialTraceabilityUI/App.config index 7fd8e19..8bf35d9 100644 --- a/MaterialTraceabilityUI/App.config +++ b/MaterialTraceabilityUI/App.config @@ -40,8 +40,8 @@ - - + + diff --git a/MaterialTraceabilityUI/SplitSfc.xaml.cs b/MaterialTraceabilityUI/SplitSfc.xaml.cs index e8f80cc..30e2217 100644 --- a/MaterialTraceabilityUI/SplitSfc.xaml.cs +++ b/MaterialTraceabilityUI/SplitSfc.xaml.cs @@ -175,22 +175,22 @@ namespace MaterialTraceabilityUI //根据当前轴写入PLC下料OK if (appConfig.PLCType != ("LY4NKLYPLcAddress") && appConfig.PLCType != ("LY4YHLYPLcAddress")) { - //if (positionId == 1 || positionId == 2) - //{ - // plcBusiness.writePlc(appConfig.LyAddress.收卷下料1AOK, 1); - //} - //else if (positionId == 3 || positionId == 4) - //{ - // plcBusiness.writePlc(appConfig.LyAddress.收卷下料1BOK, 1); - //} - //else if (positionId == 5 || positionId == 6) - //{ - // plcBusiness.writePlc(appConfig.LyAddress.收卷下料2AOK, 1); - //} - //else if (positionId == 7 || positionId == 8) - //{ - // plcBusiness.writePlc(appConfig.LyAddress.收卷下料2BOK, 1); - //} + if (positionId == 1 || positionId == 2) + { + plcBusiness.writePlc(appConfig.LyAddress.收卷1A控制下料, 1); + } + else if (positionId == 3 || positionId == 4) + { + plcBusiness.writePlc(appConfig.LyAddress.收卷1B控制下料, 1); + } + else if (positionId == 5 || positionId == 6) + { + plcBusiness.writePlc(appConfig.LyAddress.收卷2A控制下料, 1); + } + else if (positionId == 7 || positionId == 8) + { + plcBusiness.writePlc(appConfig.LyAddress.收卷2B控制下料, 1); + } } MessageBox.Show("手动拆分成功ea:" + eaStr); diff --git a/MaterialTraceabilityUI/firstPage.xaml b/MaterialTraceabilityUI/firstPage.xaml index 48f1bd2..86ab9bd 100644 --- a/MaterialTraceabilityUI/firstPage.xaml +++ b/MaterialTraceabilityUI/firstPage.xaml @@ -28,7 +28,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -49,7 +49,7 @@ - + diff --git a/MaterialTraceabilityUI/firstPage.xaml.cs b/MaterialTraceabilityUI/firstPage.xaml.cs index c30bcb6..fa50c41 100644 --- a/MaterialTraceabilityUI/firstPage.xaml.cs +++ b/MaterialTraceabilityUI/firstPage.xaml.cs @@ -576,7 +576,7 @@ namespace MaterialTraceabilityUI /// /// /// - private void upMaterial_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + private void upMaterial_MouseDown_A(object sender, System.Windows.Input.MouseButtonEventArgs e) { try { @@ -589,6 +589,20 @@ namespace MaterialTraceabilityUI LogHelperBusiness.LogError("界面upMaterial_MouseDown异常", ex); } } + private void upMaterial_MouseDown_B(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + try + { + WriteInfo write = new WriteInfo(appConfig.processId, 9); + write.ShowDialog(); + + refreshMaterialInfo(appConfig.processId, "9"); + } + catch (Exception ex) + { + LogHelperBusiness.LogError("界面upMaterial_MouseDown异常", ex); + } + } /// /// 收卷1轴内侧