Search in sources :

Example 26 with TimeoutException

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

the class MBrickletIndustrialDualAnalogInImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("sampleRate"))) {
            Short sampleRate = tfConfig.getSampleRate();
            logger.debug("sampleRate {}", sampleRate);
            setSampleRate(sampleRate);
        }
    }
    try {
        tinkerforgeDevice = new BrickletIndustrialDualAnalogIn(getUid(), getIpConnection());
        tinkerforgeDevice.setSampleRate(getSampleRate());
    } 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) MBrickletIndustrialDualAnalogIn(org.openhab.binding.tinkerforge.internal.model.MBrickletIndustrialDualAnalogIn) BrickletIndustrialDualAnalogIn(com.tinkerforge.BrickletIndustrialDualAnalogIn) TimeoutException(com.tinkerforge.TimeoutException)

Example 27 with TimeoutException

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

the class MBrickletTiltImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        DecimalValue value = convert(tinkerforgeDevice.getTiltState());
        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 28 with TimeoutException

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

the class MBrickletTemperatureImpl 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());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("slowI2C"))) {
            setSlowI2C(true);
        }
    }
    try {
        tinkerforgeDevice = new BrickletTemperature(uid, getIpConnection());
        if (isSlowI2C()) {
            logger.debug("setting I2C slow mode");
            tinkerforgeDevice.setI2CMode(BrickletTemperature.I2C_MODE_SLOW);
        } else {
            logger.debug("working with I2C fast mode");
        }
        tinkerforgeDevice.setResponseExpected(BrickletTemperature.FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD, false);
        tinkerforgeDevice.setTemperatureCallbackPeriod(callbackPeriod);
        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) MBrickletTemperature(org.openhab.binding.tinkerforge.internal.model.MBrickletTemperature) BrickletTemperature(com.tinkerforge.BrickletTemperature) TimeoutException(com.tinkerforge.TimeoutException)

Example 29 with TimeoutException

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

the class MServoImpl method setPoint.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public boolean setPoint(Short newPosition, int newVelocity, int newAccelleration) {
    Short max = getMaxPosition();
    Short min = getMinPosition();
    if (newPosition > max) {
        if (this.targetPosition < newPosition) {
            logger.debug("setting value to max speed {}, which is lower than target speed {}", max, newPosition);
            newPosition = max;
        } else {
            logger.debug("max value already reached {}", max);
            return true;
        }
    } else if (newPosition < min) {
        if (this.targetPosition > newPosition) {
            logger.debug("setting velocity to min speed {}, which is higher than target speed {}", min, newPosition);
            newPosition = min;
        } else {
            logger.debug("min value already reached {}", min);
            return true;
        }
    }
    try {
        BrickServo tinkerBrickServo = getMbrick().getTinkerforgeDevice();
        tinkerBrickServo.setVelocity(servoNum, newVelocity);
        tinkerBrickServo.setAcceleration(servoNum, newAccelleration);
        tinkerBrickServo.setPosition(servoNum, newPosition);
        setTargetPosition(newPosition);
        return true;
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
    return false;
}
Also used : NotConnectedException(com.tinkerforge.NotConnectedException) MBrickServo(org.openhab.binding.tinkerforge.internal.model.MBrickServo) BrickServo(com.tinkerforge.BrickServo) TimeoutException(com.tinkerforge.TimeoutException)

Example 30 with TimeoutException

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

the class MServoImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    try {
        short position = getMbrick().getTinkerforgeDevice().getPosition(servoNum);
        DecimalValue newValue = Tools.calculate(position);
        setSensorValue(newValue);
        OnOffValue newSwitchState = newValue.onOffValue(0);
        logger.trace("new switchstate {} new value {}", newSwitchState, newValue);
        setSwitchState(newSwitchState);
    } 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) 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