Search in sources :

Example 1 with NotConnectedException

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

the class MBrickletSoundIntensityImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("threshold"))) {
            setThreshold(tfConfig.getThreshold());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("callbackPeriod"))) {
            setCallbackPeriod(tfConfig.getCallbackPeriod());
        }
    }
    try {
        tinkerforgeDevice = new BrickletSoundIntensity(getUid(), getIpConnection());
        tinkerforgeDevice.setIntensityCallbackPeriod(getCallbackPeriod());
        listener = new SoundIntensityListener();
        tinkerforgeDevice.addIntensityListener(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) MBrickletSoundIntensity(org.openhab.binding.tinkerforge.internal.model.MBrickletSoundIntensity) BrickletSoundIntensity(com.tinkerforge.BrickletSoundIntensity) TimeoutException(com.tinkerforge.TimeoutException)

Example 2 with NotConnectedException

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

the class MBrickletSolidStateRelayImpl method fetchSwitchState.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSwitchState() {
    try {
        OnOffValue switchValue = OnOffValue.UNDEF;
        boolean state = tinkerforgeDevice.getState();
        switchValue = state ? OnOffValue.ON : OnOffValue.OFF;
        setSwitchState(switchValue);
    } 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 3 with NotConnectedException

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

the class MBrickletPTCImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    tinkerforgeDevice = new BrickletPTC(getUid(), getIpConnection());
    // default BrickletPTC.WIRE_MODE_2;
    Short wireMode = null;
    Short noiseRejectionFilter = null;
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("wireMode"))) {
            Short wireModeFromConfig = tfConfig.getWireMode();
            if (wireModeFromConfig != 2 || wireModeFromConfig != 3 || wireModeFromConfig != 4) {
                logger.error("wireMode must be 2, 3 or 4. \"{}\" is configured. Falling back to default", wireModeFromConfig);
            } else {
                wireMode = wireModeFromConfig;
            }
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("noiseRejectionFilter"))) {
            Short noiseRejectionFilterFromConfig = tfConfig.getNoiseRejectionFilter();
            if (noiseRejectionFilterFromConfig != 0 || noiseRejectionFilterFromConfig != 1) {
                logger.error("noiseRejectionFilter must be 0 or 1. \"{}\" is configured. Fallback is using no reduction filter.");
            } else {
                noiseRejectionFilter = noiseRejectionFilterFromConfig;
            }
        }
    }
    try {
        if (wireMode != null) {
            tinkerforgeDevice.setWireMode(wireMode);
        }
        if (noiseRejectionFilter != null) {
            tinkerforgeDevice.setNoiseRejectionFilter(noiseRejectionFilter);
        }
    } 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) BrickletPTC(com.tinkerforge.BrickletPTC) MBrickletPTC(org.openhab.binding.tinkerforge.internal.model.MBrickletPTC) TimeoutException(com.tinkerforge.TimeoutException)

Example 4 with NotConnectedException

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

the class MBrickletMultiTouchImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("sensitivity"))) {
            setSensitivity(tfConfig.getSensitivity());
            logger.debug("{} MultiTouchDevice uid {} setSensitivity {}", LoggerConstants.TFINIT, getUid(), getSensitivity());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("recalibrate"))) {
            setRecalibrate(tfConfig.getRecalibrate());
            logger.debug("{} MultiTouchDevice uid {} setRecalibrate {}", LoggerConstants.TFINIT, getUid(), getRecalibrate());
        }
    }
    tinkerforgeDevice = new BrickletMultiTouch(getUid(), getIpConnection());
    try {
        if (getSensitivity() != null) {
            tinkerforgeDevice.setElectrodeSensitivity(getSensitivity());
        }
        if (getRecalibrate() != null && getRecalibrate()) {
            tinkerforgeDevice.recalibrate();
        }
        // enable all electrodes by default
        tinkerforgeDevice.setElectrodeConfig(8191);
    } 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 : MBrickletMultiTouch(org.openhab.binding.tinkerforge.internal.model.MBrickletMultiTouch) BrickletMultiTouch(com.tinkerforge.BrickletMultiTouch) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 5 with NotConnectedException

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

the class MBrickletOLE64x48Impl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("contrast"))) {
            Short contrast = tfConfig.getContrast();
            logger.debug("contrast {}", contrast);
            setContrast(contrast);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("invert"))) {
            boolean invert = tfConfig.isInvert();
            logger.debug("invert {}", invert);
            setInvert(invert);
        }
    }
    try {
        tinkerforgeDevice = new BrickletOLED64x48(getUid(), getIpConnection());
        tinkerforgeDevice.setDisplayConfiguration(getContrast(), isInvert());
    } 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 : BrickletOLED64x48(com.tinkerforge.BrickletOLED64x48) 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