MbWords => MbRegisters
This commit is contained in:
parent
479cdd03ba
commit
2fa1009bbd
|
@ -3,30 +3,30 @@ using InnovEnergy.Lib.Utils;
|
|||
|
||||
namespace InnovEnergy.Lib.Protocols.Modbus.Protocol.Frames.Accessors;
|
||||
|
||||
public readonly struct MbWords : IReadOnlyList<UInt16>
|
||||
public readonly struct MbRegisters : IReadOnlyList<UInt16>
|
||||
{
|
||||
private readonly ArraySegment<Byte> _Data;
|
||||
|
||||
internal MbWords(ArraySegment<Byte> data, Byte startIndex) : this(data, startIndex, CountWords(data, startIndex))
|
||||
internal MbRegisters(ArraySegment<Byte> data, Byte startIndex) : this(data, startIndex, CountWords(data, startIndex))
|
||||
{ }
|
||||
|
||||
|
||||
|
||||
internal MbRegisters(ArraySegment<Byte> data, Byte startIndex, UInt16 wordCount) : this(data.Array!, startIndex, wordCount)
|
||||
{
|
||||
}
|
||||
|
||||
internal MbRegisters(Byte[] data, Byte startIndex, UInt16 wordCount)
|
||||
{
|
||||
_Data = new ArraySegment<Byte>(data, startIndex, wordCount * 2);
|
||||
}
|
||||
|
||||
private static UInt16 CountWords(ArraySegment<Byte> data, Byte startIndex)
|
||||
{
|
||||
var wordCount = (data.Count - startIndex) / 2;
|
||||
return wordCount.ConvertTo<UInt16>();
|
||||
}
|
||||
|
||||
internal MbWords(ArraySegment<Byte> data, Byte startIndex, UInt16 wordCount) : this(data.Array!, startIndex, wordCount)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal MbWords(Byte[] data, Byte startIndex, UInt16 wordCount)
|
||||
{
|
||||
_Data = new ArraySegment<Byte>(data, startIndex, wordCount * 2);
|
||||
}
|
||||
|
||||
internal IReadOnlyCollection<UInt16> Set(IReadOnlyCollection<UInt16> values)
|
||||
{
|
||||
if (values.Count != _Data.Count / 2)
|
Loading…
Reference in New Issue