MbWords => MbRegisters
This commit is contained in:
parent
2fa1009bbd
commit
774e7d9110
|
@ -1,4 +1,5 @@
|
|||
using System.Collections;
|
||||
using InnovEnergy.Lib.Utils;
|
||||
|
||||
namespace InnovEnergy.Lib.Protocols.Modbus.Conversions;
|
||||
|
||||
|
@ -8,7 +9,7 @@ public partial class ModbusRegisters
|
|||
{
|
||||
var offset = index - StartRegister;
|
||||
|
||||
var byteArray = BitConverter.GetBytes(Registers[offset]).Reverse().ToArray();
|
||||
var byteArray = Registers[offset].Apply(BitConverter.GetBytes).Reverse().ToArray();
|
||||
var bitArray = new BitArray(byteArray);
|
||||
|
||||
return bitArray.Get(bitIndex);
|
||||
|
@ -18,7 +19,7 @@ public partial class ModbusRegisters
|
|||
{
|
||||
var offset = index - StartRegister;
|
||||
|
||||
var byteArray = BitConverter.GetBytes(Registers[offset]).Reverse().ToArray();
|
||||
var byteArray = Registers[offset].Apply(BitConverter.GetBytes).Reverse().ToArray();
|
||||
var bitArray = new BitArray(byteArray);
|
||||
|
||||
bitArray.Set(bitIndex, value);
|
||||
|
|
|
@ -9,7 +9,7 @@ public static class Accessors
|
|||
public static MbWord WordAt (this ArraySegment<Byte> data, Byte i) => new MbWord(data, i);
|
||||
public static MbAddress AddressAt(this ArraySegment<Byte> data, Byte i) => new MbAddress(data, i);
|
||||
|
||||
public static MbWords WordsAt(this ArraySegment<Byte> data, Byte i) => new MbWords(data, i);
|
||||
public static MbRegisters RegistersAt(this ArraySegment<Byte> data, Byte i) => new MbRegisters(data, i);
|
||||
public static MbBits BitsAt (this ArraySegment<Byte> data, Byte i) => new MbBits(data, i);
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ internal class ReadWriteRegistersCommandFrame : ModbusFrame
|
|||
public MbAddress WriteAddress => Data.AddressAt(6);
|
||||
public MbWord NbToWrite => Data.WordAt(8);
|
||||
public MbByte ByteCount => Data.ByteAt(10);
|
||||
public MbWords RegistersToWrite => Data.WordsAt(11);
|
||||
public MbRegisters RegistersToWrite => Data.RegistersAt(11);
|
||||
|
||||
public Int32 ExpectedResponseSize => ReadWriteRegistersResponseFrame.ExpectedSize(NbToRead);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ internal class WriteRegistersCommandFrame : ModbusFrame
|
|||
public MbAddress WriteAddress => Data.AddressAt(2);
|
||||
public MbWord NbOfRegisters => Data.WordAt(4);
|
||||
public MbByte ByteCount => Data.ByteAt(6);
|
||||
public MbWords RegistersToWrite => Data.WordsAt(7);
|
||||
public MbRegisters RegistersToWrite => Data.RegistersAt(7);
|
||||
|
||||
public Int32 ExpectedResponseSize => WriteRegistersResponseFrame.ExpectedSize();
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ internal class ReadHoldingRegistersResponseFrame : ModbusFrame
|
|||
internal new const Int32 MinSize = 3;
|
||||
|
||||
public MbByte ByteCount => Data.ByteAt(2);
|
||||
public MbWords RegistersRead => Data.WordsAt(3);
|
||||
public MbRegisters RegistersRead => Data.RegistersAt(3);
|
||||
|
||||
|
||||
public ReadHoldingRegistersResponseFrame(Byte slave, UInt16s registersRead) : base(ExpectedSize(registersRead.Count))
|
||||
|
|
|
@ -12,7 +12,7 @@ internal class ReadInputRegistersResponseFrame : ModbusFrame
|
|||
internal new const Int32 MinSize = 3;
|
||||
|
||||
public MbByte ByteCount => Data.ByteAt(2);
|
||||
public MbWords RegistersRead => Data.WordsAt(3);
|
||||
public MbRegisters RegistersRead => Data.RegistersAt(3);
|
||||
|
||||
public ReadInputRegistersResponseFrame(Byte slave, UInt16s registersRead) : base(ExpectedSize(registersRead.Count))
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ internal class ReadWriteRegistersResponseFrame : ModbusFrame
|
|||
internal new const Int32 MinSize = 3;
|
||||
|
||||
public MbByte ByteCount => Data.ByteAt(2);
|
||||
public MbWords RegistersRead => Data.WordsAt(3);
|
||||
public MbRegisters RegistersRead => Data.RegistersAt(3);
|
||||
|
||||
public ReadWriteRegistersResponseFrame(Byte slave, UInt16s registersRead) : base(ExpectedSize(registersRead.Count))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue