Class ModbusData.MutableModbusDataView

java.lang.Object
net.solarnetwork.node.io.modbus.ModbusData.MutableModbusDataView
All Implemented Interfaces:
ModbusData.MutableModbusData
Enclosing class:
ModbusData

public static class ModbusData.MutableModbusDataView extends Object implements ModbusData.MutableModbusData
Mutable view of Modbus data registers, meant to be used for thread-safe writes.

All methods are assumed to be synchronized on dataRegsiters.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MutableModbusDataView(net.solarnetwork.util.IntShortMap dataRegisters)
    Construct with data registers to mutate.
    MutableModbusDataView(net.solarnetwork.util.IntShortMap dataRegisters, ModbusWordOrder wordOrder)
    Construct with data registers to mutate.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    saveBytes(byte[] data, int addr)
    Store an array of bytes into 16-bit register data values, starting at a given address.
    final void
    saveDataArray(int[] data, int addr)
    Store an array of 16-bit integer register data values, starting at a given address.
    final void
    saveDataArray(short[] data, int addr)
    Store an array of 16-bit integer register data values, starting at a given address.
    final void
    saveDataArray(Integer[] data, int addr)
    Store an array of 16-bit integer register data values, starting at a given address.
    final void
    saveDataMap(Map<Integer,? extends Number> data)
    Store a mapping of addresses to associated 16-bit integer register data values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MutableModbusDataView

      public MutableModbusDataView(net.solarnetwork.util.IntShortMap dataRegisters)
      Construct with data registers to mutate.
      Parameters:
      dataRegisters - the registers to mutate; calling code should by synchronized on this instance
    • MutableModbusDataView

      public MutableModbusDataView(net.solarnetwork.util.IntShortMap dataRegisters, ModbusWordOrder wordOrder)
      Construct with data registers to mutate.
      Parameters:
      dataRegisters - the registers to mutate; calling code should by synchronized on this instance
      wordOrder - this parameter is not used, but maintained for backwards compatibility
  • Method Details

    • saveDataMap

      public final void saveDataMap(Map<Integer,? extends Number> data)
      Description copied from interface: ModbusData.MutableModbusData
      Store a mapping of addresses to associated 16-bit integer register data values.
      Specified by:
      saveDataMap in interface ModbusData.MutableModbusData
      Parameters:
      data - the data map to save; all values will be treated as 16-bit integer
    • saveDataArray

      public final void saveDataArray(short[] data, int addr)
      Description copied from interface: ModbusData.MutableModbusData
      Store an array of 16-bit integer register data values, starting at a given address.
      Specified by:
      saveDataArray in interface ModbusData.MutableModbusData
      Parameters:
      data - the data array to save, as shorts
      addr - the starting address of the data
    • saveDataArray

      public final void saveDataArray(int[] data, int addr)
      Description copied from interface: ModbusData.MutableModbusData
      Store an array of 16-bit integer register data values, starting at a given address.

      Note that the data values will be treated as 16-bit unsigned values.

      Specified by:
      saveDataArray in interface ModbusData.MutableModbusData
      Parameters:
      data - the data array to save, as ints
      addr - the starting address of the data
    • saveDataArray

      public final void saveDataArray(Integer[] data, int addr)
      Description copied from interface: ModbusData.MutableModbusData
      Store an array of 16-bit integer register data values, starting at a given address.

      Note that the data values will be treated as 16-bit unsigned values.

      Specified by:
      saveDataArray in interface ModbusData.MutableModbusData
      Parameters:
      data - the data array to save, as ints
      addr - the starting address of the data
    • saveBytes

      public void saveBytes(byte[] data, int addr)
      Description copied from interface: ModbusData.MutableModbusData
      Store an array of bytes into 16-bit register data values, starting at a given address.

      The bytes are packed into 16-bit values, so the number of register addresses written to will be half of the length of bytes (rounded up to nearest even even length).

      This method will assume ModbusWordOrder.MostToLeastSignificant word ordering.

      Specified by:
      saveBytes in interface ModbusData.MutableModbusData
      Parameters:
      data - the bytes to save
      addr - the starting address of the data