diff --git a/csharp/Lib/Protocols/Modbus/Protocol/Frames/Accessors/MbWords.cs b/csharp/Lib/Protocols/Modbus/Protocol/Frames/Accessors/MbRegisters.cs similarity index 79% rename from csharp/Lib/Protocols/Modbus/Protocol/Frames/Accessors/MbWords.cs rename to csharp/Lib/Protocols/Modbus/Protocol/Frames/Accessors/MbRegisters.cs index 30876dceb..a2124a9fa 100644 --- a/csharp/Lib/Protocols/Modbus/Protocol/Frames/Accessors/MbWords.cs +++ b/csharp/Lib/Protocols/Modbus/Protocol/Frames/Accessors/MbRegisters.cs @@ -3,30 +3,30 @@ using InnovEnergy.Lib.Utils; namespace InnovEnergy.Lib.Protocols.Modbus.Protocol.Frames.Accessors; -public readonly struct MbWords : IReadOnlyList +public readonly struct MbRegisters : IReadOnlyList { private readonly ArraySegment _Data; - internal MbWords(ArraySegment data, Byte startIndex) : this(data, startIndex, CountWords(data, startIndex)) + internal MbRegisters(ArraySegment data, Byte startIndex) : this(data, startIndex, CountWords(data, startIndex)) { } + + + internal MbRegisters(ArraySegment data, Byte startIndex, UInt16 wordCount) : this(data.Array!, startIndex, wordCount) + { + } + + internal MbRegisters(Byte[] data, Byte startIndex, UInt16 wordCount) + { + _Data = new ArraySegment(data, startIndex, wordCount * 2); + } + private static UInt16 CountWords(ArraySegment data, Byte startIndex) { var wordCount = (data.Count - startIndex) / 2; return wordCount.ConvertTo(); } - internal MbWords(ArraySegment data, Byte startIndex, UInt16 wordCount) : this(data.Array!, startIndex, wordCount) - { - - } - - - internal MbWords(Byte[] data, Byte startIndex, UInt16 wordCount) - { - _Data = new ArraySegment(data, startIndex, wordCount * 2); - } - internal IReadOnlyCollection Set(IReadOnlyCollection values) { if (values.Count != _Data.Count / 2)