From 696b87e0f494eff98e1646fbde133430f22b1543 Mon Sep 17 00:00:00 2001
From: IPC-610 <IPC-610@DESKTOP-6LEOOS3>
Date: 星期日, 20 十月 2024 18:48:44 +0800
Subject: [PATCH] bug修复
---
Admin.NET/WCS.Application/PLC/PLCService.cs | 84 ++++++++++++++++++++++++----
Admin.NET/WCS.Application/Util/LedDll.cs | 87 +++++++++++++++++++++++++++++
Admin.NET/WCS.Application/PLC/PLCCommon.cs | 2
Admin.NET/WCS.Application/PLC/PLCTaskAction.cs | 4 +
4 files changed, 163 insertions(+), 14 deletions(-)
diff --git a/Admin.NET/WCS.Application/PLC/PLCCommon.cs b/Admin.NET/WCS.Application/PLC/PLCCommon.cs
index e020f08..aef594d 100644
--- a/Admin.NET/WCS.Application/PLC/PLCCommon.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCCommon.cs
@@ -328,7 +328,7 @@
public static PLCUtil GetPlcIp(string startStation)
{
string strIp = "";
- var conveyList1 = new List<string>() { "147", "145", "139", "137", "129", "127", "121", "119", "111", "109", "103", "101", "093", "091", "085", "083", "075", "073", "067", "065","033" };
+ var conveyList1 = new List<string>() { "147", "145", "139", "137", "129", "127", "121", "119", "111", "109", "103", "101", "093", "091", "085", "083", "075", "073", "067", "065","033","039","044" ,"051","059"};
var conveyList2 = new List<string>() { "205", "234", "252", "254", "260", "262", "270", "272", "278", "280", "288", "290", "294", "301", "307", "309", "315", "317", "325", "327", "331", "337" };
var conveyList3 = new List<string>() { "401", "402", "405", "406", "409", "410", "413", "414", "417", "418", "421", "422", "425", "426", "429", "430", "433", "434", "437", "438" };
if (conveyList1.Contains(startStation))
diff --git a/Admin.NET/WCS.Application/PLC/PLCService.cs b/Admin.NET/WCS.Application/PLC/PLCService.cs
index 0c8d371..31c9009 100644
--- a/Admin.NET/WCS.Application/PLC/PLCService.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCService.cs
@@ -64,7 +64,7 @@
// 璺烘満绌洪棽锛岃幏鍙栧嚭搴撲换鍔°�佺Щ搴撲换鍔�
{
// 鑾峰彇浠诲姟淇℃伅
- var modTask = _db.Queryable<WcsTask>().OrderBy(m => m.CreateTime).OrderBy(m => m.Levels, OrderByType.Asc)
+ var modTask = _db.Queryable<WcsTask>().OrderBy(m => m.Levels, OrderByType.Asc).OrderBy(m => m.CreateTime)
.First(s => s.Status == TaskStatusEnum.Wait && (s.TaskType == TaskTypeEnum.Out || s.TaskType == TaskTypeEnum.Move)
&& s.StartRoadway == modDevice.StationNum);
if (modTask == null)
@@ -422,7 +422,7 @@
}
else
{
- Log.Error(string.Format("浠诲姟鍙嶉澶辫触锛歋tatusCode锛歿0};Msg锛歿1}", modResponseTask.StatusCode, modResponseTask.Msg));
+ Log.Error(string.Format("c锛歋tatusCode锛歿0};Msg锛歿1}", modResponseTask.StatusCode, modResponseTask.Msg));
}
}
// 鏍规嵁浠诲姟鍙疯幏鍙栬捣濮嬪伐浣嶅湴鍧�锛屾牴鎹捣濮嬪伐浣嶅湴鍧�鑾峰彇LEDIP 鎺ㄩ�佸埌LED灞忓箷銆�
@@ -897,11 +897,7 @@
// 鐢宠宸烽亾
string strMsg = "";
string taskModel = "";
- // 鍒ゆ柇鏄惁婕旂ず妯″紡
- //if (PLCTaskAction.boDemo)
- //{
- // taskModel = "1";// 婕旂ず妯″紡
- //}
+
// 鑾峰彇宸ヤ綅鎵樼洏鐮佷俊鎭�
var modPosPallet = modDevice.listStation.FirstOrDefault(m => m.Text == "鎵樼洏鐮�");
var (res, palletVal) = plcConn.GetPlcDBValue(PLCDataTypeEnum.String, modDevice.DbNumber, modPosPallet.PlcPos);
@@ -909,6 +905,46 @@
{
break;
}
+ var modPosEndLocat = modDevice.listStation.FirstOrDefault(s => s.Text == "鐩殑宸ヤ綅");
+
+
+ //鍒ゆ柇鍏ュ簱閿佸畾鏄惁鎵撳紑
+ if (PLCTaskAction.boEnterLock)
+ {
+ var (res350, palletVal350) = plcConn.GetPlcDBValue(PLCDataTypeEnum.String, modDevice.DbNumber, modPosPallet.PlcPos);
+ if (res350.IsSucceed && palletVal350 != "350")
+ {
+ LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modDevice.StationNum, "鐢宠鍏ュ簱 " + $"鍏ュ簱浠诲姟宸查攣瀹氾紝璇疯В閿佸悗閲嶈瘯", "鎵樼洏鍙�:" + palletVal);
+ }
+
+ // 鍐欏叆杈撻�佺嚎閫�鍥炴寚浠�
+ var ret = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modPosEndLocat.PlcPos, modDevice.StationNum);
+ if (ret.IsSucceed)
+ {
+ plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "350");
+ }
+
+ break;
+ }
+
+ if (palletVal == null)
+ {
+ var (res350, palletVal350) = plcConn.GetPlcDBValue(PLCDataTypeEnum.String, modDevice.DbNumber, modPosPallet.PlcPos);
+ if (res350.IsSucceed && palletVal350 != "350")
+ {
+ LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modDevice.StationNum, "鐢宠鍏ュ簱 " + $"鎵弿鎵樼洏鍙峰け璐�!", "鎵樼洏鍙�:" + palletVal);
+ }
+
+ // 鍐欏叆杈撻�佺嚎閫�鍥炴寚浠�
+ var ret = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modPosEndLocat.PlcPos, modDevice.StationNum);
+ if (ret.IsSucceed)
+ {
+ plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "350");
+ }
+
+ break;
+ }
+
var http = new HttpService();
string TaskNo = "", EndLocate = "";
strMsg = http.RequestRoadWay(palletVal, modDevice.StationNum, taskModel, louCeng, ref EndLocate, ref TaskNo);
@@ -943,13 +979,34 @@
// 閫氱煡浠诲姟鐣岄潰浠诲姟宸插瓨鍦ㄦ洿鏂� 璇锋洿鏂扮晫闈�
HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>());
// led鏄剧ず鍐呭
- LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modDevice.StationNum, "鐢宠鍏ュ簱 " + $"鐩爣宸烽亾锛歿EndLocate}", "鎵樼洏鍙�:" + palletVal);
+ try
+ {
+ LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modDevice.StationNum, "鐢宠鍏ュ簱 " + $"鐩爣宸烽亾锛歿taskInfo.EndRoadway}鍙栬揣宸ヤ綅锛歿EndLocate}", "鎵樼洏鍙�:" + palletVal);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex.Message);
+ }
+
}
}
else
{
- // 鐢宠宸烽亾澶辫触锛丩ED鏄剧ず
+ var (res350, palletVal350) = plcConn.GetPlcDBValue(PLCDataTypeEnum.String, modDevice.DbNumber, modPosPallet.PlcPos);
+ if (res350.IsSucceed && palletVal350 != "350")
+ {
+ LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modDevice.StationNum, "鐢宠鍏ュ簱 " + $"鐢宠宸烽亾澶辫触锛歿strMsg}", "鎵樼洏鍙�:" + palletVal);
+ }
+
+ // 鍐欏叆杈撻�佺嚎閫�鍥炴寚浠�
+ var ret = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modPosEndLocat.PlcPos, modDevice.StationNum);
+ if (ret.IsSucceed)
+ {
+ plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "350");
+ }
+
+ // 鐢宠宸烽亾澶辫触锛�
Log.Error(string.Format($"鐢宠宸烽亾澶辫触:{strMsg},璇诲啓plc閿欒"));
}
}
@@ -1034,7 +1091,7 @@
HubUtil.PublicTaskMonitor(modInsertTaskMonitor.Adapt<WcsTaskMonitorOutput>());
// led鏄剧ず鍐呭
- LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modDevice.StationNum, "鍏ュ簱涓� " + $"鐩爣宸烽亾锛歿endLocatVlue}", "鎵樼洏鍙�:" + palletVal);
+ LedDisplay(modDevice.LedIP, "宸ヤ綅:" + modDevice.StationNum, "鐢宠鍏ュ簱 " + $"鐩爣宸烽亾锛歿modTask.EndRoadway}鍙栬揣宸ヤ綅锛歿endLocatVlue}", "鎵樼洏鍙�:" + palletVal);
}
}
@@ -1421,7 +1478,7 @@
var modTask = _db.Queryable<WcsTask>().First(m => m.Status == TaskStatusEnum.Doing && m.TaskNo == tasknoVal && m.IsDelete == false);
if (modTask == null)
{
- Log.Error(string.Format($"宸ヤ綅鍙凤細{modDevice.StationNum}绌烘墭鐩樺埌杈撅紝鏈壘鍒板搴旂殑浠诲姟!浠诲姟鍙穥tasknoVal};"));
+ //Log.Error(string.Format($"宸ヤ綅鍙凤細{modDevice.StationNum}绌烘墭鐩樺埌杈撅紝鏈壘鍒板搴旂殑浠诲姟!浠诲姟鍙穥tasknoVal};"));
break;
}
// 鍐欏叆plc娴佺▼瀛�90
@@ -1963,7 +2020,10 @@
LedDll Led = new LedDll();
Led.LEDstr(ip, top, content, foot);
}
- catch { }
+ catch (Exception ex)
+ {
+ Log.Error(ex.Message);
+ }
}
private static void Test(WcsDeviceDto modDevice)
diff --git a/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs b/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
index c044b3a..a60b447 100644
--- a/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCTaskAction.cs
@@ -436,8 +436,10 @@
{
bl = true;
}
+
if (bl != modDevice.BoHaveItem)
{
+ modDevice.BoHaveItem = bl;
var modInfo = new PlcPositionInfo() { Type = modPlc.Type, StationNum = modDevice.StationNum.PadLeft(3, '0'), BoHaveItem = bl };
HubUtil.PublicPosition(modInfo);
UpdatePosition(modInfo);
@@ -459,7 +461,7 @@
}
}
}
- Thread.Sleep(300);
+ Thread.Sleep(3000);
}
catch (Exception ex)
{
diff --git a/Admin.NET/WCS.Application/Util/LedDll.cs b/Admin.NET/WCS.Application/Util/LedDll.cs
index f881361..372a9fa 100644
--- a/Admin.NET/WCS.Application/Util/LedDll.cs
+++ b/Admin.NET/WCS.Application/Util/LedDll.cs
@@ -988,6 +988,93 @@
}
/// <summary>
+ /// LED鏄剧ず
+ /// </summary>
+ /// <param name="m_Ip">LED灞忓箷IP鍦板潃</param>
+ /// <param name="m_text">鏄剧ず鍐呭</param>
+ public void ConsoleLeds(string m_Ip, string m_text)
+ {
+ m_ledWidth = 256;
+ m_ledHeight = 160;
+ m_ledColor = 1;
+ m_ledGrayLevel = 0;
+
+ try
+ {
+ Logger logger = LogManager.GetCurrentClassLogger();
+ int nResult;
+
+ LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();
+ CommunicationInfo.LEDType = 0;
+ //TCP閫氳********************************************************************************
+ CommunicationInfo.SendType = 0; // 璁句负鍥哄畾IP閫氳妯″紡锛屽嵆TCP閫氳
+ CommunicationInfo.IpStr = m_Ip; // 缁橧pStr璧嬪�糒ED鎺у埗鍗$殑IP
+ CommunicationInfo.LedNumber = 1; // LED灞忓彿涓�1锛屾敞鎰弒ocket閫氳鍜�232閫氳涓嶈瘑鍒睆鍙凤紝榛樿璧�1灏辫浜嗭紝485蹇呴渶鏍规嵁灞忕殑瀹為檯灞忓彿杩涜璧嬪��
+ #region 鍒涘缓涓�涓妭鐩�
+ IntPtr hProgram; // 鑺傜洰鍙ユ焺
+ //娉ㄦ剰姝ゅ灞忓楂樺強棰滆壊鍙傛暟蹇呴渶涓庤缃睆鍙傜殑灞忓楂樺強棰滆壊涓�鑷达紝鍚﹀垯鍙戦�佹椂浼氭彁绀洪敊璇�
+ hProgram = LedDll.LV_CreateProgramEx(m_ledWidth, m_ledHeight, m_ledColor, m_ledGrayLevel, 0);
+ nResult = LedDll.LV_AddProgram(hProgram, 0, 0, 1); // 娣诲姞涓�涓妭鐩紝鍙傛暟璇存槑瑙佸嚱鏁板0鏄庢敞绀�
+
+ if (nResult != 0)
+ {
+ string ErrStr = LedDll.LS_GetError(nResult); // liudl 姝ゅ闇�璁板綍Log
+ throw new Exception(ErrStr);
+ }
+ #endregion
+
+
+ #region 鍒涘缓鍖哄煙
+ // 鍖哄煙鑼冨洿鍙橀噺 鍙傛暟璁惧畾
+ LedDll.AREARECT AreaRect = new LedDll.AREARECT();//鍖哄煙鍧愭爣灞炴�х粨鏋勪綋鍙橀噺
+ AreaRect.left = 0;
+ AreaRect.top = 0;
+ AreaRect.width = m_ledWidth;
+ AreaRect.height = 106;
+ LedDll.LV_AddImageTextArea(hProgram, 0, 2, ref AreaRect, 1);
+
+ // 鍖哄煙瀛椾綋鍙橀噺 鍙傛暟璁惧畾
+ LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//鏂囧瓧灞炴��
+ FontProp.FontName = "瀹嬩綋";
+ FontProp.FontSize = 20;
+ FontProp.FontColor = LedDll.COLOR_RED;
+ FontProp.FontBold = 1;
+
+ // 鍖哄煙瀛椾綋杩愯閫熷害 甯﹀叆鏂瑰紡
+ LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP();
+ PlayProp.InStyle = 0;
+ PlayProp.DelayTime = 3;
+ PlayProp.Speed = 2;
+
+
+ // 澶氭枃鏈尯鍩� 鐢ㄤ簬鏄剧ず鎵樼洏淇℃伅
+ nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 0, 2, LedDll.ADDTYPE_STRING, m_text, ref FontProp, ref PlayProp, 0, 0);
+
+ // 鍙戦�佸埌LED灞忓箷
+ nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);
+ LedDll.LV_DeleteProgram(hProgram);
+ #endregion
+
+
+ if (nResult != 0)
+ {
+ string ErrStr;
+ ErrStr = LedDll.LS_GetError(nResult); // liudl 姝ゅ闇�瑕佹坊鍔爈og
+ logger.Error("杩斿洖閿欒淇℃伅A04锛�", ErrStr);
+ }
+ }
+ catch (Exception ex)
+ {
+ // 涓嶆姏鍑哄紓甯革紝闃叉闃荤涓荤▼搴忚繍琛岋紱 Liudl:姝ゅ闇�娣诲姞log
+ //throw ex;
+ Logger logger = LogManager.GetCurrentClassLogger();
+ logger.Error("娴嬭瘯trycatch鎹曟崏鐨勪俊鎭細", ex.Message);
+ }
+ }
+
+
+
+ /// <summary>
/// 鍙戦�佺粰LED 鍗曠嫭鏇存柊瀛楀箷鍖哄煙
/// </summary>
/// <param name="m_ip">LED灞忓箷IP鍦板潃</param>
--
Gitblit v1.8.0