public class WriteMultipleRegistersRequest extends ModbusRequest
| Constructor and Description |
|---|
WriteMultipleRegistersRequest()
Constructs a new WriteMultipleRegistersRequest instance.
|
WriteMultipleRegistersRequest(int first,
Register[] registers)
Constructs a new WriteMultipleRegistersRequest instance with a
given starting reference and values to be written.
|
| Modifier and Type | Method and Description |
|---|---|
ModbusResponse |
createResponse(AbstractModbusListener listener)
createResponse - Returns the WriteMultipleRegistersResponse that
represents the answer to this WriteMultipleRegistersRequest.
|
int |
getByteCount()
getByteCount - Returns the number of bytes representing the values to be
written.
|
byte[] |
getMessage()
Returns the raw message as an array of bytes.
|
NonWordDataHandler |
getNonWordDataHandler()
getNonWordDataHandler - Returns the actual non word data handler.
|
int |
getReference()
setReference - Returns the reference of the register to start writing to
with this WriteMultipleRegistersRequest.
|
Register |
getRegister(int index)
getRegister - Returns the Register at the given position.
|
Register[] |
getRegisters()
getRegisters - Returns the registers to be written with this
WriteMultipleRegistersRequest.
|
int |
getRegisterValue(int index)
getRegisterValue - Returns the value of the specified register.
|
ModbusResponse |
getResponse()
Returns the ModbusResponse that correlates with this
ModbusRequest.
|
int |
getWordCount()
getWordCount - Returns the number of words to be written.
|
void |
readData(DataInput input)
Reads the subclass specific data from the given DataInput instance.
|
void |
setNonWordDataHandler(NonWordDataHandler dhandler)
setNonWordHandler - Sets a non word data handler.
|
void |
setReference(int ref)
setReference - Sets the reference of the register to write to with this
WriteMultipleRegistersRequest.
|
void |
setRegisters(Register[] registers)
setRegisters - Sets the registers to be written with this
WriteMultipleRegistersRequest.
|
void |
writeData(DataOutput output)
Writes the subclass specific data to the given DataOutput.
|
createExceptionResponse, createModbusRequestgetDataLength, getFunctionCode, getHexMessage, getOutputLength, getProtocolID, getTransactionID, getUnitID, isHeadless, readFrom, setDataLength, setHeadless, setHeadless, setProtocolID, setTransactionID, setUnitID, writeTopublic WriteMultipleRegistersRequest(int first,
Register[] registers)
first - -- the address of the first register to write to.registers - -- the registers to be written.public WriteMultipleRegistersRequest()
public ModbusResponse getResponse()
ModbusRequestThe response must include the unit number, function code, as well as any transport-specific header information.
This method is used to create an empty response which must be populated by the caller. It is commonly used to un-marshal responses from Modbus slaves.
getResponse in class ModbusRequestpublic ModbusResponse createResponse(AbstractModbusListener listener)
createResponse in class ModbusRequestlistener - Listener that received the requestcreateResponse() must be able to handle the case where the word data that is in the response is actually non-word data. That is, where the slave device has data which are not actually short values in the range of registers being processed.
public int getReference()
public void setReference(int ref)
ref - the reference of the register to start writing to as an
int.public Register[] getRegisters()
public void setRegisters(Register[] registers)
registers - the registers to be written as Register[].public Register getRegister(int index) throws IndexOutOfBoundsException
index - the relative index of the Register.IndexOutOfBoundsException - if the index is out of bounds.public int getRegisterValue(int index)
throws IndexOutOfBoundsException
index - the index of the desired register.IndexOutOfBoundsException - if the index is out of bounds.public int getByteCount()
public int getWordCount()
public NonWordDataHandler getNonWordDataHandler()
public void setNonWordDataHandler(NonWordDataHandler dhandler)
dhandler - a NonWordDataHandler instance.public void writeData(DataOutput output) throws IOException
ModbusMessageImplwriteData in class ModbusMessageImploutput - the DataOutput to be written to.IOException - if an I/O related error occurs.public void readData(DataInput input) throws IOException
ModbusMessageImplreadData in class ModbusMessageImplinput - the DataInput to read from.IOException - if an I/O related error occurs.public byte[] getMessage()
ModbusMessageCopyright © 2025. All Rights Reserved.