diff --git a/Modbus.Net/Modbus.Net.Modbus/AddressFormaterModbus.cs b/Modbus.Net/Modbus.Net.Modbus/AddressFormaterModbus.cs
index 06a832e..ffe8813 100644
--- a/Modbus.Net/Modbus.Net.Modbus/AddressFormaterModbus.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/AddressFormaterModbus.cs
@@ -1,5 +1,8 @@
namespace Modbus.Net.Modbus
{
+ ///
+ /// 南大奥拓NA200H专用AddressFormater
+ ///
public class AddressFormaterNA200H : AddressFormater
{
public override string FormatAddress(string area, int address)
@@ -13,6 +16,9 @@
}
}
+ ///
+ /// Modbus标准AddressFormater
+ ///
public class AddressFormaterModbus : AddressFormater
{
public override string FormatAddress(string area, int address)
diff --git a/Modbus.Net/Modbus.Net.Modbus/AddressTranslatorModbus.cs b/Modbus.Net/Modbus.Net.Modbus/AddressTranslatorModbus.cs
index 29a8b00..7822cf6 100644
--- a/Modbus.Net/Modbus.Net.Modbus/AddressTranslatorModbus.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/AddressTranslatorModbus.cs
@@ -4,12 +4,21 @@ using System.Linq;
namespace Modbus.Net.Modbus
{
///
- /// NA200H数据单元翻译器
+ /// 南大奥拓NA200H数据单元翻译器
///
public class AddressTranslatorNA200H : AddressTranslator
{
+ ///
+ /// 读功能码
+ ///
protected Dictionary ReadFunctionCodeDictionary;
+ ///
+ /// 功能码翻译至标准Modbus地址位置
+ ///
protected Dictionary TransDictionary;
+ ///
+ /// 写功能码
+ ///
protected Dictionary WriteFunctionCodeDictionary;
public AddressTranslatorNA200H()
@@ -188,7 +197,13 @@ namespace Modbus.Net.Modbus
///
public class AddressTranslatorModbus : AddressTranslator
{
+ ///
+ /// 读功能码
+ ///
protected Dictionary ReadFunctionCodeDictionary;
+ ///
+ /// 写功能码
+ ///
protected Dictionary WriteFunctionCodeDictionary;
public AddressTranslatorModbus()
diff --git a/Modbus.Net/Modbus.Net.Modbus/Modbus.Net.Modbus.nuspec b/Modbus.Net/Modbus.Net.Modbus/Modbus.Net.Modbus.nuspec
index 1a9e95c..e15ee3a 100644
--- a/Modbus.Net/Modbus.Net.Modbus/Modbus.Net.Modbus.nuspec
+++ b/Modbus.Net/Modbus.Net.Modbus/Modbus.Net.Modbus.nuspec
@@ -2,18 +2,18 @@
Modbus.Net.Modbus
- 1.2.1
+ 1.2.2
Modbus.Net.Modbus
Chris L.(Luo Sheng)
- Hangzhou Delian Information and Science Technology Co.,Ltd.
+ Hangzhou Delian IoT Science Technology Co.,Ltd.
https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md
https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.Modbus
false
Modbus.Net Modbus Implementation
- Copyright 2015 Hangzhou Delian Science and Technology Co.,Ltd.
+ Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.
hardware communicate protocal modbus Delian
-
+
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocal.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocal.cs
index 43f93fd..feeff00 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocal.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocal.cs
@@ -1,7 +1,7 @@
namespace Modbus.Net.Modbus
{
///
- /// Modbus/Rtu协议
+ /// Modbus/Ascii码协议
///
public class ModbusAsciiProtocal : ModbusProtocal
{
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocalLinker.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocalLinker.cs
index 5609f8f..8952917 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocalLinker.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusAsciiProtocalLinker.cs
@@ -3,6 +3,9 @@ using System.Text;
namespace Modbus.Net.Modbus
{
+ ///
+ /// Modbus/Ascii码协议连接器
+ ///
public class ModbusAsciiProtocalLinker : ComProtocalLinker
{
public ModbusAsciiProtocalLinker(string com) : base(com, 9600, Parity.None, StopBits.One, 8)
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusMachine.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusMachine.cs
index 9b41863..8fc918c 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusMachine.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusMachine.cs
@@ -2,6 +2,9 @@
namespace Modbus.Net.Modbus
{
+ ///
+ /// Modbus设备
+ ///
public class ModbusMachine : BaseMachine
{
public ModbusMachine(ModbusType connectionType, string connectionString,
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusProtocal.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusProtocal.cs
index 3494554..faf6bee 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusProtocal.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusProtocal.cs
@@ -4,6 +4,9 @@ using System.Threading.Tasks;
namespace Modbus.Net.Modbus
{
+ ///
+ /// 变量功能码
+ ///
internal enum ModbusProtocalVariableFunctionCode : byte
{
ReadVariable = 20,
@@ -39,6 +42,9 @@ namespace Modbus.Net.Modbus
WriteMultiRegister = 16
}
+ ///
+ /// Modbus协议
+ ///
public abstract class ModbusProtocal : BaseProtocal
{
protected ModbusProtocal(byte slaveAddress, byte masterAddress) : base(slaveAddress, masterAddress)
@@ -58,7 +64,7 @@ namespace Modbus.Net.Modbus
#region 读PLC数据
- public class ReadDataModbusInputStruct : InputStruct
+ public class ReadDataModbusInputStruct : IInputStruct
{
public ReadDataModbusInputStruct(byte slaveAddress, string startAddress, ushort getCount,
AddressTranslator addressTranslator)
@@ -79,7 +85,7 @@ namespace Modbus.Net.Modbus
public ushort GetCount { get; }
}
- public class ReadDataModbusOutputStruct : OutputStruct
+ public class ReadDataModbusOutputStruct : IOutputStruct
{
public ReadDataModbusOutputStruct(byte slaveAddress, byte functionCode,
int dataCount, byte[] dataValue)
@@ -101,14 +107,14 @@ namespace Modbus.Net.Modbus
public class ReadDataModbusProtocal : ProtocalUnit
{
- public override byte[] Format(InputStruct message)
+ public override byte[] Format(IInputStruct message)
{
var r_message = (ReadDataModbusInputStruct) message;
return Format(r_message.SlaveAddress, r_message.FunctionCode,
r_message.StartAddress, r_message.GetCount);
}
- public override OutputStruct Unformat(byte[] messageBytes, ref int pos)
+ public override IOutputStruct Unformat(byte[] messageBytes, ref int pos)
{
var slaveAddress = BigEndianValueHelper.Instance.GetByte(messageBytes, ref pos);
var functionCode = BigEndianValueHelper.Instance.GetByte(messageBytes, ref pos);
@@ -130,7 +136,7 @@ namespace Modbus.Net.Modbus
#region 写PLC数据
- public class WriteDataModbusInputStruct : InputStruct
+ public class WriteDataModbusInputStruct : IInputStruct
{
public WriteDataModbusInputStruct(byte slaveAddress, string startAddress, object[] writeValue,
AddressTranslator addressTranslator)
@@ -159,7 +165,7 @@ namespace Modbus.Net.Modbus
public byte[] WriteValue { get; }
}
- public class WriteDataModbusOutputStruct : OutputStruct
+ public class WriteDataModbusOutputStruct : IOutputStruct
{
public WriteDataModbusOutputStruct(byte slaveAddress, byte functionCode,
ushort startAddress, ushort writeCount)
@@ -184,7 +190,7 @@ namespace Modbus.Net.Modbus
///
public class WriteDataModbusProtocal : ProtocalUnit
{
- public override byte[] Format(InputStruct message)
+ public override byte[] Format(IInputStruct message)
{
var r_message = (WriteDataModbusInputStruct) message;
var functionCode = r_message.FunctionCode;
@@ -201,7 +207,7 @@ namespace Modbus.Net.Modbus
return formattingBytes;
}
- public override OutputStruct Unformat(byte[] messageBytes, ref int flag)
+ public override IOutputStruct Unformat(byte[] messageBytes, ref int flag)
{
var slaveAddress = BigEndianValueHelper.Instance.GetByte(messageBytes, ref flag);
var functionCode = BigEndianValueHelper.Instance.GetByte(messageBytes, ref flag);
@@ -216,7 +222,7 @@ namespace Modbus.Net.Modbus
#region 读PLC时间
- public class GetSystemTimeModbusInputStruct : InputStruct
+ public class GetSystemTimeModbusInputStruct : IInputStruct
{
public GetSystemTimeModbusInputStruct(byte slaveAddress)
{
@@ -235,7 +241,7 @@ namespace Modbus.Net.Modbus
public ushort GetCount { get; }
}
- public class GetSystemTimeModbusOutputStruct : OutputStruct
+ public class GetSystemTimeModbusOutputStruct : IOutputStruct
{
public GetSystemTimeModbusOutputStruct(byte slaveAddress, byte functionCode,
byte writeByteCount, ushort year, byte day, byte month, ushort hour, byte second, byte minute,
@@ -261,14 +267,14 @@ namespace Modbus.Net.Modbus
///
public class GetSystemTimeModbusProtocal : ProtocalUnit
{
- public override byte[] Format(InputStruct message)
+ public override byte[] Format(IInputStruct message)
{
var r_message = (GetSystemTimeModbusInputStruct) message;
return Format(r_message.SlaveAddress, r_message.FunctionCode,
r_message.StartAddress, r_message.GetCount);
}
- public override OutputStruct Unformat(byte[] messageBytes, ref int flag)
+ public override IOutputStruct Unformat(byte[] messageBytes, ref int flag)
{
var slaveAddress = BigEndianValueHelper.Instance.GetByte(messageBytes, ref flag);
var functionCode = BigEndianValueHelper.Instance.GetByte(messageBytes, ref flag);
@@ -289,7 +295,7 @@ namespace Modbus.Net.Modbus
#region 写PLC时间
- public class SetSystemTimeModbusInputStruct : InputStruct
+ public class SetSystemTimeModbusInputStruct : IInputStruct
{
public SetSystemTimeModbusInputStruct(byte slaveAddress, DateTime time)
{
@@ -332,7 +338,7 @@ namespace Modbus.Net.Modbus
public ushort Millisecond { get; }
}
- public class SetSystemTimeModbusOutputStruct : OutputStruct
+ public class SetSystemTimeModbusOutputStruct : IOutputStruct
{
public SetSystemTimeModbusOutputStruct(byte slaveAddress, byte functionCode,
ushort startAddress, ushort writeCount)
@@ -357,7 +363,7 @@ namespace Modbus.Net.Modbus
///
public class SetSystemTimeModbusProtocal : ProtocalUnit
{
- public override byte[] Format(InputStruct message)
+ public override byte[] Format(IInputStruct message)
{
var r_message = (SetSystemTimeModbusInputStruct) message;
return Format(r_message.SlaveAddress, r_message.FunctionCode,
@@ -366,7 +372,7 @@ namespace Modbus.Net.Modbus
r_message.Month, r_message.Hour, r_message.Second, r_message.Minute, r_message.Millisecond);
}
- public override OutputStruct Unformat(byte[] messageBytes, ref int flag)
+ public override IOutputStruct Unformat(byte[] messageBytes, ref int flag)
{
var slaveAddress = BigEndianValueHelper.Instance.GetByte(messageBytes, ref flag);
var functionCode = BigEndianValueHelper.Instance.GetByte(messageBytes, ref flag);
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusProtocalLinkerBytesExtend.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusProtocalLinkerBytesExtend.cs
index b3c375d..b079c45 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusProtocalLinkerBytesExtend.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusProtocalLinkerBytesExtend.cs
@@ -8,9 +8,9 @@ namespace Modbus.Net.Modbus
///
/// Tcp协议字节伸缩
///
- public class ModbusTcpProtocalLinkerBytesExtend : ProtocalLinkerBytesExtend
+ public class ModbusTcpProtocalLinkerBytesExtend : IProtocalLinkerBytesExtend
{
- public override byte[] BytesExtend(byte[] content)
+ public byte[] BytesExtend(byte[] content)
{
//Modbus/Tcp协议扩张,前面加6个字节,前面4个为0,后面两个为协议整体内容的长度
var newFormat = new byte[6 + content.Length];
@@ -22,7 +22,7 @@ namespace Modbus.Net.Modbus
return newFormat;
}
- public override byte[] BytesDecact(byte[] content)
+ public byte[] BytesDecact(byte[] content)
{
//Modbus/Tcp协议收缩,抛弃前面6个字节的内容
var newContent = new byte[content.Length - 6];
@@ -31,9 +31,9 @@ namespace Modbus.Net.Modbus
}
}
- public class ModbusRtuProtocalLinkerBytesExtend : ProtocalLinkerBytesExtend
+ public class ModbusRtuProtocalLinkerBytesExtend : IProtocalLinkerBytesExtend
{
- public override byte[] BytesExtend(byte[] content)
+ public byte[] BytesExtend(byte[] content)
{
var crc = new byte[2];
//Modbus/Rtu协议扩张,增加CRC校验
@@ -44,7 +44,7 @@ namespace Modbus.Net.Modbus
return newFormat;
}
- public override byte[] BytesDecact(byte[] content)
+ public byte[] BytesDecact(byte[] content)
{
//Modbus/Rtu协议收缩,抛弃后面2个字节的内容
var newContent = new byte[content.Length - 2];
@@ -53,10 +53,11 @@ namespace Modbus.Net.Modbus
}
}
- public class ModbusAsciiProtocalLinkerBytesExtend : ProtocalLinkerBytesExtend
+ public class ModbusAsciiProtocalLinkerBytesExtend : IProtocalLinkerBytesExtend
{
- public override byte[] BytesExtend(byte[] content)
+ public byte[] BytesExtend(byte[] content)
{
+ //Modbus/Ascii协议扩张,前面增加:,后面增加LRC校验和尾字符
var newContent = new List();
newContent.AddRange(Encoding.ASCII.GetBytes(":"));
foreach (var number in content)
@@ -69,8 +70,9 @@ namespace Modbus.Net.Modbus
return newContent.ToArray();
}
- public override byte[] BytesDecact(byte[] content)
+ public byte[] BytesDecact(byte[] content)
{
+ //Modbus/Ascii协议收缩,抛弃头尾。
var newContent = new List();
var ans = Encoding.ASCII.GetString(content);
var index = ans.IndexOf(Environment.NewLine);
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusRtuProtocalLinker.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusRtuProtocalLinker.cs
index 3fcbdfb..a5a089d 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusRtuProtocalLinker.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusRtuProtocalLinker.cs
@@ -2,6 +2,9 @@
namespace Modbus.Net.Modbus
{
+ ///
+ /// Modbus/Rtu协议连接器
+ ///
public class ModbusRtuProtocalLinker : ComProtocalLinker
{
public ModbusRtuProtocalLinker(string com) : base(com, 9600, Parity.None, StopBits.One, 8)
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocalLinker.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocalLinker.cs
index 9e1154d..830e564 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocalLinker.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocalLinker.cs
@@ -1,5 +1,8 @@
namespace Modbus.Net.Modbus
{
+ ///
+ /// Modbus/Tcp协议连接器
+ ///
public class ModbusTcpProtocalLinker : TcpProtocalLinker
{
public ModbusTcpProtocalLinker(string ip) : base(ip, int.Parse(ConfigurationManager.ModbusPort))
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusUtility.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusUtility.cs
index 65580f4..53c4775 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusUtility.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusUtility.cs
@@ -23,8 +23,14 @@ namespace Modbus.Net.Modbus
Ascii = 2
}
+ ///
+ /// Modbus基础Api入口
+ ///
public class ModbusUtility : BaseUtility
{
+ ///
+ /// Modbus协议类型
+ ///
private ModbusType _modbusType;
public ModbusUtility(int connectionType, byte slaveAddress, byte masterAddress)
@@ -81,6 +87,7 @@ namespace Modbus.Net.Modbus
_modbusType = value;
switch (_modbusType)
{
+ //Rtu协议
case ModbusType.Rtu:
{
Wrapper = ConnectionString == null
@@ -88,6 +95,7 @@ namespace Modbus.Net.Modbus
: new ModbusRtuProtocal(ConnectionString, SlaveAddress, MasterAddress);
break;
}
+ //Tcp协议
case ModbusType.Tcp:
{
Wrapper = ConnectionString == null
@@ -98,6 +106,7 @@ namespace Modbus.Net.Modbus
MasterAddress));
break;
}
+ //Ascii协议
case ModbusType.Ascii:
{
Wrapper = ConnectionString == null
@@ -114,6 +123,12 @@ namespace Modbus.Net.Modbus
ModbusType = (ModbusType) connectionType;
}
+ ///
+ /// 读数据
+ ///
+ /// 起始地址
+ /// 获取字节个数
+ /// 获取的结果
public override async Task GetDatasAsync(string startAddress, int getByteCount)
{
try
@@ -131,6 +146,12 @@ namespace Modbus.Net.Modbus
}
}
+ ///
+ /// 写数据
+ ///
+ /// 起始地址
+ /// 需要设置的数据
+ /// 设置是否成功
public override async Task SetDatasAsync(string startAddress, object[] setContents)
{
try
@@ -149,6 +170,10 @@ namespace Modbus.Net.Modbus
}
/*
+ ///
+ /// 读时间
+ ///
+ /// 设备的时间
public override DateTime GetTime()
{
try
@@ -165,6 +190,11 @@ namespace Modbus.Net.Modbus
}
}
+ ///
+ /// 写时间
+ ///
+ /// 需要写入的时间
+ /// 写入是否成功
public override bool SetTime(DateTime setTime)
{
try
diff --git a/Modbus.Net/Modbus.Net.Modbus/Properties/AssemblyInfo.cs b/Modbus.Net/Modbus.Net.Modbus/Properties/AssemblyInfo.cs
index 1505b06..8f85574 100644
--- a/Modbus.Net/Modbus.Net.Modbus/Properties/AssemblyInfo.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/Properties/AssemblyInfo.cs
@@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Modbus.Net.Modbus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
+[assembly: AssemblyCompany("杭州德联物联网科技有限公司")]
[assembly: AssemblyProduct("Modbus.Net.Modbus")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyCopyright("Copyright © Chris L. 2017 HangZhou Delian IoT Science Technology Co.,Ltd.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.0")]
-[assembly: AssemblyFileVersion("1.2.0")]
+[assembly: AssemblyVersion("1.2.2")]
+[assembly: AssemblyFileVersion("1.2.2")]
diff --git a/Modbus.Net/Modbus.Net.Modbus/README.md b/Modbus.Net/Modbus.Net.Modbus/README.md
index 22a75ae..921de72 100644
--- a/Modbus.Net/Modbus.Net.Modbus/README.md
+++ b/Modbus.Net/Modbus.Net.Modbus/README.md
@@ -1,4 +1,4 @@
-Modbus.Net
+Modbus.Net.Modbus
===================
[](https://www.nuget.org/packages/Modbus.Net.Modbus/)
diff --git a/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs b/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs
index 9bc6d1d..ea16eb8 100644
--- a/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs
+++ b/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs
@@ -3,8 +3,17 @@ using System.Linq;
namespace Modbus.Net.OPC
{
+ ///
+ /// Opc地址编码器
+ ///
public class AddressFormaterOpc : AddressFormater
{
+ ///
+ /// 协议构造器
+ ///
+ /// 如何通过BaseMachine和AddressUnit构造Opc的标签
+ /// 调用这个编码器的设备
+ /// 每两个标签之间用什么符号隔开,默认为/
public AddressFormaterOpc(Func tagGeter, BaseMachine machine,
char seperator = '/')
{
diff --git a/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs b/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs
index 31d8f37..71f0d20 100644
--- a/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs
+++ b/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs
@@ -2,6 +2,9 @@
namespace Modbus.Net.OPC
{
+ ///
+ /// Opc地址解析器
+ ///
public class AddressTranslatorOpc : AddressTranslator
{
public override AddressDef AddressTranslate(string address, bool isRead)
diff --git a/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj b/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj
index 2accc6f..71afb08 100644
--- a/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj
+++ b/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj
@@ -90,6 +90,7 @@
+