Class ModbusWriteCoilRequestBlueprint


  • @NonNullByDefault
    public class ModbusWriteCoilRequestBlueprint
    extends ModbusWriteRequestBlueprint
    Implementation for writing coils
    Author:
    Sami Salonen - Initial contribution
    • Constructor Detail

      • ModbusWriteCoilRequestBlueprint

        public ModbusWriteCoilRequestBlueprint​(int slaveId,
                                               int reference,
                                               boolean data,
                                               boolean writeMultiple,
                                               int maxTries)
        Construct coil write request with single bit of data
        Parameters:
        slaveId - slave id to write to
        reference - reference address
        data - bit to write
        writeMultiple - whether to use ModbusWriteFunctionCode.WRITE_MULTIPLE_COILS over ModbusWriteFunctionCode.WRITE_COIL
        maxTries - maximum number of tries in case of errors, should be at least 1
      • ModbusWriteCoilRequestBlueprint

        public ModbusWriteCoilRequestBlueprint​(int slaveId,
                                               int reference,
                                               BitArray data,
                                               boolean writeMultiple,
                                               int maxTries)
        Construct coil write request with many bits of data
        Parameters:
        slaveId - slave id to write to
        reference - reference address
        data - bit(s) to write
        writeMultiple - whether to use ModbusWriteFunctionCode.WRITE_MULTIPLE_COILS over ModbusWriteFunctionCode.WRITE_COIL. Useful with single bit of data.
        maxTries - maximum number of tries in case of errors, should be at least 1
        Throws:
        IllegalArgumentException - in case data is empty, writeMultiple is false but there are many bits to write.