From 01503b2809977ecdab703695c8e4bd70324f3c62 Mon Sep 17 00:00:00 2001 From: wxw <Administrator@DESKTOP-5BIMHQ3> Date: 星期二, 25 三月 2025 08:07:04 +0800 Subject: [PATCH] LED屏幕增加实时显示称重重量 --- Admin.NET/WCS.Application/PLC/PLCService.cs | 66 ++++++++++++++++++++++++++++++--- 1 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Admin.NET/WCS.Application/PLC/PLCService.cs b/Admin.NET/WCS.Application/PLC/PLCService.cs index 42ac0e4..0632770 100644 --- a/Admin.NET/WCS.Application/PLC/PLCService.cs +++ b/Admin.NET/WCS.Application/PLC/PLCService.cs @@ -23,6 +23,9 @@ private static readonly object OLock = new object(); private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId); + private static decimal weight94 = 0; + private static decimal weight160 = 0; + private static decimal weight155 = 0; public static void OnChangeEvent(object sender, EventArgs e) { @@ -1192,6 +1195,43 @@ { return; } + + #region#瀹炴椂鏄剧ず閲嶉噺鍒癓ED灞忓箷 + var modPosPalletWeightIng = modDevice.listStation.FirstOrDefault(m => m.Text == "瀹為檯閲嶉噺"); + var (resPalletWeightIng, palletWeightValIng) = plcConn.GetPlcDBValue(modPosPalletWeightIng.PosType, modDevice.DbNumber, modPosPalletWeightIng.PlcPos); + switch (modDevice.StationNum) + { + case "094": + { + if (Convert.ToDecimal(palletWeightValIng) != weight94) + { + LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}"); + weight94 = Convert.ToDecimal(palletWeightValIng); + } + } + break; + case "160": + { + if (Convert.ToDecimal(palletWeightValIng) != weight160) + { + LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}"); + weight160 = Convert.ToDecimal(palletWeightValIng); + } + } + break; + case "155": + { + if (Convert.ToDecimal(palletWeightValIng) != weight155) + { + LedDisplay(modDevice.LedIP, $"褰撳墠閲嶉噺(KG)锛歿Convert.ToDecimal(palletWeightValIng)}"); + weight155 = Convert.ToDecimal(palletWeightValIng); + } + } + break; + } + #endregion + + var ledText = ""; switch (modDevice.Value.ToString()) { @@ -1236,7 +1276,7 @@ break; } - string errorStr = "寮傚父淇℃伅锛�"; + string errorStr = string.Empty; //灏嗗紓甯镐俊鎭樉绀哄埌LED灞忓箷涓� var (errorRes0, errorVal0) = plcConn.GetPlcDBValue(PLCDataTypeEnum.Bit, $"M{dbStr}.0", ""); if (errorRes0.IsSucceed && errorVal0 == true) @@ -1283,9 +1323,15 @@ { errorStr += " 鎵爜浠�氳鎶ヨ"; } - ledText += $"鐢宠鍏ュ簱澶辫触\n\n"; - ledText += $"{errorStr}"; - LedDisplay(modDevice.LedIP, ledText); + + if (!string.IsNullOrEmpty(errorStr)) + { + errorStr = "寮傚父淇℃伅锛�" + errorStr; + + ledText += $"鐢宠鍏ュ簱澶辫触\n\n"; + ledText += $"{errorStr}"; + LedDisplay(modDevice.LedIP, ledText); + } } break; case "320": @@ -2882,12 +2928,20 @@ } } - private static void LedDisplay(string ip,string text) + private static void LedDisplay(string ip,string text,int type=0) { try { LedDll Led = new LedDll(); - Led.ConsoleLeds(ip, text); + if (type == 0) + { + Led.ConsoleLeds(ip, text); + } + else + { + Led.LEDstr(ip, text); + } + // 璁剧疆瀹炰緥 //Led.ConsoleLeds("10.18.51.238", $"浠诲姟绫诲瀷:{TaskTypeEnum.Move.GetDescription()}\n\n浠诲姟鍙�:TK2024102100001\n鎵樼洏鍙�:LN000145\n\n璧峰浣�:033\n鐩爣浣�:R01-02010102"); } -- Gitblit v1.8.0