jamod at SF

net.wimpi.modbus.msg
Class ReadInputDiscretesResponse

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

public final class ReadInputDiscretesResponse
extends ModbusResponse

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

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

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

Constructor Summary
ReadInputDiscretesResponse()
          Constructs a new ReadInputDiscretesResponse instance.
ReadInputDiscretesResponse(int count)
          Constructs a new ReadInputDiscretesResponse instance with a given count of input discretes (i.e. bits).
 
Method Summary
 int getBitCount()
          Returns the number of bits (i.e. input discretes) read with the request.
 BitVector getDiscretes()
          Returns the BitVector that stores the collection of bits that have been read.
 boolean getDiscreteStatus(int index)
          Convenience method that returns the state of the bit at the given index.
 void readData(java.io.DataInput din)
          Reads the subclass specific data from the given DataInput instance.
 void setBitCount(int count)
          Sets the number of bits in this response.
 void setDiscreteStatus(int index, boolean b)
          Sets the status of the given input discrete.
 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

ReadInputDiscretesResponse

public ReadInputDiscretesResponse()
Constructs a new ReadInputDiscretesResponse instance.


ReadInputDiscretesResponse

public ReadInputDiscretesResponse(int count)
Constructs a new ReadInputDiscretesResponse instance with a given count of input discretes (i.e. bits).

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

getBitCount

public int getBitCount()
Returns the number of bits (i.e. input discretes) read with the request.

Returns:
the number of bits that have been read.

setBitCount

public void setBitCount(int count)
Sets the number of bits in this response.

Parameters:
count - the number of response bits as int.

getDiscretes

public BitVector getDiscretes()
Returns the BitVector that stores the collection of bits that have been read.

Returns:
the BitVector holding the bits that have been read.

getDiscreteStatus

public boolean getDiscreteStatus(int index)
                          throws java.lang.IndexOutOfBoundsException
Convenience method that returns the state of the bit at the given index.

Parameters:
index - the index of the input discrete for which the status should be returned.
Returns:
true if set, false otherwise.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of bounds

setDiscreteStatus

public void setDiscreteStatus(int index,
                              boolean b)
                       throws java.lang.IndexOutOfBoundsException
Sets the status of the given input discrete.

Parameters:
index - the index of the input discrete to be set.
b - true if to be set, false if to be reset.
Throws:
java.lang.IndexOutOfBoundsException - if the given index exceeds bounds.

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.