Search in sources :

Example 1 with BrickletIndustrialDual020mA

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

the class MBrickletIndustrialDual020mAImpl method setTinkerforgeDevice.

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

Example 2 with BrickletIndustrialDual020mA

use of com.tinkerforge.BrickletIndustrialDual020mA 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)

Aggregations

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