
package uk.co.wingpath.modbus;

import java.io.*;

/**
* Interface for handlers of Modbus requests.
* <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 ModbusRequestHandler
{
    /**
    * Handles a Modbus request message and returns a response message.
    * <p>Errors are reported by throwing an exception, not by returning
    * an error response message.
    * @param request the request message.
    * @return the response message.
    * @throws ModbusException if a Modbus error occurs.
    * @throws IOException if an I/O error occurs.
    * @throws InterruptedException if the thread is interrupted.
    */
    public ModbusResponse handleRequest (ModbusRequest request)
        throws ModbusException, InterruptedException, IOException;
}

