net.wimpi.modbus.msg
Class WriteCoilRequest

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

public final class WriteCoilRequest
extends ModbusRequest

Class implementing a WriteCoilRequest. The implementation directly correlates with the class 0 function write coil (FC 5). It encapsulates the corresponding request message.

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

Constructor Summary
WriteCoilRequest()
          Constructs a new WriteCoilRequest instance.
WriteCoilRequest(int ref, boolean b)
          Constructs a new WriteCoilRequest instance with a given reference and state to be written.
 
Method Summary
 ModbusResponse createResponse()
          Returns the ModbusResponse that represents the answer to this ModbusRequest.
 boolean getCoil()
          Returns the state that should be written with this WriteCoilRequest.
 int getReference()
          Returns the reference of the register of the coil that should be written to with this ReadCoilsRequest.
 void readData(DataInput din)
          Reads the subclass specific data from the given DataInput instance.
 void setCoil(boolean b)
          Sets the state that should be written with this WriteCoilRequest.
 void setReference(int ref)
          Sets the reference of the register of the coil that should be written to with this ReadCoilsRequest.
 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

WriteCoilRequest

public WriteCoilRequest()
Constructs a new WriteCoilRequest instance.


WriteCoilRequest

public WriteCoilRequest(int ref,
                        boolean b)
Constructs a new WriteCoilRequest instance with a given reference and state to be written.

Parameters:
ref - the reference number of the register to read from.
b - true if the coil should be set of false if it should be unset.
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 of the coil that should be written to with this ReadCoilsRequest.

Parameters:
ref - the reference of the coil's register.

getReference

public int getReference()
Returns the reference of the register of the coil that should be written to with this ReadCoilsRequest.

Returns:
the reference of the coil's register.

setCoil

public void setCoil(boolean b)
Sets the state that should be written with this WriteCoilRequest.

Parameters:
b - true if the coil should be set of false if it should be unset.

getCoil

public boolean getCoil()
Returns the state that should be written with this WriteCoilRequest.

Returns:
true if the coil should be set of false if it should be unset.

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.