Class ModbusWriteRegisterRequestBlueprint
java.lang.Object
org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint
org.openhab.core.io.transport.modbus.ModbusWriteRegisterRequestBlueprint
@NonNullByDefault
public class ModbusWriteRegisterRequestBlueprint
extends ModbusWriteRequestBlueprint
Implementation for writing registers
- Author:
- Sami Salonen - Initial contribution
-
Constructor Summary
ConstructorDescriptionModbusWriteRegisterRequestBlueprint
(int slaveId, int reference, ModbusRegisterArray registers, boolean writeMultiple, int maxTries) Construct coil write request with many bits of data -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ModbusWriteRequestBlueprintVisitor visitor) Accept visitorReturns the function code of this ModbusMessage as int.
The function code is a 1-byte non negative integer value valid in the range of 0-127.
Function codes are ordered in conformance classes their values are specified in net.wimpi.modbus.Modbus.int
Get maximum number of tries, in case errors occur.int
Returns the reference of the register/coil/discrete input to to start writing with this requestint
Returns the unit identifier of this ModbusMessage as int.
The identifier is a 1-byte non negative integer value valid in the range of 0-255.toString()
Methods inherited from class org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint
getProtocolID
-
Constructor Details
-
ModbusWriteRegisterRequestBlueprint
public ModbusWriteRegisterRequestBlueprint(int slaveId, int reference, ModbusRegisterArray registers, boolean writeMultiple, int maxTries) throws IllegalArgumentException Construct coil write request with many bits of data- Parameters:
slaveId
- slave id to write toreference
- reference addressregisters
- register(s) to writewriteMultiple
- whether to useModbusWriteFunctionCode.WRITE_MULTIPLE_COILS
overModbusWriteFunctionCode.WRITE_COIL
. Useful with single register of data.maxTries
- maximum number of tries in case of errors, should be at least 1- Throws:
IllegalArgumentException
- in casedata
is empty,writeMultiple
isfalse
but there are many registers to write.
-
-
Method Details
-
getReference
public int getReference()Description copied from class:ModbusWriteRequestBlueprint
Returns the reference of the register/coil/discrete input to to start writing with this request- Specified by:
getReference
in classModbusWriteRequestBlueprint
- Returns:
- the reference of the register to start reading from as int.
-
getUnitID
public int getUnitID()Description copied from class:ModbusWriteRequestBlueprint
Returns the unit identifier of this ModbusMessage as int.
The identifier is a 1-byte non negative integer value valid in the range of 0-255.- Specified by:
getUnitID
in classModbusWriteRequestBlueprint
- Returns:
- the unit identifier as int.
-
getFunctionCode
Description copied from class:ModbusWriteRequestBlueprint
Returns the function code of this ModbusMessage as int.
The function code is a 1-byte non negative integer value valid in the range of 0-127.
Function codes are ordered in conformance classes their values are specified in net.wimpi.modbus.Modbus.- Specified by:
getFunctionCode
in classModbusWriteRequestBlueprint
- Returns:
- the function code as int.
- See Also:
-
Modbus
-
getRegisters
-
getMaxTries
public int getMaxTries()Description copied from class:ModbusWriteRequestBlueprint
Get maximum number of tries, in case errors occur. Should be at least 1.- Specified by:
getMaxTries
in classModbusWriteRequestBlueprint
-
toString
-
accept
Description copied from class:ModbusWriteRequestBlueprint
Accept visitor- Specified by:
accept
in classModbusWriteRequestBlueprint
-