Search in sources :

Example 81 with TimeoutException

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

the class AccelerometerDirectionImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    Short currAcceleration;
    Acceleration acceleration;
    try {
        acceleration = tinkerforgeDevice.getAcceleration();
        if (getDirection() == AccelerometerCoordinate.X) {
            currAcceleration = acceleration.x;
        } else if (getDirection() == AccelerometerCoordinate.Y) {
            currAcceleration = acceleration.y;
        } else {
            currAcceleration = acceleration.z;
        }
        DecimalValue value = Tools.calculate1000(currAcceleration);
        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) Acceleration(com.tinkerforge.BrickletAccelerometer.Acceleration) TimeoutException(com.tinkerforge.TimeoutException)

Example 82 with TimeoutException

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

the class AccelerometerLedImpl method fetchDigitalValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchDigitalValue() {
    try {
        HighLowValue value = tinkerforgeDevice.isLEDOn() ? HighLowValue.HIGH : HighLowValue.LOW;
        setDigitalState(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 83 with TimeoutException

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

the class MBrickDCImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    tinkerforgeDevice = new BrickDC(uid, ipConnection);
    if (tfConfig != null) {
        logger.debug("found tfConfig");
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("acceleration"))) {
            setAcceleration(tfConfig.getAcceleration());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("pwmFrequency"))) {
            setPwmFrequency(tfConfig.getPwmFrequency());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("driveMode"))) {
            setDriveMode(DCDriveMode.get(tfConfig.getDriveMode()));
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
            setThreshold(tfConfig.getThreshold());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
    }
    try {
        tinkerforgeDevice.setPWMFrequency(pwmFrequency);
        if (driveMode == DCDriveMode.BRAKE) {
            tinkerforgeDevice.setDriveMode(BrickDC.DRIVE_MODE_DRIVE_BRAKE);
        } else if (driveMode == DCDriveMode.COAST) {
            tinkerforgeDevice.setDriveMode(BrickDC.DRIVE_MODE_DRIVE_COAST);
        }
        tinkerforgeDevice.setCurrentVelocityPeriod((int) callbackPeriod);
        listener = new VelocityListener();
        tinkerforgeDevice.addCurrentVelocityListener(listener);
        tinkerforgeDevice.enable();
        handleVelocity(tinkerforgeDevice.getVelocity(), false);
    } 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) MBrickDC(org.openhab.binding.tinkerforge.internal.model.MBrickDC) BrickDC(com.tinkerforge.BrickDC) TimeoutException(com.tinkerforge.TimeoutException)

Example 84 with TimeoutException

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

the class MBrickletBarometerImpl 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 BrickletBarometer(uid, ipConnection);
    try {
        tinkerforgeDevice.setResponseExpected(BrickletBarometer.FUNCTION_SET_AIR_PRESSURE_CALLBACK_PERIOD, false);
        tinkerforgeDevice.setAirPressureCallbackPeriod(callbackPeriod);
        listener = new AirPressureListener();
        tinkerforgeDevice.addAirPressureListener(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 : MBrickletBarometer(org.openhab.binding.tinkerforge.internal.model.MBrickletBarometer) BrickletBarometer(com.tinkerforge.BrickletBarometer) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 85 with TimeoutException

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

the class MBrickletCO2Impl method fetchSensorValue.

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