Search in sources :

Example 1 with WSControllerState

use of org.openhab.binding.ihc.ws.datatypes.WSControllerState in project openhab1-addons by openhab.

the class IhcControllerService method getControllerState.

/**
     * Query controller current state.
     * 
     * @return controller's current state.
     */
public synchronized WSControllerState getControllerState() throws IhcExecption {
    openConnection(url);
    setRequestProperty("SOAPAction", "getState");
    String response = sendQuery(emptyQuery, timeout);
    closeConnection();
    WSControllerState controllerState = new WSControllerState();
    controllerState.encodeData(response);
    return controllerState;
}
Also used : WSControllerState(org.openhab.binding.ihc.ws.datatypes.WSControllerState)

Example 2 with WSControllerState

use of org.openhab.binding.ihc.ws.datatypes.WSControllerState in project openhab1-addons by openhab.

the class IhcControllerService method waitStateChangeNotifications.

/**
     * Wait controller state change notification.
     * 
     * @param previousState
     *            Previous controller state.
     * @param timeoutInSeconds
     *            How many seconds to wait notifications.
     * @return current controller state.
     */
public synchronized WSControllerState waitStateChangeNotifications(WSControllerState previousState, int timeoutInSeconds) throws IhcExecption {
    final String soapQuery = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<soapenv:Header/>" + "<soapenv:Body>" + " <ns1:waitForControllerStateChange1 xmlns:ns1=\"utcs\" xsi:type=\"ns1:WSControllerState\">" + "  <ns1:state xsi:type=\"xsd:string\">%s</ns1:state>" + " </ns1:waitForControllerStateChange1>" + " <ns2:waitForControllerStateChange2 xmlns:ns2=\"utcs\" xsi:type=\"xsd:int\">%s</ns2:waitForControllerStateChange2>" + "</soapenv:Body>" + "</soapenv:Envelope>";
    String query = String.format(soapQuery, previousState.getState(), timeoutInSeconds);
    openConnection(url);
    setRequestProperty("SOAPAction", "waitForControllerStateChange");
    String response = sendQuery(query, timeout + timeoutInSeconds * 1000);
    closeConnection();
    WSControllerState controllerState = new WSControllerState();
    controllerState.encodeData(response);
    return controllerState;
}
Also used : WSControllerState(org.openhab.binding.ihc.ws.datatypes.WSControllerState)

Aggregations

WSControllerState (org.openhab.binding.ihc.ws.datatypes.WSControllerState)2