Search in sources :

Example 16 with NotConnectedException

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

the class MBrickletCO2Impl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
            logger.debug("threshold {}", tfConfig.getThreshold());
            setThreshold(tfConfig.getThreshold());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            logger.debug("callbackPeriod {}", tfConfig.getCallbackPeriod());
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
    }
    try {
        tinkerforgeDevice = new BrickletCO2(getUid(), getIpConnection());
        tinkerforgeDevice.setCO2ConcentrationCallbackPeriod(getCallbackPeriod());
        listener = new CO2ConcentrationListener();
        tinkerforgeDevice.addCO2ConcentrationListener(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) BrickletCO2(com.tinkerforge.BrickletCO2) MBrickletCO2(org.openhab.binding.tinkerforge.internal.model.MBrickletCO2) TimeoutException(com.tinkerforge.TimeoutException)

Example 17 with NotConnectedException

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

the class ObjectTemperatureImpl 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("emissivity"))) {
            setEmissivity(tfConfig.getEmissivity());
        }
    }
    thresholdBigDecimal = new BigDecimal(String.valueOf(getThreshold()));
    BrickletTemperatureIR tinkerforgeDevice = getMbrick().getTinkerforgeDevice();
    tinkerforgeDevice.setResponseExpected(BrickletTemperatureIR.FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD, false);
    try {
        tinkerforgeDevice.setObjectTemperatureCallbackPeriod(getCallbackPeriod());
        tinkerforgeDevice.setEmissivity(getEmissivity());
        temperatureListener = new ObjectTemperatureListener();
        tinkerforgeDevice.addObjectTemperatureListener(temperatureListener);
        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 : BrickletTemperatureIR(com.tinkerforge.BrickletTemperatureIR) MBrickletTemperatureIR(org.openhab.binding.tinkerforge.internal.model.MBrickletTemperatureIR) NotConnectedException(com.tinkerforge.NotConnectedException) BigDecimal(java.math.BigDecimal) TimeoutException(com.tinkerforge.TimeoutException)

Example 18 with NotConnectedException

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

the class MultiTouchDeviceImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    HighLowValue value = HighLowValue.UNDEF;
    try {
        value = extractValue(getMbrick().getTinkerforgeDevice().getTouchState());
        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 : NotConnectedException(com.tinkerforge.NotConnectedException) HighLowValue(org.openhab.binding.tinkerforge.internal.types.HighLowValue) TimeoutException(com.tinkerforge.TimeoutException)

Example 19 with NotConnectedException

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

the class PTCConnectedImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        boolean sensorConnected = tinkerforgeDevice.isSensorConnected();
        HighLowValue newValue = sensorConnected ? HighLowValue.LOW : HighLowValue.HIGH;
        setSensorValue(newValue);
    } 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) HighLowValue(org.openhab.binding.tinkerforge.internal.types.HighLowValue) TimeoutException(com.tinkerforge.TimeoutException)

Example 20 with NotConnectedException

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

the class PTCResistanceImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        int resistance = tinkerforgeDevice.getResistance();
        DecimalValue value = Tools.calculate(resistance);
        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)

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