Commit ccc472e1 LN

IO日志修改

1 个父辈 2fc51fb8
...@@ -47,7 +47,7 @@ namespace Asa.IOModule ...@@ -47,7 +47,7 @@ namespace Asa.IOModule
private readonly byte[] _addressOutput; //输出地址 private readonly byte[] _addressOutput; //输出地址
private const int SEND_SLEEP = 60; //每条命令发送的间隔,不能小于15,会出现IO接收不到的情况,小于30时,会出现接收数据连包的情况 private const int SEND_SLEEP = 60; //每条命令发送的间隔,不能小于15,会出现IO接收不到的情况,小于30时,会出现接收数据连包的情况
private const int PORT = 502; //端口 private const int PORT = 502; //端口
private const int UPLOAD_TIME = 8000; //8秒 private const int UPLOAD_TIME = 3000; //8秒
private Thread tRecon; //重连线程 private Thread tRecon; //重连线程
private Thread tSend; //发送命令处理 private Thread tSend; //发送命令处理
...@@ -135,7 +135,7 @@ namespace Asa.IOModule ...@@ -135,7 +135,7 @@ namespace Asa.IOModule
tRecon.Start(); tRecon.Start();
tSend.Start(); tSend.Start();
tListen.Start(); tListen.Start();
log.Info("Connect"); log.Info(LogName+ "Connect");
} }
/// <summary> /// <summary>
...@@ -153,11 +153,11 @@ namespace Asa.IOModule ...@@ -153,11 +153,11 @@ namespace Asa.IOModule
_client.Shutdown(SocketShutdown.Both); _client.Shutdown(SocketShutdown.Both);
_client.Close(); _client.Close();
} }
log.Info("Close"); log.Info(LogName+ "Close");
} }
catch (Exception ex) catch (Exception ex)
{ {
log.Error("Close", ex); log.Error(LogName+ "Close", ex);
} }
finally finally
{ {
...@@ -290,7 +290,7 @@ namespace Asa.IOModule ...@@ -290,7 +290,7 @@ namespace Asa.IOModule
{ {
try try
{ {
log.Info("call WriteDO"); log.Info(LogName+ "call WriteDO");
byte[] data = Command(); byte[] data = Command();
byte[] buff = new byte[12]; byte[] buff = new byte[12];
...@@ -305,7 +305,7 @@ namespace Asa.IOModule ...@@ -305,7 +305,7 @@ namespace Asa.IOModule
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LogName + "WriteDO ", ex); LogUtil.error(LogName + "WriteDO ", ex);
log.Error("WriteDO ", ex); log.Error(LogName+ "WriteDO ", ex);
return false; return false;
} }
} }
...@@ -404,13 +404,13 @@ namespace Asa.IOModule ...@@ -404,13 +404,13 @@ namespace Asa.IOModule
try try
{ {
_client.Send(buff); _client.Send(buff);
log.Debug("Send: " + HexBuff(buff)); log.Debug(LogName+ "Send: " + HexBuff(buff));
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LogName + "Send Error Socket Close", ex); LogUtil.error(LogName + "Send Error Socket Close", ex);
log.Error("Send Error,Socket Close ", ex); log.Error(LogName+ "Send Error,Socket Close ", ex);
IsConn = false; IsConn = false;
} }
return false; return false;
...@@ -484,7 +484,7 @@ namespace Asa.IOModule ...@@ -484,7 +484,7 @@ namespace Asa.IOModule
_receive.CopyTo(0, cmd, 0, len); _receive.CopyTo(0, cmd, 0, len);
_receive.RemoveRange(0, len); _receive.RemoveRange(0, len);
index++; index++;
log.Debug("Receive: " + HexBuff(cmd)); log.Debug(LogName+ "Receive: " + HexBuff(cmd));
if (IP.Equals("192.168.101.22") && cmd.Length>7&& (cmd[7] == 2)) if (IP.Equals("192.168.101.22") && cmd.Length>7&& (cmd[7] == 2))
{ {
LogUtil.LOGGER.Debug(LogName + " Listen 收到数据 ["+index+"] " + HexBuff(cmd)); LogUtil.LOGGER.Debug(LogName + " Listen 收到数据 ["+index+"] " + HexBuff(cmd));
...@@ -498,7 +498,7 @@ namespace Asa.IOModule ...@@ -498,7 +498,7 @@ namespace Asa.IOModule
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LogName + "Listen ",ex); LogUtil.error(LogName + "Listen ",ex);
log.Error("Listen ", ex); log.Error(LogName+ "Listen ", ex);
IsConn = false; IsConn = false;
} }
} }
...@@ -538,7 +538,7 @@ namespace Asa.IOModule ...@@ -538,7 +538,7 @@ namespace Asa.IOModule
str = "MonitorDO "; str = "MonitorDO ";
for (int i = 0; i < MonitorDO.Length; i++) for (int i = 0; i < MonitorDO.Length; i++)
str += string.Format("[{0}]{1} ", MonitorDO[i], _stateDO[MonitorDO[i]].ToString()); str += string.Format("[{0}]{1} ", MonitorDO[i], _stateDO[MonitorDO[i]].ToString());
log.Info(str); log.Info(LogName+ str);
} }
} }
DO_Changed_Event?.Invoke(this, staDO); DO_Changed_Event?.Invoke(this, staDO);
...@@ -565,7 +565,7 @@ namespace Asa.IOModule ...@@ -565,7 +565,7 @@ namespace Asa.IOModule
str = "MonitorDI "; str = "MonitorDI ";
for (int i = 0; i < MonitorDI.Length; i++) for (int i = 0; i < MonitorDI.Length; i++)
str += string.Format("[{0}]{1} ", MonitorDI[i], _stateDI[MonitorDI[i]].ToString()); str += string.Format("[{0}]{1} ", MonitorDI[i], _stateDI[MonitorDI[i]].ToString());
log.Info(str); log.Info(LogName+ str);
} }
} }
...@@ -630,12 +630,12 @@ namespace Asa.IOModule ...@@ -630,12 +630,12 @@ namespace Asa.IOModule
_client.Connect(IPAddress.Parse(IP), PORT); _client.Connect(IPAddress.Parse(IP), PORT);
Thread.Sleep(100); //需要等待一会才能获取连接状态 Thread.Sleep(100); //需要等待一会才能获取连接状态
IsConn = true; IsConn = true;
log.Info("Socket Connect"); log.Info(LogName+ "Socket Connect");
} }
catch (Exception ex) catch (Exception ex)
{ {
IsConn = false; IsConn = false;
log.Error("Open ", ex); log.Error(LogName+ "Open ", ex);
LogUtil.error(LogName + "Open ", ex); LogUtil.error(LogName + "Open ", ex);
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!