Search in sources :

Example 1 with SappCommand

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

the class SappCentralExecuter method executeSapp7CCommand.

/**
     * runs 7C command
     */
public int executeSapp7CCommand(String ip, int port, int address) throws SappException {
    synchronized (this) {
        SappCommand sappCommand = new Sapp7CCommand(address);
        sappCommand.run(ip, port);
        if (!sappCommand.isResponseOk()) {
            throw new SappException("command execution failed");
        }
        return sappCommand.getResponse().getDataAsWord();
    }
}
Also used : SappCommand(com.github.paolodenti.jsapp.core.command.base.SappCommand) Sapp7CCommand(com.github.paolodenti.jsapp.core.command.Sapp7CCommand) SappException(com.github.paolodenti.jsapp.core.command.base.SappException)

Example 2 with SappCommand

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

the class SappCentralExecuter method executeSapp74Command.

/**
     * runs 74 command
     */
public int executeSapp74Command(String ip, int port, byte address) throws SappException {
    synchronized (this) {
        SappCommand sappCommand = new Sapp74Command(address);
        sappCommand.run(ip, port);
        if (!sappCommand.isResponseOk()) {
            throw new SappException("command execution failed");
        }
        return sappCommand.getResponse().getDataAsWord();
    }
}
Also used : SappCommand(com.github.paolodenti.jsapp.core.command.base.SappCommand) Sapp74Command(com.github.paolodenti.jsapp.core.command.Sapp74Command) SappException(com.github.paolodenti.jsapp.core.command.base.SappException)

Example 3 with SappCommand

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

the class SappCentralExecuter method executeSapp7DCommand.

/**
     * runs 7D command
     */
public void executeSapp7DCommand(String ip, int port, int address, int value) throws SappException {
    synchronized (this) {
        SappCommand sappCommand = new Sapp7DCommand(address, value);
        sappCommand.run(ip, port);
        if (!sappCommand.isResponseOk()) {
            throw new SappException("command execution failed");
        }
    }
}
Also used : SappCommand(com.github.paolodenti.jsapp.core.command.base.SappCommand) Sapp7DCommand(com.github.paolodenti.jsapp.core.command.Sapp7DCommand) SappException(com.github.paolodenti.jsapp.core.command.base.SappException)

Example 4 with SappCommand

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

the class SappCentralExecuter method executeSapp75Command.

/**
     * runs 75 command
     */
public int executeSapp75Command(String ip, int port, byte address) throws SappException {
    synchronized (this) {
        SappCommand sappCommand = new Sapp75Command(address);
        sappCommand.run(ip, port);
        if (!sappCommand.isResponseOk()) {
            throw new SappException("command execution failed");
        }
        return sappCommand.getResponse().getDataAsWord();
    }
}
Also used : SappCommand(com.github.paolodenti.jsapp.core.command.base.SappCommand) Sapp75Command(com.github.paolodenti.jsapp.core.command.Sapp75Command) SappException(com.github.paolodenti.jsapp.core.command.base.SappException)

Example 5 with SappCommand

use of com.github.paolodenti.jsapp.core.command.base.SappCommand 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

SappCommand (com.github.paolodenti.jsapp.core.command.base.SappCommand)5 SappException (com.github.paolodenti.jsapp.core.command.base.SappException)5 Sapp74Command (com.github.paolodenti.jsapp.core.command.Sapp74Command)1 Sapp75Command (com.github.paolodenti.jsapp.core.command.Sapp75Command)1 Sapp7CCommand (com.github.paolodenti.jsapp.core.command.Sapp7CCommand)1 Sapp7DCommand (com.github.paolodenti.jsapp.core.command.Sapp7DCommand)1 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 SappConnection (com.github.paolodenti.jsapp.core.command.base.SappConnection)1 IOException (java.io.IOException)1