
package uk.co.wingpath.modbus;

import java.io.*;

/**
* Interface for handlers of Modbus transaction.
* <p>This interface may implemented within a slave or within a master.
* <p>The interface may be implemented in a slave by interrogating/updating a
* model and constructing a response to be sent back to a master.
* <p>The interface may be implemented in a master by sending a message to
* a slave and receiving a response.
*/
public interface ModbusTransactionHandler
{
    /**
    * Handles a Modbus request message.
    * <p>If the transaction has a response handler, handleTransaction may return
    * before procesing of the transaction is finished. The response handler
    * will be called when processing has finished.
    * <p>If the transaction does not have a response handler, handleTransaction
    * will not return until processing is finished.
    * @param trans the transaction.
    * @throws IOException if an I/O error occurs.
    * @throws InterruptedException if the thread is interrupted.
    */
    public void handleTransaction (ModbusTransaction trans)
        throws InterruptedException;
}

