Search in sources :

Example 11 with TimeoutException

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

the class RotaryEncoderImpl method fetchSensorValue.

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

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

the class Dual020mADeviceImpl method fetchSensorValue.

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

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

the class DualButtonButtonImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    if (tactile || this.sensorValue == null || this.sensorValue == OnOffValue.UNDEF) {
        try {
            ButtonState buttonState = tinkerforgeDevice.getButtonState();
            OnOffValue newValue;
            if (position == DualButtonDevicePosition.LEFT) {
                newValue = getValue4State(buttonState.buttonL);
            } else {
                newValue = getValue4State(buttonState.buttonR);
            }
            setSensorValue(newValue);
            logger.trace("{} fetch value: {}", position, newValue);
        } catch (TimeoutException e) {
            TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
        } catch (NotConnectedException e) {
            TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
        }
    } else {
        // send current state to update the eventbus
        setSensorValue(getSensorValue());
    }
}
Also used : OnOffValue(org.openhab.binding.tinkerforge.internal.types.OnOffValue) NotConnectedException(com.tinkerforge.NotConnectedException) ButtonState(com.tinkerforge.BrickletDualButton.ButtonState) TimeoutException(com.tinkerforge.TimeoutException)

Example 14 with TimeoutException

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

the class JoystickYPositionImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        Position position = tinkerforgeDevice.getPosition();
        DecimalValue value = Tools.calculate(position.y);
        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) Position(com.tinkerforge.BrickletJoystick.Position) JoystickYPosition(org.openhab.binding.tinkerforge.internal.model.JoystickYPosition) TimeoutException(com.tinkerforge.TimeoutException)

Example 15 with TimeoutException

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

the class LEDGroupImpl method setSelectedColor.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void setSelectedColor(HSBType color) {
    // get the rgb values from HSBType
    Color rgbColor = color.toColor();
    short red = (short) rgbColor.getRed();
    short green = (short) rgbColor.getGreen();
    short blue = (short) rgbColor.getBlue();
    logger.debug("rgb is: {}:{}:{}", red, green, blue);
    // construct the values for the setRGBValues call
    HashMap<Character, short[]> colorMap = new HashMap<Character, short[]>(3);
    short[] reds = { red, red, red, red, red, red, red, red, red, red, red, red, red, red, red, red };
    short[] greens = { green, green, green, green, green, green, green, green, green, green, green, green, green, green, green, green };
    short[] blues = { blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue, blue };
    colorMap.put('r', reds);
    colorMap.put('g', greens);
    colorMap.put('b', blues);
    try {
        if (ledList.hasLedRanges()) {
            Map<Integer, Short> ledRanges = ledList.getLedRanges();
            for (Integer led : ledRanges.keySet()) {
                logger.debug("setting color for range from led {} to range {}", led, ledRanges.get(led));
                logger.debug("color from mapping{},{},{}", colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
                tinkerforgeDevice.setRGBValues(led, ledRanges.get(led), colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
            }
        }
        if (ledList.hasLeds()) {
            for (Integer led : ledList.getLedNumbers()) {
                logger.debug("setting color for led {}", led);
                logger.debug("color from mapping{},{},{}", colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
                tinkerforgeDevice.setRGBValues(led, (short) 1, colorMap.get(colorMapping[0]), colorMap.get(colorMapping[1]), colorMap.get(colorMapping[2]));
            }
        }
        setColor(new HSBValue(color));
    } 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) HashMap(java.util.HashMap) Color(java.awt.Color) HSBValue(org.openhab.binding.tinkerforge.internal.types.HSBValue) 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