Added VirtualModbusClient to Common

This commit is contained in:
2025-01-23 22:01:45 +01:00
parent ce3d873cd0
commit fb67e0b77e
14 changed files with 752 additions and 81 deletions

View File

@@ -17,15 +17,11 @@ namespace AMWD.Protocols.Modbus.Common
{
get
{
byte[] blob = [HighByte, LowByte];
blob.SwapBigEndian();
return BitConverter.ToUInt16(blob, 0);
return new[] { HighByte, LowByte }.GetBigEndianUInt16();
}
set
{
byte[] blob = BitConverter.GetBytes(value);
blob.SwapBigEndian();
var blob = value.ToBigEndianBytes();
HighByte = blob[0];
LowByte = blob[1];
}

View File

@@ -17,9 +17,7 @@ namespace AMWD.Protocols.Modbus.Common
{
get
{
byte[] blob = [HighByte, LowByte];
blob.SwapBigEndian();
return BitConverter.ToUInt16(blob, 0);
return new[] { HighByte, LowByte }.GetBigEndianUInt16();
}
}

View File

@@ -11,7 +11,7 @@ namespace AMWD.Protocols.Modbus.Common.Models
/// Initializes a new instance of the <see cref="ModbusDevice"/> class.
/// </remarks>
/// <param name="id">The <see cref="ModbusDevice"/> ID.</param>
public class ModbusDevice(byte id) : IDisposable
internal class ModbusDevice(byte id) : IDisposable
{
private readonly ReaderWriterLockSlim _rwLockCoils = new();
private readonly ReaderWriterLockSlim _rwLockDiscreteInputs = new();