Commit 70741fd3 几米阳光

超时日志10秒打印一次

1 个父辈 a2234284
...@@ -72,16 +72,12 @@ namespace OnlineStore.Common ...@@ -72,16 +72,12 @@ namespace OnlineStore.Common
AddToBox(msg, Color.Gray); AddToBox(msg, Color.Gray);
} }
} }
public static void error( string errorMsg,int type)
//private static List<string> lasErrorLogList = new List<string>();
private static int errCount = 5;
public static void error(ILog log, string errorMsg,int type)
{ {
if (lastErrorLogTime.ContainsKey(type)) if (lastErrorLogTime.ContainsKey(type))
{ {
TimeSpan span = DateTime.Now - lastErrorLogTime[type]; TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds < 5) if (span.TotalSeconds < 10)
{ {
return; return;
} }
...@@ -89,13 +85,13 @@ namespace OnlineStore.Common ...@@ -89,13 +85,13 @@ namespace OnlineStore.Common
{ {
lastErrorLogTime.Remove(type); lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now); lastErrorLogTime.Add(type, DateTime.Now);
error(log, errorMsg); error( errorMsg);
} }
} }
else else
{ {
lastErrorLogTime.Add(type, DateTime.Now); lastErrorLogTime.Add(type, DateTime.Now);
error(log, errorMsg); error( errorMsg);
} }
} }
public static void error(ILog log, string errorMsg) public static void error(ILog log, string errorMsg)
......
...@@ -185,7 +185,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -185,7 +185,7 @@ namespace OnlineStore.DeviceLibrary
ConfigIO io = Config.getWaitIO(wait.IoType); ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = StoreName + " 等待信号" + io.DisplayStr + "=" + wait.IoValue + "超时!"; WarnMsg = StoreName + " 等待信号" + io.DisplayStr + "=" + wait.IoValue + "超时!";
Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType); Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType);
LogUtil.error(LOGGER, StoreName + wait.IoType + "等待信号(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", 14); LogUtil.error( StoreName + wait.IoType + "等待信号(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", 14);
isOk = false; isOk = false;
break; break;
} }
...@@ -258,7 +258,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -258,7 +258,7 @@ namespace OnlineStore.DeviceLibrary
{ {
WarnMsg = WarnMsg + "\r\n" + wait.ToStr(); WarnMsg = WarnMsg + "\r\n" + wait.ToStr();
} }
LogUtil.error(LOGGER, WarnMsg, 12); LogUtil.error( WarnMsg, 12);
} }
else else
{ {
......
...@@ -56,7 +56,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -56,7 +56,7 @@ namespace OnlineStore.DeviceLibrary
//else //else
//{ //{
msg = Name + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警"; msg = Name + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(msg); LogUtil.error(msg,100);
return false; return false;
//} //}
} }
...@@ -99,7 +99,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -99,7 +99,7 @@ namespace OnlineStore.DeviceLibrary
ConfigIO io = StoreManager.Config.getWaitIO(wait.IoType); ConfigIO io = StoreManager.Config.getWaitIO(wait.IoType);
WarnMsg = "[" + StoreMove.MoveStep + "] 等待[" + io.ElectricalDefinition + "_" + io.Explain + "=" + wait.IoValue + "]超时"; WarnMsg = "[" + StoreMove.MoveStep + "] 等待[" + io.ElectricalDefinition + "_" + io.Explain + "=" + wait.IoValue + "]超时";
StoreManager.Store.Alarm(StoreAlarmType.BatchIoTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType); StoreManager.Store.Alarm(StoreAlarmType.BatchIoTimeOut, io.ElectricalDefinition, WarnMsg, StoreMove.MoveType);
LogUtil.error(WarnMsg); LogUtil.error(WarnMsg,101);
isOk = false; isOk = false;
break; break;
} }
...@@ -164,7 +164,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -164,7 +164,7 @@ namespace OnlineStore.DeviceLibrary
else if (span.TotalSeconds > StoreMove.TimeOutSeconds) else if (span.TotalSeconds > StoreMove.TimeOutSeconds)
{ {
WarnMsg = "[" + StoreMove.MoveStep + "]等待[" + NotOkMsg + "]超时[" + Math.Round(span.TotalSeconds, 0) + "秒]"; WarnMsg = "[" + StoreMove.MoveStep + "]等待[" + NotOkMsg + "]超时[" + Math.Round(span.TotalSeconds, 0) + "秒]";
LogUtil.error(WarnMsg); LogUtil.error(WarnMsg,102);
StoreManager.Store.Alarm(StoreAlarmType.BatchIoTimeOut, "", WarnMsg, StoreMove.MoveType); StoreManager.Store.Alarm(StoreAlarmType.BatchIoTimeOut, "", WarnMsg, StoreMove.MoveType);
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!