Search in sources :

Example 66 with TimeoutException

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

the class MBrickletIndustrialDual020mAImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    tinkerforgeDevice = new BrickletIndustrialDual020mA(getUid(), getIpConnection());
    Short sampleRate = null;
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("sampleRate"))) {
            Short sampleRateFromConfig = tfConfig.getSampleRate();
            if (sampleRateFromConfig != 0 || sampleRateFromConfig != 1 || sampleRateFromConfig != 2 || sampleRateFromConfig != 3) {
                logger.error("sampleRate must be 0, 1, 2, or 3. \"{}\" is configured. Falling back to default", sampleRateFromConfig);
            } else {
                sampleRate = sampleRateFromConfig;
            }
        }
    }
    if (sampleRate != null) {
        try {
            tinkerforgeDevice.setSampleRate(sampleRate);
        } 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) BrickletIndustrialDual020mA(com.tinkerforge.BrickletIndustrialDual020mA) MBrickletIndustrialDual020mA(org.openhab.binding.tinkerforge.internal.model.MBrickletIndustrialDual020mA) TimeoutException(com.tinkerforge.TimeoutException)

Example 67 with TimeoutException

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

the class MLCD20x4BacklightImpl method fetchSwitchState.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSwitchState() {
    OnOffValue switchValue = OnOffValue.UNDEF;
    try {
        switchValue = brickletLCD20x4.isBacklightOn() ? 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);
    }
    setSwitchState(switchValue);
}
Also used : OnOffValue(org.openhab.binding.tinkerforge.internal.types.OnOffValue) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 68 with TimeoutException

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

the class MDualRelayImpl method fetchSwitchState.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSwitchState() {
    OnOffValue switchValue = OnOffValue.UNDEF;
    try {
        State state = getMbrick().getTinkerforgeDevice().getState();
        if (relayNum == 1) {
            switchValue = (state.relay1) ? OnOffValue.ON : OnOffValue.OFF;
        } else {
            switchValue = (state.relay2) ? 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);
    }
    setSwitchState(switchValue);
}
Also used : OnOffValue(org.openhab.binding.tinkerforge.internal.types.OnOffValue) NotConnectedException(com.tinkerforge.NotConnectedException) State(com.tinkerforge.BrickletDualRelay.State) TimeoutException(com.tinkerforge.TimeoutException)

Example 69 with TimeoutException

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

the class MBrickletVoltageCurrentImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("averaging"))) {
            setAveraging(tfConfig.getAveraging());
            logger.debug("{} VoltageCurrent uid {} averaging {}", LoggerConstants.TFINIT, getUid(), getAveraging());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("voltageConversionTime"))) {
            setVoltageConversionTime(tfConfig.getVoltageConversionTime());
            logger.debug("{} VoltageCurrent uid {} voltageConversionTime {}", LoggerConstants.TFINIT, getUid(), getVoltageConversionTime());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("currentConversionTime"))) {
            setVoltageConversionTime(tfConfig.getCurrentConversionTime());
            logger.debug("{} VoltageCurrent uid {} currentConversionTime {}", LoggerConstants.TFINIT, getUid(), getCurrentConversionTime());
        }
    }
    tinkerforgeDevice = new BrickletVoltageCurrent(getUid(), getIpConnection());
    try {
        tinkerforgeDevice.setConfiguration(getAveraging(), getVoltageConversionTime(), getCurrentConversionTime());
    } 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) BrickletVoltageCurrent(com.tinkerforge.BrickletVoltageCurrent) MBrickletVoltageCurrent(org.openhab.binding.tinkerforge.internal.model.MBrickletVoltageCurrent) TimeoutException(com.tinkerforge.TimeoutException)

Example 70 with TimeoutException

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

the class MServoImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void enable() {
    MBrickServo brick = getMbrick();
    if (brick == null) {
        logger.error("No servo brick configured for servo: " + uid);
    } else {
        if (tfConfig != null) {
            logger.debug("found tfConfig");
            if (tfConfig.getVelocity() != 0) {
                // TODO check for
                setVelocity(tfConfig.getVelocity());
            }
            // state
            if (tfConfig.getAcceleration() != 0) {
                setAcceleration(tfConfig.getAcceleration());
            }
            if (tfConfig.getPeriod() != 0) {
                setPeriod(tfConfig.getPeriod());
            }
            if (tfConfig.getPulseWidthMax() != 0 && tfConfig.getPulseWidthMin() != 0) {
                setPulseWidthMax(tfConfig.getPulseWidthMax());
                setPulseWidthMin(tfConfig.getPulseWidthMin());
            }
            if (tfConfig.getOutputVoltage() != 0) {
                setOutputVoltage(tfConfig.getOutputVoltage());
            }
        }
        BrickServo tinkerBrickServo = brick.getTinkerforgeDevice();
        try {
            servoNum = Short.parseShort(String.valueOf(subId.charAt(subId.length() - 1)));
            // tinkerBrickServo.setVelocity(servoNum, velocity);
            // tinkerBrickServo.setAcceleration(servoNum, acceleration);
            tinkerBrickServo.setPulseWidth(servoNum, pulseWidthMin, pulseWidthMax);
            tinkerBrickServo.setPeriod(servoNum, period);
            tinkerBrickServo.setOutputVoltage(outputVoltage);
            // initialize target postion with
            setTargetPosition(tinkerBrickServo.getPosition(servoNum));
            // current position value
            listener = new PositionReachedListener();
            tinkerBrickServo.addPositionReachedListener(listener);
            tinkerBrickServo.enablePositionReachedCallback();
            tinkerBrickServo.enable(servoNum);
            fetchSwitchState();
        } catch (NumberFormatException e) {
            TinkerforgeErrorHandler.handleError(this, "can not determine servoNum", e);
        } 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) MBrickServo(org.openhab.binding.tinkerforge.internal.model.MBrickServo) MBrickServo(org.openhab.binding.tinkerforge.internal.model.MBrickServo) BrickServo(com.tinkerforge.BrickServo) 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