jamod at SF

net.wimpi.modbus.msg
Class ReadInputRegistersResponse

java.lang.Object
  extended bynet.wimpi.modbus.msg.ModbusMessageImpl
      extended bynet.wimpi.modbus.msg.ModbusResponse
          extended bynet.wimpi.modbus.msg.ReadInputRegistersResponse
All Implemented Interfaces:
ModbusMessage, Transportable

public final class ReadInputRegistersResponse
extends ModbusResponse

Class implementing a ReadInputRegistersRequest. The implementation directly correlates with the class 0 function read multiple registers (FC 4). It encapsulates the corresponding response message.

Version:
1.2rc1 (09/11/2004)
Author:
Dieter Wimberger

Constructor Summary
ReadInputRegistersResponse()
          Constructs a new ReadInputRegistersResponse instance.
ReadInputRegistersResponse(InputRegister[] registers)
          Constructs a new ReadInputRegistersResponse instance.
 
Method Summary
 int getByteCount()
          Returns the number of bytes that have been read.
 InputRegister getRegister(int index)
          Returns the InputRegister at the given position (relative to the reference used in the request).
 InputRegister[] getRegisters()
          Returns a reference to the array of input registers read.
 int getRegisterValue(int index)
          Returns the value of the register at the given position (relative to the reference used in the request) interpreted as usigned short.
 int getWordCount()
          Returns the number of words that have been read.
 void readData(java.io.DataInput din)
          Reads the subclass specific data from the given DataInput instance.
 void writeData(java.io.DataOutput dout)
          Writes the subclass specific data to the given DataOutput.
 
Methods inherited from class net.wimpi.modbus.msg.ModbusResponse
createModbusResponse, setMessage
 
Methods inherited from class net.wimpi.modbus.msg.ModbusMessageImpl
getDataLength, getFunctionCode, getHexMessage, getOutputLength, getProtocolID, getTransactionID, getUnitID, isHeadless, readFrom, setDataLength, setFunctionCode, setHeadless, setHeadless, setProtocolID, setTransactionID, setUnitID, writeTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadInputRegistersResponse

public ReadInputRegistersResponse()
Constructs a new ReadInputRegistersResponse instance.


ReadInputRegistersResponse

public ReadInputRegistersResponse(InputRegister[] registers)
Constructs a new ReadInputRegistersResponse instance.

Parameters:
registers - the InputRegister[] holding response input registers.
Method Detail

getByteCount

public int getByteCount()
Returns the number of bytes that have been read.

Returns:
the number of bytes that have been read as int.

getWordCount

public int getWordCount()
Returns the number of words that have been read. The returned value should be twice as much as the byte count of the response.

Returns:
the number of words that have been read as int.

getRegister

public InputRegister getRegister(int index)
                          throws java.lang.IndexOutOfBoundsException
Returns the InputRegister at the given position (relative to the reference used in the request).

Parameters:
index - the relative index of the InputRegister.
Returns:
the register as InputRegister.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of bounds.

getRegisterValue

public int getRegisterValue(int index)
                     throws java.lang.IndexOutOfBoundsException
Returns the value of the register at the given position (relative to the reference used in the request) interpreted as usigned short.

Parameters:
index - the relative index of the register for which the value should be retrieved.
Returns:
the value as int.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of bounds.

getRegisters

public InputRegister[] getRegisters()
Returns a reference to the array of input registers read.

Returns:
a InputRegister[] instance.

writeData

public void writeData(java.io.DataOutput dout)
               throws java.io.IOException
Description copied from class: ModbusMessageImpl
Writes the subclass specific data to the given DataOutput.

Specified by:
writeData in class ModbusMessageImpl
Parameters:
dout - the DataOutput to be written to.
Throws:
java.io.IOException - if an I/O related error occurs.

readData

public void readData(java.io.DataInput din)
              throws java.io.IOException
Description copied from class: ModbusMessageImpl
Reads the subclass specific data from the given DataInput instance.

Specified by:
readData in class ModbusMessageImpl
Parameters:
din - the DataInput to read from.
Throws:
java.io.IOException - if an I/O related error occurs.

jamod at SF

Copyright © 2002-2004 jamod development team.