From 8ab19ae17dc98d3c79f87ca54aa4cdc75d174b12 Mon Sep 17 00:00:00 2001 From: cjs <2216046164@qq.com> Date: 星期三, 18 六月 2025 17:10:30 +0800 Subject: [PATCH] 111 --- ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs | 121 +++++++++++++++++++-------------------- 1 files changed, 59 insertions(+), 62 deletions(-) diff --git a/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs b/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs index afa5106..d541128 100644 --- a/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs +++ b/ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs @@ -2026,62 +2026,6 @@ } } } - - /// <summary> - /// 3妤兼墦鍖呮満涓嬬嚎锛屽垽鏂墦鍖呮満鏄惁鐢辩敓鎴愭墦鍖呬笅绾跨殑浠诲姟锛堝洓閽磋溅闂达級 - /// </summary> - /// <param name="plc"></param> - internal static void CheckPackingLineFullTwo(Settings.PlcInfo plc) - { - //璇籶lc淇″彿锛岀湅鏈夋病鏈変笅绾胯姹傦紝鍒ゆ柇鏄惁宸茬粡鏈変换鍔�- //娌℃湁浠诲姟锛岀户缁璸lc锛屽寘瑁呬笅绾跨殑鐗╂枡淇″彿 - //妫�煡鎵撳寘鏈洪�閬�鏄惁鏈夊嚭鏂欎换鍔′俊鍙凤紝濡傛灉鏈夌敓鎴愬彇鏂欎换鍔°� - if (CheckStartFree(plc.location)) - { - try - { - var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel - { - dataNum = 1, - addr = plc.readAddr + 1, - host = plc.ip, - port = plc.port - }); - if (result != null && result.errCode == 0) - { - if (result.result[0] == 1) - { - //鑾峰彇MODBUS閫氶亾閲岄潰瀛樻斁鐨勬椂闂存埑 - var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel - { - addr = plc.readAddr + 10, - host = plc.ip, - port = plc.port, - dataNum = 170 - }); - if (resultTime.errCode == 0) - { - string wmstaskno = ""; - TimeCuoInfoComTwo timecuo = TimeCuoTwo(resultTime.result); - if (timecuo != null) - { - string timeStamp = timecuo.TimeCuo; - //string employeeId = timecuo.employeeId1; - //// ERP鍙樻洿-璋冪敤ERP鎺ュ彛浼犺緭鐩稿叧鏁版嵁 - //WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeStamp, timeStamp, employeeId,true); - } - else CMMLog.Info($"鏃堕棿鎴虫帴鍙h繑鍥炲�涓虹┖锛�); - } - else CMMLog.Info($"MODBUS鏃堕棿鎴虫暟鎹繑鍥炲�閿欒锛氳繑鍥炲�瑙f瀽锛歿JsonConvert.SerializeObject(result)}"); - } - } - } - catch (Exception ex) - { - CMMLog.Error(ex.Message); - } - } - } #endregion #region 鎵撳寘鏈哄嚭鍙ODBUS浜や簰锛堝紑濮嬪彇鏂欙紝鍙栨枡瀹屾垚锛�@@ -2090,9 +2034,9 @@ /// 璁惧鍏佽鍑烘枡 1 PLC鍐欙紝AMS璇�1-璁惧璇锋眰鍑烘枡锛�-鍏佽杩涘叆锛�-纭璐х墿鍙栬蛋锛岄�鍑虹墿鏂欙紱 ///鎵撳寘绾夸笅绾库�鈥斿皬杞﹀紑濮嬪彇璐�- internal static void PackingLineUnload1012(string ip, string taskNo) + internal static void PackingLineUnload1012(string ip, string taskNo, int port) { - var plc = Settings.GetPlcInfo().Where(a => a.deviceType == "4").FirstOrDefault(); + var plc = Settings.GetPlcInfo().Where(a => a.ip == ip && a.port == port).FirstOrDefault(); if (plc != null) { try @@ -2141,11 +2085,11 @@ /// </summary> /// <param name="ip"></param> /// <param name="taskNo"></param> - internal static void PackingLineComplete4(string ip, string taskNo) + internal static void PackingLineComplete4(string ip, string taskNo, int port) { //鍙栬揣瀹屾垚鍚庨渶瑕佽鍙栬澶囨椂闂存埑閲岄潰鐨勬暟鎹紝骞跺皢鍏舵殏瀛樿嚦涓棿琛ㄧ瓑鍒板叆搴撲换鍔″畬鎴愪紶杈撶粰WMS - var plc = Settings.GetPlcInfo().Where(a => a.deviceType == "4").FirstOrDefault(); + var plc = Settings.GetPlcInfo().Where(a => a.ip == ip && a.port == port).FirstOrDefault(); if (plc != null) { try @@ -4200,6 +4144,7 @@ internal static void CheckPackingLineFullThree(Settings.PlcInfo plc) { + string trayCode = ""; var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel { dataNum = 25, @@ -4212,7 +4157,7 @@ if (result.result[0] == 1) { //鑾峰彇鐗╂枡淇℃伅 鏍规嵁鎵樼洏鐮佸尯鍒�- string trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//鎵樼洏鐮�+ trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//鎵樼洏鐮� var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("trayCode", trayCode)), "TimeCuoInfoComTwo"); @@ -4244,11 +4189,63 @@ }); string materialCode = RemoveNull(GetTrayCode(result.result.Skip(0).Take(15).ToArray()).Trim().ToString()); - UpdateBuilder update = Update.Set("materialCode", materialCode); + UpdateBuilder update = Update.Set("materialCode", materialCode).Set("createTime",DateTime.Now); MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), update, UpdateFlags.None); + + var writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel + { + host = plc.ip, + addr = plc.writeAddr, + data = 1, + port = plc.port + }); + CMMLog.Debug($"鍐欏叆璁惧{plc.location}閫氶亾{plc.writeAddr}閲岄潰鏁版嵁涓�."); } } } + + var xxPlc = Settings.GetPlcInfo().Where(a => a.deviceType == "27" && a.enable == 1).FirstOrDefault(); + if(xxPlc != null) + { + result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel + { + dataNum = 1, + addr = plc.readAddr + 1, + host = plc.ip, + port = plc.port + }); + if(result != null && result.errCode == 0) + { + if (result.result[0] == 1) + { + var resultTime = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel + { + dataNum = 2, + addr = plc.readAddr + 8, + host = plc.ip, + port = plc.port + }); + if (resultTime.errCode == 0) + { + string timeCuoData = (resultTime.result[0] * 65536 + resultTime.result[1]).ToString(); + TimeCuoInfoComTwo time = null; + var timeTwo = MongoDBSingleton.Instance.Find<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), "TimeCuoInfoComTwo"); + if(timeTwo.Count > 0) + { + time = timeTwo.OrderBy(a => a.createTime).FirstOrDefault(); + MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("_id", time._id),Update.Set("TimeCuo", timeCuoData)); + } + string wmstaskno = ""; + WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeCuoData, timeCuoData, time.employeeId, true); + } + } + } + } + else + { + CMMLog.Info("涓嬬嚎鍙h澶囨湭閰嶇疆"); + } + } #endregion } -- Gitblit v1.9.1