Change ISpecialProtocalUnit to SpecialProtocalUnitAttribute
This commit is contained in:
@@ -65,7 +65,8 @@
|
||||
/// <summary>
|
||||
/// 读数据协议
|
||||
/// </summary>
|
||||
public class ReadRequestOpcProtocal : ProtocalUnit<OpcParamIn, OpcParamOut>, ISpecialProtocalUnit
|
||||
[SpecialProtocalUnit]
|
||||
public class ReadRequestOpcProtocal : ProtocalUnit<OpcParamIn, OpcParamOut>
|
||||
{
|
||||
/// <summary>
|
||||
/// 从对象的参数数组格式化
|
||||
@@ -156,7 +157,8 @@
|
||||
/// <summary>
|
||||
/// 写数据协议
|
||||
/// </summary>
|
||||
public class WriteRequestOpcProtocal : ProtocalUnit<OpcParamIn, OpcParamOut>, ISpecialProtocalUnit
|
||||
[SpecialProtocalUnit]
|
||||
public class WriteRequestOpcProtocal : ProtocalUnit<OpcParamIn, OpcParamOut>
|
||||
{
|
||||
/// <summary>
|
||||
/// 从对象的参数数组格式化
|
||||
|
||||
@@ -146,7 +146,8 @@ namespace Modbus.Net.Siemens
|
||||
public byte ConfirmMessage { get; set; }
|
||||
}
|
||||
|
||||
internal class ComCreateReferenceSiemensProtocal : ProtocalUnit, ISpecialProtocalUnit
|
||||
[SpecialProtocalUnit]
|
||||
internal class ComCreateReferenceSiemensProtocal : ProtocalUnit
|
||||
{
|
||||
public override byte[] Format(IInputStruct message)
|
||||
{
|
||||
@@ -200,7 +201,8 @@ namespace Modbus.Net.Siemens
|
||||
public ushort TsapDst { get; }
|
||||
}
|
||||
|
||||
internal class CreateReferenceSiemensProtocal : ProtocalUnit, ISpecialProtocalUnit
|
||||
[SpecialProtocalUnit]
|
||||
internal class CreateReferenceSiemensProtocal : ProtocalUnit
|
||||
{
|
||||
public override byte[] Format(IInputStruct message)
|
||||
{
|
||||
@@ -306,7 +308,8 @@ namespace Modbus.Net.Siemens
|
||||
/// <summary>
|
||||
/// 串口消息确认协议
|
||||
/// </summary>
|
||||
public class ComConfirmMessageSiemensProtocal : ProtocalUnit, ISpecialProtocalUnit
|
||||
[SpecialProtocalUnit]
|
||||
public class ComConfirmMessageSiemensProtocal : ProtocalUnit
|
||||
{
|
||||
/// <summary>
|
||||
/// 格式化
|
||||
|
||||
@@ -394,10 +394,11 @@ public class ReadDataModbusProtocal : ProtocalUnit
|
||||
}
|
||||
}
|
||||
```
|
||||
There is another interface called ISpecialProtocalUnit.
|
||||
If you add ISpecialProtocalUnit to ProtocalUnit, then the protocal will not run BytesExtend and BytesDecact.
|
||||
There is another attribute called SpecialProtocalUnitAttribute.
|
||||
If you add SpecialProtocalUnitAttribute to ProtocalUnit, then the protocal will not run BytesExtend and BytesDecact.
|
||||
```C#
|
||||
internal class CreateReferenceSiemensProtocal : ProtocalUnit, ISpecialProtocalUnit
|
||||
[SpecialProtocalUnit]
|
||||
internal class CreateReferenceSiemensProtocal : ProtocalUnit
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -185,7 +186,7 @@ namespace Modbus.Net
|
||||
{
|
||||
TParamOut receiveContent;
|
||||
//如果为特别处理协议的话,跳过协议扩展收缩
|
||||
if (unit is ISpecialProtocalUnit)
|
||||
if (unit.GetType().GetTypeInfo().GetCustomAttributes(typeof(SpecialProtocalUnitAttribute)).Any())
|
||||
receiveContent = await ProtocalLinker.SendReceiveWithoutExtAndDecAsync(formatContent);
|
||||
else
|
||||
receiveContent = await ProtocalLinker.SendReceiveAsync(formatContent);
|
||||
|
||||
@@ -71,7 +71,8 @@ namespace Modbus.Net
|
||||
/// <summary>
|
||||
/// 特殊协议单元,写入这个协议不会执行BytesExtend和BytesDecact
|
||||
/// </summary>
|
||||
public interface ISpecialProtocalUnit
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class SpecialProtocalUnitAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace AnyType.Controllers
|
||||
{
|
||||
Console.WriteLine($"ip {returnValues.MachineId} not return value");
|
||||
}
|
||||
}, 15000, 60000));
|
||||
}, MachineGetDataType.CommunicationTag, 15000, 60000));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace TaskManager.Controllers
|
||||
{
|
||||
Console.WriteLine($"ip {returnValues.MachineId} not return value");
|
||||
}
|
||||
}, 15000, 60000));
|
||||
}, MachineGetDataType.CommunicationTag, 15000, 60000));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
||||
Reference in New Issue
Block a user