Search in sources :

Example 1 with BrickletPTC

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

the class MBrickletPTCImpl method setTinkerforgeDevice.

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

Example 2 with BrickletPTC

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

the class MBrickletPTCImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    tinkerforgeDevice = new BrickletPTC(getUid(), getIpConnection());
    // default BrickletPTC.WIRE_MODE_2;
    Short wireMode = null;
    Short noiseRejectionFilter = null;
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("wireMode"))) {
            Short wireModeFromConfig = tfConfig.getWireMode();
            if (wireModeFromConfig != 2 || wireModeFromConfig != 3 || wireModeFromConfig != 4) {
                logger.error("wireMode must be 2, 3 or 4. \"{}\" is configured. Falling back to default", wireModeFromConfig);
            } else {
                wireMode = wireModeFromConfig;
            }
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("noiseRejectionFilter"))) {
            Short noiseRejectionFilterFromConfig = tfConfig.getNoiseRejectionFilter();
            if (noiseRejectionFilterFromConfig != 0 || noiseRejectionFilterFromConfig != 1) {
                logger.error("noiseRejectionFilter must be 0 or 1. \"{}\" is configured. Fallback is using no reduction filter.");
            } else {
                noiseRejectionFilter = noiseRejectionFilterFromConfig;
            }
        }
    }
    try {
        if (wireMode != null) {
            tinkerforgeDevice.setWireMode(wireMode);
        }
        if (noiseRejectionFilter != null) {
            tinkerforgeDevice.setNoiseRejectionFilter(noiseRejectionFilter);
        }
    } 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) BrickletPTC(com.tinkerforge.BrickletPTC) MBrickletPTC(org.openhab.binding.tinkerforge.internal.model.MBrickletPTC) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

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