net.wimpi.modbus.msg
Class ModbusRequest

java.lang.Object
  extended by net.wimpi.modbus.msg.ModbusMessageImpl
      extended by net.wimpi.modbus.msg.ModbusRequest
All Implemented Interfaces:
Transportable, ModbusMessage
Direct Known Subclasses:
IllegalFunctionRequest, ReadCoilsRequest, ReadInputDiscretesRequest, ReadInputRegistersRequest, ReadMultipleRegistersRequest, WriteCoilRequest, WriteMultipleCoilsRequest, WriteMultipleRegistersRequest, WriteSingleRegisterRequest

public abstract class ModbusRequest
extends ModbusMessageImpl

Abstract class implementing a ModbusRequest. This class provides specialised implementations with the functionality they have in common.

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

Constructor Summary
ModbusRequest()
           
 
Method Summary
 ModbusResponse createExceptionResponse(int EXCEPTION_CODE)
          Factory method for creating exception responses with the given exception code.
static ModbusRequest createModbusRequest(int functionCode)
          Factory method creating the required specialized ModbusRequest instance.
abstract  ModbusResponse createResponse()
          Returns the ModbusResponse that represents the answer to this ModbusRequest.
 
Methods inherited from class net.wimpi.modbus.msg.ModbusMessageImpl
getDataLength, getFunctionCode, getHexMessage, getOutputLength, getProtocolID, getTransactionID, getUnitID, isHeadless, readData, readFrom, setDataLength, setHeadless, setProtocolID, setTransactionID, setUnitID, writeData, writeTo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModbusRequest

public ModbusRequest()
Method Detail

createResponse

public abstract ModbusResponse createResponse()
Returns the ModbusResponse that represents the answer to this ModbusRequest.

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

Returns:
the corresponding ModbusResponse.

createExceptionResponse

public ModbusResponse createExceptionResponse(int EXCEPTION_CODE)
Factory method for creating exception responses with the given exception code.

Parameters:
EXCEPTION_CODE - the code of the exception.
Returns:
a ModbusResponse instance representing the exception response.

createModbusRequest

public static ModbusRequest createModbusRequest(int functionCode)
Factory method creating the required specialized ModbusRequest instance.

Parameters:
functionCode - the function code of the request as int.
Returns:
a ModbusRequest instance specific for the given function type.


Copyright © 2010. All Rights Reserved.