Search in sources :

Example 96 with TimeoutException

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

the class MBrickletMotionDetectorImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    HighLowValue value = HighLowValue.UNDEF;
    try {
        short motionDetected = tinkerforgeDevice.getMotionDetected();
        if (motionDetected == 1) {
            value = HighLowValue.HIGH;
        } else {
            value = HighLowValue.LOW;
        }
        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 97 with TimeoutException

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

the class MBrickletLaserRangeFinderImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("distanceAverageLength"))) {
            Short distanceAverageLength = tfConfig.getDistanceAverageLength();
            logger.debug("distanceAverageLength {}", distanceAverageLength);
            setDistanceAverageLength(distanceAverageLength);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("velocityAverageLength"))) {
            Short velocityAverageLength = tfConfig.getVelocityAverageLength();
            logger.debug("velocityAverageLength {}", velocityAverageLength);
            setVelocityAverageLength(velocityAverageLength);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("mode"))) {
            Short mode = tfConfig.getMode();
            logger.debug("mode {}", mode);
            setMode(mode);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("enableLaserOnStartup"))) {
            boolean enableLaser = tfConfig.getEnableLaserOnStartup();
            logger.debug("enable laser on startup {}", enableLaser);
            setEnableLaserOnStartup(enableLaser);
        } else {
            boolean enableLaser = tfConfig.getEnableLaserOnStartup();
            logger.debug("enable laser on startup {}", enableLaser);
        }
    }
    try {
        tinkerforgeDevice = new BrickletLaserRangeFinder(getUid(), getIpConnection());
        tinkerforgeDevice.setMode(getMode());
        tinkerforgeDevice.setMovingAverage(getDistanceAverageLength(), getVelocityAverageLength());
        if (getEnableLaserOnStartup()) {
            logger.debug("enabling laser");
            tinkerforgeDevice.enableLaser();
        }
    } 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 : MBrickletLaserRangeFinder(org.openhab.binding.tinkerforge.internal.model.MBrickletLaserRangeFinder) BrickletLaserRangeFinder(com.tinkerforge.BrickletLaserRangeFinder) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 98 with TimeoutException

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

the class MBrickletLinearPotiImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    setCallbackPeriod(10);
    if (tfConfig != null) {
        logger.trace("got configuration");
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            logger.trace("found callbackPeriod");
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
    }
    logger.trace("callbackPeriod is {}", getCallbackPeriod());
    tinkerforgeDevice = new BrickletLinearPoti(getUid(), getIpConnection());
    listener = new PositionListener();
    tinkerforgeDevice.addPositionListener(listener);
    fetchSensorValue();
    try {
        tinkerforgeDevice.setPositionCallbackPeriod(getCallbackPeriod());
    } 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) BrickletLinearPoti(com.tinkerforge.BrickletLinearPoti) MBrickletLinearPoti(org.openhab.binding.tinkerforge.internal.model.MBrickletLinearPoti) TimeoutException(com.tinkerforge.TimeoutException)

Example 99 with TimeoutException

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

the class MBrickletLinearPotiImpl method fetchSensorValue.

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

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

the class MBrickletMoistureImpl method fetchSensorValue.

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