Search in sources :

Example 86 with TimeoutException

use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.

the class MBrickletDistanceIRImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
            setThreshold(tfConfig.getThreshold());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
    }
    tinkerforgeDevice = new BrickletDistanceIR(uid, ipConnection);
    tinkerforgeDevice.setResponseExpected(BrickletDistanceIR.FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, false);
    try {
        tinkerforgeDevice.setDistanceCallbackPeriod(callbackPeriod);
        listener = new DistanceListener();
        tinkerforgeDevice.addDistanceListener(listener);
        fetchSensorValue();
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
}
Also used : NotConnectedException(com.tinkerforge.NotConnectedException) MBrickletDistanceIR(org.openhab.binding.tinkerforge.internal.model.MBrickletDistanceIR) BrickletDistanceIR(com.tinkerforge.BrickletDistanceIR) TimeoutException(com.tinkerforge.TimeoutException)

Example 87 with TimeoutException

use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.

the class MBrickletDistanceIRImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        int distance = tinkerforgeDevice.getDistance();
        DecimalValue value = Tools.calculate(distance);
        setSensorValue(value);
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
}
Also used : DecimalValue(org.openhab.binding.tinkerforge.internal.types.DecimalValue) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 88 with TimeoutException

use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.

the class MBrickletDistanceUSImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
            setThreshold(tfConfig.getThreshold());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("movingAverage"))) {
            logger.debug("{} setting movingAverage: {}", LoggerConstants.TFINIT, tfConfig.getMovingAverage());
            setMovingAverage(tfConfig.getMovingAverage());
        }
    }
    try {
        tinkerforgeDevice = new BrickletDistanceUS(getUid(), getIpConnection());
        tinkerforgeDevice.setMovingAverage(getMovingAverage());
        tinkerforgeDevice.setDistanceCallbackPeriod(getCallbackPeriod());
        listener = new DistanceListener();
        tinkerforgeDevice.addDistanceListener(listener);
        fetchSensorValue();
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
}
Also used : NotConnectedException(com.tinkerforge.NotConnectedException) MBrickletDistanceUS(org.openhab.binding.tinkerforge.internal.model.MBrickletDistanceUS) BrickletDistanceUS(com.tinkerforge.BrickletDistanceUS) TimeoutException(com.tinkerforge.TimeoutException)

Example 89 with TimeoutException

use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.

the class MBrickletAmbientLightV2Impl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        long illuminance = tinkerforgeDevice.getIlluminance();
        DecimalValue value = Tools.calculate100(illuminance);
        setSensorValue(value);
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
}
Also used : DecimalValue(org.openhab.binding.tinkerforge.internal.types.DecimalValue) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 90 with TimeoutException

use of com.tinkerforge.TimeoutException in project openhab1-addons by openhab.

the class MBrickletAnalogInImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
            setThreshold(tfConfig.getThreshold());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("movingAverage"))) {
            logger.debug("{} setting movingAverage: {}", LoggerConstants.TFINIT, tfConfig.getMovingAverage());
            setMovingAverage(tfConfig.getMovingAverage());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("range"))) {
            logger.debug("{} setting range: {}", LoggerConstants.TFINIT, tfConfig.getRange());
            setRange(tfConfig.getRange());
        }
    }
    try {
        tinkerforgeDevice = new BrickletAnalogIn(getUid(), getIpConnection());
        tinkerforgeDevice.setVoltageCallbackPeriod(getCallbackPeriod());
        tinkerforgeDevice.setAveraging(getMovingAverage());
        listener = new VoltageListener();
        tinkerforgeDevice.addVoltageListener(listener);
        fetchSensorValue();
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
}
Also used : NotConnectedException(com.tinkerforge.NotConnectedException) MBrickletAnalogIn(org.openhab.binding.tinkerforge.internal.model.MBrickletAnalogIn) BrickletAnalogIn(com.tinkerforge.BrickletAnalogIn) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

NotConnectedException (com.tinkerforge.NotConnectedException)107 TimeoutException (com.tinkerforge.TimeoutException)107 DecimalValue (org.openhab.binding.tinkerforge.internal.types.DecimalValue)36 HighLowValue (org.openhab.binding.tinkerforge.internal.types.HighLowValue)14 OnOffValue (org.openhab.binding.tinkerforge.internal.types.OnOffValue)8 BigDecimal (java.math.BigDecimal)4 Color (java.awt.Color)3 BrickServo (com.tinkerforge.BrickServo)2 BrickletColor (com.tinkerforge.BrickletColor)2 LEDState (com.tinkerforge.BrickletDualButton.LEDState)2 BrickletIO16 (com.tinkerforge.BrickletIO16)2 BrickletIO4 (com.tinkerforge.BrickletIO4)2 Position (com.tinkerforge.BrickletJoystick.Position)2 BrickletMultiTouch (com.tinkerforge.BrickletMultiTouch)2 BrickletTemperatureIR (com.tinkerforge.BrickletTemperatureIR)2 HashMap (java.util.HashMap)2 ConfigurationException (org.openhab.binding.tinkerforge.internal.config.ConfigurationException)2 MBrickletIO16 (org.openhab.binding.tinkerforge.internal.model.MBrickletIO16)2 MBrickletIO4 (org.openhab.binding.tinkerforge.internal.model.MBrickletIO4)2 LinePositionText (org.openhab.binding.tinkerforge.internal.tools.LinePositionText)2