Search in sources :

Example 1 with BrickletMultiTouch

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

the class MBrickletMultiTouchImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("sensitivity"))) {
            setSensitivity(tfConfig.getSensitivity());
            logger.debug("{} MultiTouchDevice uid {} setSensitivity {}", LoggerConstants.TFINIT, getUid(), getSensitivity());
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("recalibrate"))) {
            setRecalibrate(tfConfig.getRecalibrate());
            logger.debug("{} MultiTouchDevice uid {} setRecalibrate {}", LoggerConstants.TFINIT, getUid(), getRecalibrate());
        }
    }
    tinkerforgeDevice = new BrickletMultiTouch(getUid(), getIpConnection());
    try {
        if (getSensitivity() != null) {
            tinkerforgeDevice.setElectrodeSensitivity(getSensitivity());
        }
        if (getRecalibrate() != null && getRecalibrate()) {
            tinkerforgeDevice.recalibrate();
        }
        // enable all electrodes by default
        tinkerforgeDevice.setElectrodeConfig(8191);
    } 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 : MBrickletMultiTouch(org.openhab.binding.tinkerforge.internal.model.MBrickletMultiTouch) BrickletMultiTouch(com.tinkerforge.BrickletMultiTouch) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Example 2 with BrickletMultiTouch

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

the class MBrickletMultiTouchImpl method setTinkerforgeDevice.

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

Example 3 with BrickletMultiTouch

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

the class MultiTouchDeviceImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("disableElectrode"))) {
            if (tfConfig.getDisableElectrode()) {
                logger.debug("{} MultiTouchDevice uid {} subid {} disable electrode {}", LoggerConstants.TFINIT, getUid(), getSubId(), getPin());
                setDisableElectrode(true);
            }
        }
    }
    MBrickletMultiTouch bricklet = getMbrick();
    if (bricklet == null) {
        logger.error("{} No bricklet found for MultiTouchDevice: {}:{} ", LoggerConstants.TFINIT, getUid(), subId);
    } else {
        try {
            BrickletMultiTouch brickletMultiTouch = bricklet.getTinkerforgeDevice();
            if (getDisableElectrode() != null && getDisableElectrode()) {
                logger.debug("{} MultiTouchDevice uid {} subid {} disabling electrode {}", LoggerConstants.TFINIT, getUid(), getSubId(), getPin());
                getEnabledA().set(false);
                int electrodeConfig = brickletMultiTouch.getElectrodeConfig();
                electrodeConfig &= ~mask;
                brickletMultiTouch.setElectrodeConfig(electrodeConfig);
                return;
            }
            setSensorValue(HighLowValue.UNDEF);
            touchListener = new TouchListener();
            brickletMultiTouch.addTouchStateListener(touchListener);
            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 : MBrickletMultiTouch(org.openhab.binding.tinkerforge.internal.model.MBrickletMultiTouch) BrickletMultiTouch(com.tinkerforge.BrickletMultiTouch) NotConnectedException(com.tinkerforge.NotConnectedException) MBrickletMultiTouch(org.openhab.binding.tinkerforge.internal.model.MBrickletMultiTouch) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

BrickletMultiTouch (com.tinkerforge.BrickletMultiTouch)3 MBrickletMultiTouch (org.openhab.binding.tinkerforge.internal.model.MBrickletMultiTouch)3 NotConnectedException (com.tinkerforge.NotConnectedException)2 TimeoutException (com.tinkerforge.TimeoutException)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1