net.wimpi.modbus.msg
Class ReadInputDiscretesRequest

java.lang.Object
  extended by net.wimpi.modbus.msg.ModbusMessageImpl
      extended by net.wimpi.modbus.msg.ModbusRequest
          extended by net.wimpi.modbus.msg.ReadInputDiscretesRequest
All Implemented Interfaces:
Transportable, ModbusMessage

public final class ReadInputDiscretesRequest
extends ModbusRequest

Class implementing a ReadInputDiscretesRequest. The implementation directly correlates with the class 1 function read input discretes (FC 2). It encapsulates the corresponding request message.

Input Discretes are understood as bits that cannot be manipulated (i.e. set or unset).

Version:
@version@ (@date@)
Author:
Dieter Wimberger

Constructor Summary
ReadInputDiscretesRequest()
          Constructs a new ReadInputDiscretesRequest instance.
ReadInputDiscretesRequest(int ref, int count)
          Constructs a new ReadInputDiscretesRequest instance with a given reference and count of input discretes (i.e.
 
Method Summary
 ModbusResponse createResponse()
          Returns the ModbusResponse that represents the answer to this ModbusRequest.
 int getBitCount()
          Returns the number of bits (i.e.
 int getReference()
          Returns the reference of the register to to start reading from with this ReadInputDiscretesRequest.
 void readData(DataInput din)
          Reads the subclass specific data from the given DataInput instance.
 void setBitCount(int count)
          Sets the number of bits (i.e.
 void setReference(int ref)
          Sets the reference of the register to start reading from with this ReadInputDiscretesRequest.
 void writeData(DataOutput dout)
          Writes the subclass specific data to the given DataOutput.
 
Methods inherited from class net.wimpi.modbus.msg.ModbusRequest
createExceptionResponse, createModbusRequest
 
Methods inherited from class net.wimpi.modbus.msg.ModbusMessageImpl
getDataLength, getFunctionCode, getHexMessage, getOutputLength, getProtocolID, getTransactionID, getUnitID, isHeadless, readFrom, setDataLength, setHeadless, setProtocolID, setTransactionID, setUnitID, writeTo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadInputDiscretesRequest

public ReadInputDiscretesRequest()
Constructs a new ReadInputDiscretesRequest instance.


ReadInputDiscretesRequest

public ReadInputDiscretesRequest(int ref,
                                 int count)
Constructs a new ReadInputDiscretesRequest instance with a given reference and count of input discretes (i.e. bits) to be read.

Parameters:
ref - the reference number of the register to read from.
count - the number of bits to be read.
Method Detail

createResponse

public ModbusResponse createResponse()
Description copied from class: ModbusRequest
Returns the ModbusResponse that represents the answer to this ModbusRequest.

The implementation should take care about assembling the reply to this ModbusRequest.

Specified by:
createResponse in class ModbusRequest
Returns:
the corresponding ModbusResponse.

setReference

public void setReference(int ref)
Sets the reference of the register to start reading from with this ReadInputDiscretesRequest.

Parameters:
ref - the reference of the register to start reading from.

getReference

public int getReference()
Returns the reference of the register to to start reading from with this ReadInputDiscretesRequest.

Returns:
the reference of the register to start reading from as int.

setBitCount

public void setBitCount(int count)
Sets the number of bits (i.e. input discretes) to be read with this ReadInputDiscretesRequest.

Parameters:
count - the number of bits to be read.

getBitCount

public int getBitCount()
Returns the number of bits (i.e. input discretes) to be read with this ReadInputDiscretesRequest.

Returns:
the number of bits to be read.

writeData

public void writeData(DataOutput dout)
               throws 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:
IOException - if an I/O related error occurs.

readData

public void readData(DataInput din)
              throws 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:
IOException - if an I/O related error occurs.


Copyright © 2010. All Rights Reserved.