public class ReadWriteMultipleRequest extends ModbusRequest
| Constructor and Description |
|---|
ReadWriteMultipleRequest()
Constructs a new Read/Write Multiple Registers Request instance.
|
ReadWriteMultipleRequest(int unit)
Constructs a new Read/Write Multiple Registers Request instance.
|
ReadWriteMultipleRequest(int unit,
int readRef,
int readCount,
int writeRef,
int writeCount)
Constructs a new Read/Write Multiple Registers Request instance.
|
| Modifier and Type | Method and Description |
|---|---|
ModbusResponse |
createResponse(AbstractModbusListener listener)
Returns the ModbusResponse that represents the answer to this
ModbusRequest.
|
int |
getByteCount()
getByteCount - Returns the number of bytes representing the values to be
written.
|
byte[] |
getMessage()
getMessage -- return a prepared message.
|
NonWordDataHandler |
getNonWordDataHandler()
getNonWordDataHandler - Returns the actual non word data handler.
|
int |
getReadReference()
getReadReference - Returns the reference of the register to start writing
to with this ReadWriteMultipleRequest.
|
int |
getReadRegisterValue(int index)
getReadRegisterValue - Returns the value of the specified register
interpreted as unsigned short.
|
int |
getReadWordCount()
getReadWordCount - Returns the number of words to be read.
|
Register |
getRegister(int index)
getRegister - Returns the specified Register.
|
Register[] |
getRegisters()
getRegisters - Returns the registers to be written with this
ReadWriteMultipleRequest.
|
ModbusResponse |
getResponse()
Returns the ModbusResponse that correlates with this
ModbusRequest.
|
int |
getWriteReference()
getWriteReference - Returns the reference of the register to start
writing to with this ReadWriteMultipleRequest.
|
int |
getWriteWordCount()
getWriteWordCount - Returns the number of words to be written.
|
void |
readData(DataInput input)
readData -- read the values of the registers to be written, along with
the reference and count for the registers to be read.
|
void |
setNonWordDataHandler(NonWordDataHandler dhandler)
setNonWordDataHandler - Sets a non word data handler.
|
void |
setReadReference(int ref)
setReadReference - Sets the reference of the register to writing to with
this ReadWriteMultipleRequest.
|
void |
setReadWordCount(int count)
setReadWordCount - Sets the number of words to be read.
|
void |
setRegisters(Register[] registers)
setRegisters - Sets the registers to be written with this
ReadWriteMultipleRequest.
|
void |
setWriteReference(int ref)
setWriteReference - Sets the reference of the register to write to with
this ReadWriteMultipleRequest.
|
void |
setWriteWordCount(int count)
setWriteWordCount - Sets the number of words to be written.
|
void |
writeData(DataOutput dout)
writeData -- output this Modbus message to dout.
|
createExceptionResponse, createModbusRequestgetDataLength, getFunctionCode, getHexMessage, getOutputLength, getProtocolID, getTransactionID, getUnitID, isHeadless, readFrom, setDataLength, setHeadless, setHeadless, setProtocolID, setTransactionID, setUnitID, writeTopublic ReadWriteMultipleRequest(int unit,
int readRef,
int readCount,
int writeRef,
int writeCount)
unit - Unit IDreadRef - Register to readwriteCount - Number of registers to writewriteRef - Starting register to writereadCount - Number of registers to readpublic ReadWriteMultipleRequest(int unit)
unit - Unit IDpublic ReadWriteMultipleRequest()
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)
ModbusRequestThe implementation should take care about assembling the reply to this ModbusRequest.
This method is used to create responses from the process image associated with the listener. It is commonly used to implement Modbus slave instances.
createResponse in class ModbusRequestlistener - Listener that received the requestpublic int getReadReference()
public void setReadReference(int ref)
ref - the reference of the register to start writing to as
int.public int getWriteReference()
public void setWriteReference(int ref)
ref - the reference of the register to start writing to as
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 index of the Register.IndexOutOfBoundsException - if the index is out of bounds.public int getReadRegisterValue(int index)
throws IndexOutOfBoundsException
index - the relative index of the register for which the value should
be retrieved.IndexOutOfBoundsException - if the index is out of bounds.public int getByteCount()
public int getWriteWordCount()
public void setWriteWordCount(int count)
count - the number of words to be written as int.public int getReadWordCount()
public void setReadWordCount(int count)
count - the number of words to be read as int.public NonWordDataHandler getNonWordDataHandler()
public void setNonWordDataHandler(NonWordDataHandler dhandler)
dhandler - a NonWordDataHandler instance.public void writeData(DataOutput dout) throws IOException
writeData in class ModbusMessageImpldout - the DataOutput to be written to.IOException - if an I/O related error occurs.public void readData(DataInput input) throws IOException
readData in class ModbusMessageImplinput - the DataInput to read from.IOException - if an I/O related error occurs.public byte[] getMessage()
Copyright © 2025. All Rights Reserved.