Search in sources :

Example 71 with NotConnectedException

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

the class MIndustrialDigitalInImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    HighLowValue value = HighLowValue.UNDEF;
    try {
        value = extractValue(getMbrick().getTinkerforgeDevice().getValue());
        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 72 with NotConnectedException

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

the class MIndustrialQuadRelayImpl method fetchSwitchState.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSwitchState() {
    OnOffValue value = OnOffValue.UNDEF;
    try {
        int deviceValue = getMbrick().getTinkerforgeDevice().getValue();
        if ((deviceValue & mask) == mask) {
            value = OnOffValue.ON;
        } else {
            value = OnOffValue.OFF;
        }
        setSwitchState(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 : OnOffValue(org.openhab.binding.tinkerforge.internal.types.OnOffValue) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 73 with NotConnectedException

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

the class MBrickletThermocoupleImpl method fetchSensorValue.

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

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

the class MBrickletSoundIntensityImpl method fetchSensorValue.

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

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

the class MBrickletThermocoupleImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void enable() {
    List<Short> possibleAveragingValues = Arrays.asList(new Short[] { 1, 2, 4, 8, 16 });
    List<String> possibleTypeValues = Arrays.asList(new String[] { "B", "E", "J", "K", "N", "R", "S", "T", "G8", "G32" });
    List<String> possibleFilterValues = Arrays.asList(new String[] { "50", "60" });
    short averaging = BrickletThermocouple.AVERAGING_1;
    short thermocoupleTypeId = BrickletThermocouple.TYPE_K;
    short filterId = BrickletThermocouple.FILTER_OPTION_50HZ;
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
            logger.debug("threshold {}", tfConfig.getThreshold());
            setThreshold(tfConfig.getThreshold());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            logger.debug("callbackPeriod {}", tfConfig.getCallbackPeriod());
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("averaging"))) {
            Short averagingConfig = tfConfig.getAveraging();
            if (!possibleAveragingValues.contains(averagingConfig)) {
                logger.error("invalid averaging configuration {}", averagingConfig);
                throw new ConfigurationException("invalid averaging configuration " + averagingConfig);
            }
            averaging = averagingConfig;
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("thermocoupleType"))) {
            String thermocoupleType = tfConfig.getThermocoupleType();
            if (!possibleTypeValues.contains(thermocoupleType)) {
                logger.error("invalid thermocoupleType {}", thermocoupleType);
                throw new ConfigurationException("invalid thermocoupleType" + thermocoupleType);
            }
            thermocoupleTypeId = getTypeId(thermocoupleType);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("filter"))) {
            String filterConfig = tfConfig.getFilter();
            if (!possibleFilterValues.contains(filterConfig)) {
                logger.error("invalid filter configuration {}", filterConfig);
                throw new ConfigurationException("invalid filter configuration" + filterConfig);
            }
            filterId = filterConfig.equals("50") ? BrickletThermocouple.FILTER_OPTION_50HZ : BrickletThermocouple.FILTER_OPTION_60HZ;
        }
    }
    try {
        tinkerforgeDevice = new BrickletThermocouple(getUid(), getIpConnection());
        tinkerforgeDevice.setConfiguration(averaging, thermocoupleTypeId, filterId);
        tinkerforgeDevice.setTemperatureCallbackPeriod(getCallbackPeriod());
        listener = new TemperatureListener();
        tinkerforgeDevice.addTemperatureListener(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 : NotConnectedException(com.tinkerforge.NotConnectedException) ConfigurationException(org.openhab.binding.tinkerforge.internal.config.ConfigurationException) MBrickletThermocouple(org.openhab.binding.tinkerforge.internal.model.MBrickletThermocouple) BrickletThermocouple(com.tinkerforge.BrickletThermocouple) 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