mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-26 21:27:10 +08:00
ModbusClient添加帧前时间
This commit is contained in:
@@ -58,6 +58,7 @@ public class ModbusRtu : CollectBase, IDisposable
|
||||
|
||||
public override async Task<OperResult> WriteValueAsync(CollectVariableRunTime deviceVariable, string value)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime);
|
||||
return await _plc.WriteAsync(deviceVariable.DataType, deviceVariable.VariableAddress, value);
|
||||
}
|
||||
|
||||
@@ -86,6 +87,7 @@ public class ModbusRtu : CollectBase, IDisposable
|
||||
}
|
||||
protected override async Task<OperResult<byte[]>> ReadAsync(string address, int length, CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime, cancellationToken);
|
||||
return await _plc.ReadAsync(address, length, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -104,6 +106,9 @@ public class ModbusRtuProperty : CollectDriverPropertyBase
|
||||
[DeviceProperty("默认解析顺序", "")]
|
||||
public DataFormat DataFormat { get; set; }
|
||||
|
||||
[DeviceProperty("帧前时间", "某些设备性能较弱,报文间需要间隔较长时间")]
|
||||
public int FrameTime { get; set; } = 0;
|
||||
|
||||
[DeviceProperty("共享链路", "")]
|
||||
public override bool IsShareChannel { get; set; } = false;
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ModbusRtuOverTcp : CollectBase, IDisposable
|
||||
|
||||
public override async Task<OperResult> WriteValueAsync(CollectVariableRunTime deviceVariable, string value)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime);
|
||||
return await _plc.WriteAsync(deviceVariable.DataType, deviceVariable.VariableAddress, value);
|
||||
}
|
||||
|
||||
@@ -73,9 +74,10 @@ public class ModbusRtuOverTcp : CollectBase, IDisposable
|
||||
_plc.Station = driverPropertys.Station;
|
||||
_plc.TimeOut = driverPropertys.TimeOut;
|
||||
}
|
||||
protected override Task<OperResult<byte[]>> ReadAsync(string address, int length, CancellationToken cancellationToken)
|
||||
protected override async Task<OperResult<byte[]>> ReadAsync(string address, int length, CancellationToken cancellationToken)
|
||||
{
|
||||
return _plc.ReadAsync(address, length, cancellationToken);
|
||||
await Task.Delay(driverPropertys.FrameTime, cancellationToken);
|
||||
return await _plc.ReadAsync(address, length, cancellationToken);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,6 +103,9 @@ public class ModbusRtuOverTcpProperty : CollectDriverPropertyBase
|
||||
[DeviceProperty("读写超时时间", "")]
|
||||
public ushort TimeOut { get; set; } = 3000;
|
||||
|
||||
[DeviceProperty("帧前时间", "某些设备性能较弱,报文间需要间隔较长时间")]
|
||||
public int FrameTime { get; set; } = 0;
|
||||
|
||||
[DeviceProperty("共享链路", "")]
|
||||
public override bool IsShareChannel { get; set; } = false;
|
||||
public override ShareChannelEnum ShareChannel => ShareChannelEnum.TcpClient;
|
||||
|
||||
@@ -54,6 +54,7 @@ public class ModbusRtuOverUdp : CollectBase
|
||||
|
||||
public override async Task<OperResult> WriteValueAsync(CollectVariableRunTime deviceVariable, string value)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime);
|
||||
return await _plc.WriteAsync(deviceVariable.DataType, deviceVariable.VariableAddress, value);
|
||||
}
|
||||
|
||||
@@ -75,6 +76,7 @@ public class ModbusRtuOverUdp : CollectBase
|
||||
}
|
||||
protected override async Task<OperResult<byte[]>> ReadAsync(string address, int length, CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime, cancellationToken);
|
||||
return await _plc.ReadAsync(address, length, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public class ModbusTcp : CollectBase
|
||||
|
||||
public override async Task<OperResult> WriteValueAsync(CollectVariableRunTime deviceVariable, string value)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime);
|
||||
return await _plc.WriteAsync(deviceVariable.DataType, deviceVariable.VariableAddress, value);
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ public class ModbusTcp : CollectBase
|
||||
}
|
||||
protected override async Task<OperResult<byte[]>> ReadAsync(string address, int length, CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime, cancellationToken);
|
||||
return await _plc.ReadAsync(address, length, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -94,6 +96,9 @@ public class ModbusTcpProperty : CollectDriverPropertyBase
|
||||
[DeviceProperty("连接超时时间", "")]
|
||||
public ushort ConnectTimeOut { get; set; } = 3000;
|
||||
|
||||
[DeviceProperty("帧前时间", "某些设备性能较弱,报文间需要间隔较长时间")]
|
||||
public int FrameTime { get; set; } = 0;
|
||||
|
||||
[DeviceProperty("默认解析顺序", "")]
|
||||
public DataFormat DataFormat { get; set; }
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ public class ModbusUdp : CollectBase
|
||||
|
||||
public override async Task<OperResult> WriteValueAsync(CollectVariableRunTime deviceVariable, string value)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime);
|
||||
return await _plc.WriteAsync(deviceVariable.DataType, deviceVariable.VariableAddress, value);
|
||||
}
|
||||
|
||||
@@ -76,6 +77,7 @@ public class ModbusUdp : CollectBase
|
||||
}
|
||||
protected override async Task<OperResult<byte[]>> ReadAsync(string address, int length, CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Delay(driverPropertys.FrameTime, cancellationToken);
|
||||
return await _plc.ReadAsync(address, length, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user