Search in sources :

Example 1 with BrickletDistanceUS

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

the class MBrickletDistanceUSImpl method setTinkerforgeDevice.

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

Example 2 with BrickletDistanceUS

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

the class MBrickletDistanceUSImpl 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("movingAverage"))) {
            logger.debug("{} setting movingAverage: {}", LoggerConstants.TFINIT, tfConfig.getMovingAverage());
            setMovingAverage(tfConfig.getMovingAverage());
        }
    }
    try {
        tinkerforgeDevice = new BrickletDistanceUS(getUid(), getIpConnection());
        tinkerforgeDevice.setMovingAverage(getMovingAverage());
        tinkerforgeDevice.setDistanceCallbackPeriod(getCallbackPeriod());
        listener = new DistanceListener();
        tinkerforgeDevice.addDistanceListener(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) MBrickletDistanceUS(org.openhab.binding.tinkerforge.internal.model.MBrickletDistanceUS) BrickletDistanceUS(com.tinkerforge.BrickletDistanceUS) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

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