net.wimpi.modbus.io
Interface ModbusTransaction

All Known Implementing Classes:
ModbusSerialTransaction, ModbusTCPTransaction, ModbusUDPTransaction

public interface ModbusTransaction

Interface defining a ModbusTransaction.

A transaction is defined by the sequence of sending a request message and receiving a related response message.

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

Method Summary
 void execute()
          Executes this ModbusTransaction.
 ModbusRequest getRequest()
          Returns the ModbusRequest instance associated with this ModbusTransaction.
 ModbusResponse getResponse()
          Returns the ModbusResponse instance associated with this ModbusTransaction.
 int getRetries()
          Returns the amount of retries for opening the connection for executing the transaction.
 int getTransactionID()
          Returns the actual transaction identifier of this ModbusTransaction.
 boolean isCheckingValidity()
          Tests whether the validity of a transaction will be checked.
 void setCheckingValidity(boolean b)
          Sets the flag that controls whether the validity of a transaction will be checked.
 void setRequest(ModbusRequest req)
          Sets the ModbusRequest for this ModbusTransaction.
 void setRetries(int retries)
          Set the amount of retries for opening the connection for executing the transaction.
 

Method Detail

setRequest

void setRequest(ModbusRequest req)
Sets the ModbusRequest for this ModbusTransaction.

The related ModbusResponse is acquired from the passed in ModbusRequest instance.

Parameters:
req - a ModbusRequest.

getRequest

ModbusRequest getRequest()
Returns the ModbusRequest instance associated with this ModbusTransaction.

Returns:
the associated ModbusRequest instance.

getResponse

ModbusResponse getResponse()
Returns the ModbusResponse instance associated with this ModbusTransaction.

Returns:
the associated ModbusRequest instance.

getTransactionID

int getTransactionID()
Returns the actual transaction identifier of this ModbusTransaction. The identifier is a 2-byte (short) non negative integer value valid in the range of 0-65535.

Returns:
the actual transaction identifier as int.

setRetries

void setRetries(int retries)
Set the amount of retries for opening the connection for executing the transaction.

Parameters:
retries - the amount of retries as int.

getRetries

int getRetries()
Returns the amount of retries for opening the connection for executing the transaction.

Returns:
the amount of retries as int.

setCheckingValidity

void setCheckingValidity(boolean b)
Sets the flag that controls whether the validity of a transaction will be checked.

Parameters:
b - true if checking validity, false otherwise.

isCheckingValidity

boolean isCheckingValidity()
Tests whether the validity of a transaction will be checked.

Returns:
true if checking validity, false otherwise.

execute

void execute()
             throws ModbusException
Executes this ModbusTransaction. Locks the ModbusTransport for sending the ModbusRequest and reading the related ModbusResponse. If reconnecting is activated the connection will be opened for the transaction and closed afterwards.

Throws:
ModbusException - if an I/O error occurs, or the response is a modbus protocol exception.


Copyright © 2010. All Rights Reserved.