Search in sources :

Example 16 with TimeoutException

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

the class LaserRangeFinderDistanceImpl 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 17 with TimeoutException

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

the class LaserRangeFinderLaserImpl method fetchDigitalValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchDigitalValue() {
    try {
        HighLowValue value = tinkerforgeDevice.isLaserEnabled() ? 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 18 with TimeoutException

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

the class DualButtonLedImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    tinkerforgeDevice = getMbrick().getTinkerforgeDevice();
    boolean autotoggle = false;
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("autotoggle"))) {
            autotoggle = tfConfig.isAutotoggle();
        }
    }
    logger.trace("autotoggle for {} is {}", position, autotoggle);
    try {
        short ledstate;
        short led;
        LEDState ledState = tinkerforgeDevice.getLEDState();
        if (position == DualButtonDevicePosition.LEFT) {
            ledstate = ledState.ledL;
            led = BrickletDualButton.LED_LEFT;
        } else {
            ledstate = ledState.ledR;
            led = BrickletDualButton.LED_RIGHT;
        }
        if (!autotoggle) {
            logger.trace("autotoggle is off for led {}", led);
            if (ledstate == BrickletDualButton.LED_STATE_AUTO_TOGGLE_OFF) {
                tinkerforgeDevice.setSelectedLEDState(led, BrickletDualButton.LED_STATE_OFF);
                logger.trace("setting led {} to off", led);
            } else if (ledstate == BrickletDualButton.LED_STATE_AUTO_TOGGLE_ON) {
                tinkerforgeDevice.setSelectedLEDState(led, BrickletDualButton.LED_STATE_ON);
                logger.trace("setting led {} to on", led);
            }
        } else {
            logger.trace("autotoggle is on for led {}", led);
            if (ledstate == BrickletDualButton.LED_STATE_OFF) {
                tinkerforgeDevice.setSelectedLEDState(led, BrickletDualButton.LED_STATE_AUTO_TOGGLE_OFF);
                logger.trace("setting led {} to off", led);
            } else if (ledstate == BrickletDualButton.LED_STATE_ON) {
                tinkerforgeDevice.setSelectedLEDState(led, BrickletDualButton.LED_STATE_AUTO_TOGGLE_ON);
                logger.trace("setting led {} to on", led);
            }
        }
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
    listener = new StateListener();
    tinkerforgeDevice.addStateChangedListener(listener);
    fetchDigitalValue();
}
Also used : NotConnectedException(com.tinkerforge.NotConnectedException) LEDState(com.tinkerforge.BrickletDualButton.LEDState) TimeoutException(com.tinkerforge.TimeoutException)

Example 19 with TimeoutException

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

the class LaserRangeFinderVelocityImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        int velocity = tinkerforgeDevice.getVelocity();
        DecimalValue value = Tools.calculate100(velocity);
        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 20 with TimeoutException

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

the class MBarometerTemperatureImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        short chipTemperature = getMbrick().getTinkerforgeDevice().getChipTemperature();
        DecimalValue value = Tools.calculate100(chipTemperature);
        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