Search in sources :

Example 1 with BrickletColor

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

the class MBrickletColorImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("gain"))) {
            Short gainConfig = tfConfig.getGain();
            switch(gainConfig) {
                case 0:
                    this.gain = 0;
                    break;
                case 1:
                    this.gain = 1;
                    break;
                case 2:
                    this.gain = 2;
                    break;
                default:
                    logger.error("invalid gain value {}; using default gain", gainConfig);
                    break;
            }
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("integrationTime"))) {
            Short integrationTimeConfig = tfConfig.getIntegrationTime();
            switch(integrationTimeConfig) {
                case 0:
                    this.integrationTime = 0;
                    break;
                case 1:
                    this.integrationTime = 1;
                    break;
                case 2:
                    this.integrationTime = 2;
                    break;
                case 3:
                    this.integrationTime = 3;
                    break;
                case 4:
                    this.integrationTime = 4;
                    break;
                default:
                    logger.error("invalid integrationTime value {}; using default integrationTime", integrationTimeConfig);
                    break;
            }
        }
    }
    try {
        tinkerforgeDevice = new BrickletColor(getUid(), getIpConnection());
        tinkerforgeDevice.setConfig(gain, integrationTime);
    } 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) MBrickletColor(org.openhab.binding.tinkerforge.internal.model.MBrickletColor) BrickletColor(com.tinkerforge.BrickletColor) TimeoutException(com.tinkerforge.TimeoutException)

Example 2 with BrickletColor

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

the class MBrickletColorImpl method setTinkerforgeDevice.

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

Aggregations

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