Search in sources :

Example 1 with BrickletTemperature

use of com.tinkerforge.BrickletTemperature 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 2 with BrickletTemperature

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

the class MBrickletTemperatureImpl method setTinkerforgeDevice.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated
     */
@Override
public void setTinkerforgeDevice(BrickletTemperature newTinkerforgeDevice) {
    BrickletTemperature oldTinkerforgeDevice = tinkerforgeDevice;
    tinkerforgeDevice = newTinkerforgeDevice;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_TEMPERATURE__TINKERFORGE_DEVICE, oldTinkerforgeDevice, tinkerforgeDevice));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) MBrickletTemperature(org.openhab.binding.tinkerforge.internal.model.MBrickletTemperature) BrickletTemperature(com.tinkerforge.BrickletTemperature)

Aggregations

BrickletTemperature (com.tinkerforge.BrickletTemperature)2 MBrickletTemperature (org.openhab.binding.tinkerforge.internal.model.MBrickletTemperature)2 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1