Search in sources :

Example 1 with MBrickletMultiTouch

use of org.openhab.binding.tinkerforge.internal.model.MBrickletMultiTouch 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)1 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 MBrickletMultiTouch (org.openhab.binding.tinkerforge.internal.model.MBrickletMultiTouch)1