Commit a4ccb556 LN

日志错误修改。去掉清理内存代码。

1 个父辈 8d6dc742
...@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoCountClient", "source\A ...@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoCountClient", "source\A
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserFromControl", "source\UserFromControl\UserFromControl.csproj", "{F018462A-D9BC-4365-97F2-F6D71751641E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserFromControl", "source\UserFromControl\UserFromControl.csproj", "{F018462A-D9BC-4365-97F2-F6D71751641E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeLibrary", "source\CodeLibrary\CodeLibrary.csproj", "{2E0D9598-CB37-46DC-9C9B-D36D4D344451}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -45,6 +47,10 @@ Global ...@@ -45,6 +47,10 @@ Global
{F018462A-D9BC-4365-97F2-F6D71751641E}.Debug|Any CPU.Build.0 = Debug|Any CPU {F018462A-D9BC-4365-97F2-F6D71751641E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.ActiveCfg = Release|Any CPU {F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.Build.0 = Release|Any CPU {F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.Build.0 = Release|Any CPU
{2E0D9598-CB37-46DC-9C9B-D36D4D344451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E0D9598-CB37-46DC-9C9B-D36D4D344451}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E0D9598-CB37-46DC-9C9B-D36D4D344451}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E0D9598-CB37-46DC-9C9B-D36D4D344451}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -432,8 +432,8 @@ namespace OnlineStore.AutoCountClient ...@@ -432,8 +432,8 @@ namespace OnlineStore.AutoCountClient
} }
} }
#endregion #endregion
private void LogM() private void LogM()
{ {
try try
{ {
...@@ -456,7 +456,7 @@ namespace OnlineStore.AutoCountClient ...@@ -456,7 +456,7 @@ namespace OnlineStore.AutoCountClient
LogUtil.info(sbResult.ToString()); LogUtil.info(sbResult.ToString());
} }
ClearMemory(); //ClearMemory();
} }
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -7,6 +7,7 @@ using System.Reflection; ...@@ -7,6 +7,7 @@ using System.Reflection;
using System.Drawing; using System.Drawing;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Threading;
namespace OnlineStore.Common namespace OnlineStore.Common
{ {
...@@ -89,7 +90,7 @@ namespace OnlineStore.Common ...@@ -89,7 +90,7 @@ namespace OnlineStore.Common
} }
public static void error(ILog log, string errorMsg, Exception ex = null) public static void error(ILog log, string errorMsg, Exception ex = null)
{ {
if (errorMsg.Trim().Equals("")&&(ex==null)) if (errorMsg.Trim().Equals("") && (ex == null))
{ {
return; return;
} }
...@@ -103,15 +104,27 @@ namespace OnlineStore.Common ...@@ -103,15 +104,27 @@ namespace OnlineStore.Common
} }
AddToBox(errorMsg, Color.Red); AddToBox(errorMsg, Color.Red);
} }
private static object lockObj = "";
private static void AddToBox(string msg, Color color) private static void AddToBox(string msg, Color color)
{ {
try if (Monitor.TryEnter(lockObj, 2))
{ {
ShowLogPro(msg, color); try
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
LOGGER.Error("出错:", ex);
}
finally
{
Monitor.Exit(lockObj);
}
} }
catch (Exception ex) else
{ {
LOGGER.Error("出错:",ex); LOGGER.Debug("ShowLogPro【" + msg + "】失败,未得到锁");
} }
} }
private static List<string> logList = new List<string>(); private static List<string> logList = new List<string>();
...@@ -121,10 +134,6 @@ namespace OnlineStore.Common ...@@ -121,10 +134,6 @@ namespace OnlineStore.Common
{ {
try try
{ {
if (logList.Count > 0)
{
// logList.RemoveAt(0);
}
if (logList.Count >= showCount) if (logList.Count >= showCount)
{ {
logList.RemoveAt(0); logList.RemoveAt(0);
...@@ -166,7 +175,7 @@ namespace OnlineStore.Common ...@@ -166,7 +175,7 @@ namespace OnlineStore.Common
LOGGER.Error("出错:" + ex.ToString()); LOGGER.Error("出错:" + ex.ToString());
} }
} }
private static DateTime lastTime = DateTime.Now; private static DateTime lastTime = DateTime.Now;
public static void UpdateLogbox() public static void UpdateLogbox()
{ {
if (logBox != null && logBox.Visible) if (logBox != null && logBox.Visible)
...@@ -184,7 +193,7 @@ namespace OnlineStore.Common ...@@ -184,7 +193,7 @@ namespace OnlineStore.Common
} }
public static void ClearLog() public static void ClearLog()
{ {
if (logBox != null) if (logBox != null)
{ {
LastText = ""; LastText = "";
...@@ -196,9 +205,9 @@ namespace OnlineStore.Common ...@@ -196,9 +205,9 @@ namespace OnlineStore.Common
{ {
debug(LOGGER, msg); debug(LOGGER, msg);
} }
public static void error(string errorMsg,Exception ex=null) public static void error(string errorMsg, Exception ex = null)
{ {
error(LOGGER, errorMsg,ex); error(LOGGER, errorMsg, ex);
} }
public static void info(string msg) public static void info(string msg)
{ {
......
...@@ -57,9 +57,6 @@ ...@@ -57,9 +57,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\Client.dll</HintPath> <HintPath>..\..\dll\Client.dll</HintPath>
</Reference> </Reference>
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="CountImage"> <Reference Include="CountImage">
<HintPath>..\..\dll\X-Ray\CountImage.dll</HintPath> <HintPath>..\..\dll\X-Ray\CountImage.dll</HintPath>
</Reference> </Reference>
...@@ -157,6 +154,10 @@ ...@@ -157,6 +154,10 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\CodeLibrary\CodeLibrary.csproj">
<Project>{2e0d9598-cb37-46dc-9c9b-d36d4d344451}</Project>
<Name>CodeLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\Common\Common.csproj"> <ProjectReference Include="..\Common\Common.csproj">
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project> <Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name> <Name>Common</Name>
......
...@@ -456,10 +456,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -456,10 +456,10 @@ namespace OnlineStore.DeviceLibrary
{ {
level = WorkLogLevel; level = WorkLogLevel;
} }
//if (level <= WorkLogLevel) if (level <= WorkLogLevel)
//{ {
// level = WorkLogLevel; level = WorkLogLevel;
//} }
string code = ""; string code = "";
if (MoveInfo.MoveParam != null && MoveInfo.MoveParam.WareCode != null) if (MoveInfo.MoveParam != null && MoveInfo.MoveParam.WareCode != null)
{ {
...@@ -484,7 +484,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -484,7 +484,10 @@ namespace OnlineStore.DeviceLibrary
{ {
level = SecWorkLogLevel; level = SecWorkLogLevel;
} }
//level = SecWorkLogLevel; if (level < SecWorkLogLevel)
{
level = SecWorkLogLevel;
}
string code = SecMoveInfo.MoveParam != null ? SecMoveInfo.MoveParam.WareCode : ""; string code = SecMoveInfo.MoveParam != null ? SecMoveInfo.MoveParam.WareCode : "";
if (level.Equals(1)) if (level.Equals(1))
{ {
...@@ -694,15 +697,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -694,15 +697,15 @@ namespace OnlineStore.DeviceLibrary
if (isInSuddenDown.Equals(false)) if (isInSuddenDown.Equals(false))
{ {
LogUtil.error(Name + "收到急停信号,等待200后再次验证急停"); LogUtil.error(Name + "收到急停信号,等待200后再次验证急停");
Task.Factory.StartNew(delegate //Task.Factory.StartNew(delegate
{ //{
Thread.Sleep(200); Thread.Sleep(200);
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{ {
SetWarnMsg("收到急停信号,报警急停"); SetWarnMsg("收到急停信号,报警急停");
Alarm(AlarmType.SuddenStop); Alarm(AlarmType.SuddenStop);
} }
}); //});
} }
} }
else if (fuweiValue.Equals(IO_VALUE.HIGH) && (!fuweiValue.Equals(lastFuwei))) else if (fuweiValue.Equals(IO_VALUE.HIGH) && (!fuweiValue.Equals(lastFuwei)))
......
...@@ -157,7 +157,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -157,7 +157,7 @@ namespace OnlineStore.DeviceLibrary
findRightCode = HasRightCode(str); findRightCode = HasRightCode(str);
} }
} }
} }
} }
if (!findRightCode) if (!findRightCode)
{ {
...@@ -182,8 +182,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -182,8 +182,8 @@ namespace OnlineStore.DeviceLibrary
{ {
if (ho_Image != null) if (ho_Image != null)
{ {
ho_Image.Dispose(); HalconDotNet.HOperatorSet.ClearObj(ho_Image);
} }
} }
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!