2917-02-28 Update 1 Add Name Mode。
This commit is contained in:
@@ -18,7 +18,12 @@ namespace Modbus.Net
|
||||
/// <summary>
|
||||
/// 通讯标识
|
||||
/// </summary>
|
||||
CommunicationTag
|
||||
CommunicationTag,
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
Name
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -34,7 +39,12 @@ namespace Modbus.Net
|
||||
/// <summary>
|
||||
/// 通讯标识
|
||||
/// </summary>
|
||||
CommunicationTag
|
||||
CommunicationTag,
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
Name
|
||||
}
|
||||
|
||||
public abstract class BaseMachine : IMachineProperty
|
||||
@@ -233,6 +243,11 @@ namespace Modbus.Net
|
||||
key = AddressFormater.FormatAddress(address.Area, address.Address, address.SubAddress);
|
||||
break;
|
||||
}
|
||||
case MachineGetDataType.Name:
|
||||
{
|
||||
key = address.Name;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
key = address.CommunicationTag;
|
||||
@@ -340,6 +355,11 @@ namespace Modbus.Net
|
||||
GetAddresses.SingleOrDefault(p => p.CommunicationTag == value.Key);
|
||||
break;
|
||||
}
|
||||
case MachineSetDataType.Name:
|
||||
{
|
||||
address = GetAddresses.SingleOrDefault(p => p.Name == value.Key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//地址为空报错
|
||||
if (address == null)
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace Modbus.Net
|
||||
public enum MachineDataType
|
||||
{
|
||||
Address,
|
||||
CommunicationTag
|
||||
CommunicationTag,
|
||||
Name
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -348,6 +349,12 @@ namespace Modbus.Net
|
||||
SetDataType = MachineSetDataType.CommunicationTag;
|
||||
break;
|
||||
}
|
||||
case MachineDataType.Name:
|
||||
{
|
||||
GetDataType = MachineGetDataType.Name;
|
||||
SetDataType = MachineSetDataType.Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user