Search in sources :

Example 1 with Sapp82Command

use of com.github.paolodenti.jsapp.core.command.Sapp82Command in project openhab1-addons by openhab.

the class SappCentralExecuter method executePollingSappCommands.

/**
     * runs polling on virtuals, inputs, outputs
     */
public PollingResult executePollingSappCommands(String ip, int port) throws SappException {
    synchronized (this) {
        PollingResult pollingResult = new PollingResult();
        SappConnection sappConnection = null;
        try {
            sappConnection = new SappConnection(ip, port);
            sappConnection.openConnection();
            SappCommand sappCommand;
            sappCommand = new Sapp80Command();
            sappCommand.run(sappConnection);
            if (!sappCommand.isResponseOk()) {
                throw new SappException("Sapp80Command command execution failed");
            }
            pollingResult.changedOutputs = sappCommand.getResponse().getDataAsByteWordMap();
            sappCommand = new Sapp81Command();
            sappCommand.run(sappConnection);
            if (!sappCommand.isResponseOk()) {
                throw new SappException("Sapp81Command command execution failed");
            }
            pollingResult.changedInputs = sappCommand.getResponse().getDataAsByteWordMap();
            sappCommand = new Sapp82Command();
            sappCommand.run(sappConnection);
            if (!sappCommand.isResponseOk()) {
                throw new SappException("Sapp82Command command execution failed");
            }
            pollingResult.changedVirtuals = sappCommand.getResponse().getDataAsWordWordMap();
            return pollingResult;
        } catch (IOException e) {
            throw new SappException(e.getMessage());
        } finally {
            if (sappConnection != null) {
                sappConnection.closeConnection();
            }
        }
    }
}
Also used : SappCommand(com.github.paolodenti.jsapp.core.command.base.SappCommand) SappConnection(com.github.paolodenti.jsapp.core.command.base.SappConnection) Sapp82Command(com.github.paolodenti.jsapp.core.command.Sapp82Command) IOException(java.io.IOException) Sapp80Command(com.github.paolodenti.jsapp.core.command.Sapp80Command) SappException(com.github.paolodenti.jsapp.core.command.base.SappException) Sapp81Command(com.github.paolodenti.jsapp.core.command.Sapp81Command)

Aggregations

Sapp80Command (com.github.paolodenti.jsapp.core.command.Sapp80Command)1 Sapp81Command (com.github.paolodenti.jsapp.core.command.Sapp81Command)1 Sapp82Command (com.github.paolodenti.jsapp.core.command.Sapp82Command)1 SappCommand (com.github.paolodenti.jsapp.core.command.base.SappCommand)1 SappConnection (com.github.paolodenti.jsapp.core.command.base.SappConnection)1 SappException (com.github.paolodenti.jsapp.core.command.base.SappException)1 IOException (java.io.IOException)1