jamod at SF

net.wimpi.modbus.msg
Class WriteMultipleCoilsRequest

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

public final class WriteMultipleCoilsRequest
extends ModbusRequest

Class implementing a WriteMultipleCoilsRequest. The implementation directly correlates with the class 1 function write multiple coils (FC 15). It encapsulates the corresponding request message.

Coils are understood as bits that can be manipulated (i.e. set or unset).

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

Constructor Summary
WriteMultipleCoilsRequest()
          Constructs a new ReadCoilsRequest instance.
WriteMultipleCoilsRequest(int ref, BitVector bv)
          Constructs a new WriteMultipleCoilsRequest instance with given reference and coil status.
WriteMultipleCoilsRequest(int ref, int count)
          Constructs a new WriteMultipleCoilsRequest instance with a given reference and count of coils (i.e. bits) to be written.
 
Method Summary
 ModbusResponse createResponse()
          Returns the ModbusResponse that represents the answer to this ModbusRequest.
 int getBitCount()
          Returns the number of bits (i.e. input discretes) read with the request.
 int getByteCount()
          Returns the number of bytes required for packing the coil bits.
 BitVector getCoils()
          Returns the BitVector instance holding coil status information.
 boolean getCoilStatus(int index)
          Returns the status of the given coil.
 int getReference()
          Returns the reference of the register to to start reading from with this ReadCoilsRequest.
 void readData(java.io.DataInput din)
          Reads the subclass specific data from the given DataInput instance.
 void setCoils(BitVector bv)
          Sets the BitVector instance holding coil status information.
 void setCoilStatus(int index, boolean b)
          Sets the coil status of the given coil.
 void setReference(int ref)
          Sets the reference of the register to start reading from with this ReadCoilsRequest.
 void writeData(java.io.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, 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

WriteMultipleCoilsRequest

public WriteMultipleCoilsRequest()
Constructs a new ReadCoilsRequest instance.


WriteMultipleCoilsRequest

public WriteMultipleCoilsRequest(int ref,
                                 int count)
Constructs a new WriteMultipleCoilsRequest instance with a given reference and count of coils (i.e. bits) to be written.

Parameters:
ref - the index of the first coil to be written.
count - the number of coils to be written.

WriteMultipleCoilsRequest

public WriteMultipleCoilsRequest(int ref,
                                 BitVector bv)
Constructs a new WriteMultipleCoilsRequest instance with given reference and coil status.

Parameters:
ref - the index of the first coil to be written.
bv - the coils to be written.
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 ReadCoilsRequest.

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 ReadCoilsRequest.

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

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.

getByteCount

public int getByteCount()
Returns the number of bytes required for packing the coil bits.

Returns:
the number of bytes required for packing the coil bits.

getCoilStatus

public boolean getCoilStatus(int index)
                      throws java.lang.IndexOutOfBoundsException
Returns the status of the given coil.

Parameters:
index - the index of the coil to be tested.
Returns:
true if set, false otherwise.
Throws:
java.lang.IndexOutOfBoundsException - if the given index is out of bounds.

setCoilStatus

public void setCoilStatus(int index,
                          boolean b)
                   throws java.lang.IndexOutOfBoundsException
Sets the coil status of the given coil.

Parameters:
index - the index of the coil to be set/reset.
b - true if to be set, false for reset.
Throws:
java.lang.IndexOutOfBoundsException - if the given index is out of bounds.

getCoils

public BitVector getCoils()
Returns the BitVector instance holding coil status information.

Returns:
the coils status as BitVector instance.

setCoils

public void setCoils(BitVector bv)
Sets the BitVector instance holding coil status information.

Parameters:
bv - a BitVector instance holding coil status info.

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.