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