Commit 46aa9c56 张东亮

发送状态死锁造成离线

1 个父辈 e950f5cc
...@@ -105,13 +105,13 @@ namespace DeviceLibrary ...@@ -105,13 +105,13 @@ namespace DeviceLibrary
} }
bool isnglog = false; bool isnglog = false;
public void LogNgInfo(ServerCommunication server) //public void LogNgInfo(ServerCommunication server)
{ //{
if (!isnglog && IsNg) // if (!isnglog && IsNg)
{ // {
isnglog = server.SendNGInfo(NgMsg); // isnglog = server.SendNGInfo(NgMsg);
} // }
} //}
} }
} }
...@@ -158,7 +158,7 @@ namespace DeviceLibrary ...@@ -158,7 +158,7 @@ namespace DeviceLibrary
} }
else if (!RobotManage.isRunning) else if (!RobotManage.isRunning)
{ {
sendmsg = "I="+crc.GetString("Res0127.a5affabf","设备未启动"); sendmsg = "I=" + crc.GetString("Res0127.a5affabf", "设备未启动");
} }
lineOperation.msg = sendmsg; lineOperation.msg = sendmsg;
...@@ -168,9 +168,9 @@ namespace DeviceLibrary ...@@ -168,9 +168,9 @@ namespace DeviceLibrary
lineOperation.msgJp = lineOperation.msg; lineOperation.msgJp = lineOperation.msg;
//lineOperation.boxStatus.Add(StoreID, boxStatus); //lineOperation.boxStatus.Add(StoreID, boxStatus);
lineOperation.data= lineOperation.data.Union(UnifiedDataHandler.PrintNgMESData()).ToDictionary(x=>x.Key,x=>x.Value); lineOperation.data = lineOperation.data.Union(UnifiedDataHandler.PrintNgMESData()).ToDictionary(x => x.Key, x => x.Value);
lineOperation.showLogs = StepInformation(out Dictionary<string,string> dic); lineOperation.showLogs = StepInformation(out Dictionary<string, string> dic);
lineOperation.data =lineOperation.data.Union(dic).ToDictionary(x => x.Key, x => x.Value); lineOperation.data = lineOperation.data.Union(dic).ToDictionary(x => x.Key, x => x.Value);
return lineOperation; return lineOperation;
} }
private static string api_communication = "service/equipment/communication"; //流水线状态通信接口 private static string api_communication = "service/equipment/communication"; //流水线状态通信接口
...@@ -207,7 +207,7 @@ namespace DeviceLibrary ...@@ -207,7 +207,7 @@ namespace DeviceLibrary
{ {
try try
{ {
lock (serverclock) // lock (serverclock)
{ {
bool printlog = false; bool printlog = false;
DateTime time = DateTime.Now; DateTime time = DateTime.Now;
...@@ -232,19 +232,24 @@ namespace DeviceLibrary ...@@ -232,19 +232,24 @@ namespace DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("SendLineStatus",ex); LogUtil.error("SendLineStatus", ex);
}
finally
{
Monitor.Exit(serverclock);
} }
} }
public bool SendAgvLog(string msg) public bool SendAgvLog(string msg)
{ {
if (Monitor.TryEnter(serverclock, TimeSpan.FromSeconds(5))) if (Monitor.TryEnter(serverclock, TimeSpan.FromSeconds(5)))
{ {
try
{
if (!server.ToLower().StartsWith("http")) if (!server.ToLower().StartsWith("http"))
{ {
return false; return false;
} }
lock (serverclock) //lock (serverclock)
{ {
Operation operation = getLineBoxStatus(); Operation operation = getLineBoxStatus();
...@@ -265,6 +270,9 @@ namespace DeviceLibrary ...@@ -265,6 +270,9 @@ namespace DeviceLibrary
} }
return true; return true;
} }
finally { Monitor.Exit(serverclock); }
}
else else
{ {
LogUtil.info($"SendAgvLog 超时"); LogUtil.info($"SendAgvLog 超时");
...@@ -276,11 +284,13 @@ namespace DeviceLibrary ...@@ -276,11 +284,13 @@ namespace DeviceLibrary
{ {
if (Monitor.TryEnter(serverclock, TimeSpan.FromSeconds(5))) if (Monitor.TryEnter(serverclock, TimeSpan.FromSeconds(5)))
{ {
try
{
if (!server.ToLower().StartsWith("http")) if (!server.ToLower().StartsWith("http"))
{ {
return false; return false;
} }
lock (serverclock) // lock (serverclock)
{ {
Operation operation = getLineBoxStatus(); Operation operation = getLineBoxStatus();
...@@ -305,6 +315,12 @@ namespace DeviceLibrary ...@@ -305,6 +315,12 @@ namespace DeviceLibrary
} }
return true; return true;
} }
finally
{
Monitor.Exit(serverclock);
}
}
else else
{ {
LogUtil.info($"OpMIMO超时"); LogUtil.info($"OpMIMO超时");
...@@ -455,9 +471,9 @@ namespace DeviceLibrary ...@@ -455,9 +471,9 @@ namespace DeviceLibrary
/// 获取模板信息 /// 获取模板信息
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<EquipMsg> StepInformation(out Dictionary<string,string> dic) public List<EquipMsg> StepInformation(out Dictionary<string, string> dic)
{ {
dic = new Dictionary<string,string>(); dic = new Dictionary<string, string>();
List<EquipMsg> equipMsgs = new List<EquipMsg>(); List<EquipMsg> equipMsgs = new List<EquipMsg>();
try try
{ {
...@@ -477,12 +493,12 @@ namespace DeviceLibrary ...@@ -477,12 +493,12 @@ namespace DeviceLibrary
//msg.msgParams = new string[] { addressValue.GetStateStr() }; //msg.msgParams = new string[] { addressValue.GetStateStr() };
msg.msg = addressValue.GetStateStr(); msg.msg = addressValue.GetStateStr();
equipMsgs.Add(msg); equipMsgs.Add(msg);
if (addressValue.Name== crc.GetString("Res0039", "右侧取料")) if (addressValue.Name == crc.GetString("Res0039", "右侧取料"))
{ {
dic.Add("inShelfType", ShelfType.smallReel.ToString()); dic.Add("inShelfType", ShelfType.smallReel.ToString());
dic.Add("inShelfStatus", UnifiedDataHandler.ShelfStatus(true,Convert.ToInt32(addressValue.MoveStep))); dic.Add("inShelfStatus", UnifiedDataHandler.ShelfStatus(true, Convert.ToInt32(addressValue.MoveStep)));
} }
if (addressValue.Name== crc.GetString("Res0051", "左侧放料")) if (addressValue.Name == crc.GetString("Res0051", "左侧放料"))
{ {
dic.Add("outShelfType", ShelfType.smallReel.ToString()); dic.Add("outShelfType", ShelfType.smallReel.ToString());
dic.Add("outShelfStatus", UnifiedDataHandler.ShelfStatus(false, Convert.ToInt32(addressValue.MoveStep))); dic.Add("outShelfStatus", UnifiedDataHandler.ShelfStatus(false, Convert.ToInt32(addressValue.MoveStep)));
...@@ -509,8 +525,6 @@ namespace DeviceLibrary ...@@ -509,8 +525,6 @@ namespace DeviceLibrary
public bool SendNGInfo(string ngmsg) public bool SendNGInfo(string ngmsg)
{ {
lock (serverclock)
{
try try
{ {
Operation operation = getLineBoxStatus(); Operation operation = getLineBoxStatus();
...@@ -547,6 +561,9 @@ namespace DeviceLibrary ...@@ -547,6 +561,9 @@ namespace DeviceLibrary
{ {
LogUtil.error($"SendNGInfo error:{ngmsg}", ex); LogUtil.error($"SendNGInfo error:{ngmsg}", ex);
} }
finally
{
Monitor.Exit(serverclock);
} }
return true; return true;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!