2014-08-27 update 1

This commit is contained in:
parallelbgls@outlook.com
2014-08-27 15:57:25 +08:00
parent aa1cbf85ba
commit ca030c8f59
24 changed files with 1159 additions and 2371 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
public enum ModbusProtocalReg
{
@@ -782,4 +783,35 @@ namespace ModBus.Net
}
}
public class ProtocalErrorException : Exception
{
public ProtocalErrorException(string message)
: base(message)
{
}
}
public class ModbusProtocalErrorException : ProtocalErrorException
{
public int ErrorMessageNumber { get; private set; }
private static readonly Dictionary<int, string> ProtocalErrorDictionary = new Dictionary<int, string>()
{
{1, "ILLEGAL_FUNCTION"},
{2, "ILLEGAL_DATA_ACCESS"},
{3, "ILLEGAL_DATA_VALUE"},
{4, "SLAVE_DEVICE_FAILURE"},
{5, "ACKNOWLWDGE"},
{6, "SLAVE_DEVICE_BUSY"},
{500, "TCP_ILLEGAL_LENGTH"},
{501, "RTU_ILLEGAL_CRC"},
};
public ModbusProtocalErrorException(int messageNumber)
: base(ProtocalErrorDictionary[messageNumber])
{
ErrorMessageNumber = messageNumber;
}
}
}