Class ModbusWriteCoilRequestBlueprint
java.lang.Object
org.openhab.core.io.transport.modbus.ModbusWriteRequestBlueprint
org.openhab.core.io.transport.modbus.ModbusWriteCoilRequestBlueprint
Implementation for writing coils
- Author:
- Sami Salonen - Initial contribution
-
Constructor Summary
ConstructorDescriptionModbusWriteCoilRequestBlueprint
(int slaveId, int reference, boolean data, boolean writeMultiple, int maxTries) Construct coil write request with single bit of dataModbusWriteCoilRequestBlueprint
(int slaveId, int reference, BitArray data, boolean writeMultiple, int maxTries) Construct coil write request with many bits of data -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ModbusWriteRequestBlueprintVisitor visitor) Accept visitorgetCoils()
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.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
-
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 toreference
- reference addressdata
- bit to writewriteMultiple
- whether to useModbusWriteFunctionCode.WRITE_MULTIPLE_COILS
overModbusWriteFunctionCode.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 toreference
- reference addressdata
- bit(s) to writewriteMultiple
- whether to useModbusWriteFunctionCode.WRITE_MULTIPLE_COILS
overModbusWriteFunctionCode.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 casedata
is empty,writeMultiple
isfalse
but there are many bits to write.
-
-
Method Details
-
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.
-
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.
-
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:
-
getCoils
-
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
- Parameters:
visitor
-
-