net.wimpi.modbus.io.ModbusTransaction Maven / Gradle / Ivy
Show all versions of jamod Show documentation
/***
* Copyright 2002-2010 jamod development team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***/
package net.wimpi.modbus.io;
import net.wimpi.modbus.ModbusException;
import net.wimpi.modbus.msg.ModbusRequest;
import net.wimpi.modbus.msg.ModbusResponse;
/**
* Interface defining a ModbusTransaction.
*
* A transaction is defined by the sequence of
* sending a request message and receiving a
* related response message.
*
* @author Dieter Wimberger
* @version 1.2 (@date@)
*/
public interface ModbusTransaction {
/**
* Sets the ModbusRequest for this
* ModbusTransaction.
* The related ModbusResponse is acquired
* from the passed in ModbusRequest instance.
*
* @param req a ModbusRequest.
*/
public void setRequest(ModbusRequest req);
/**
* Returns the ModbusRequest instance
* associated with this ModbusTransaction.
*
* @return the associated ModbusRequest instance.
*/
public ModbusRequest getRequest();
/**
* Returns the ModbusResponse instance
* associated with this ModbusTransaction.
*
* @return the associated ModbusRequest instance.
*/
public ModbusResponse getResponse();
/**
* 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.
*
* @return the actual transaction identifier as
* int.
*/
public int getTransactionID();
/**
* Set the amount of retries for opening
* the connection for executing the transaction.
*
* @param retries the amount of retries as int.
*/
public void setRetries(int retries);
/**
* Returns the amount of retries for opening
* the connection for executing the transaction.
*
* @return the amount of retries as int.
*/
public int getRetries();
/**
* Sets the flag that controls whether the
* validity of a transaction will be checked.
*
* @param b true if checking validity, false otherwise.
*/
public void setCheckingValidity(boolean b);
/**
* Tests whether the validity of a transaction
* will be checked.
*
* @return true if checking validity, false otherwise.
*/
public boolean isCheckingValidity();
/**
* 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.
*/
public void execute() throws ModbusException;
}//interface ModbusTransaction