Commit 2b471f9a authored by 95Jack's avatar 95Jack

Modifying Log Errors

parent c089422c
......@@ -36,17 +36,6 @@ namespace ModbusDemo.windows
}
writer.WriteLine(DateTime.Now + ": " + info);
}
catch (Exception e)
{
if (writer != null)
{
writer.Close();
writer.Dispose();
fileStream.Close();
fileStream.Dispose();
}
throw;
}
finally
{
if (writer != null)
......
......@@ -46,7 +46,7 @@ namespace ModbusDemo.MessageFormat
if (exception.Source.Equals("System"))
{
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message+ "Modbus_ReadHoldingRegistersTask");
OutputValue = new ushort[numberOfPoints];
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++;
......@@ -127,7 +127,7 @@ namespace ModbusDemo.MessageFormat
if (exception.Source.Equals("System"))
{
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message+ "Modbus_ReadCoilsTask");
OutputValue = new bool[numberOfPoints];
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++;
......@@ -208,7 +208,7 @@ namespace ModbusDemo.MessageFormat
if (exception.Source.Equals("System"))
{
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message+ "Modbus_WriteSingleCoil");
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
}
//The server return error code.
......@@ -286,7 +286,7 @@ namespace ModbusDemo.MessageFormat
if (exception.Source.Equals("System"))
{
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message+ "Modbus_WriteMultipleCoils");
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
}
//The server return error code.
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment