Search in sources :

Example 1 with Acceleration

use of com.tinkerforge.BrickletAccelerometer.Acceleration 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)

Aggregations

Acceleration (com.tinkerforge.BrickletAccelerometer.Acceleration)1 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 DecimalValue (org.openhab.binding.tinkerforge.internal.types.DecimalValue)1