Search in sources :

Example 1 with MBrickletIO16

use of org.openhab.binding.tinkerforge.internal.model.MBrickletIO16 in project openhab1-addons by openhab.

the class DigitalSensorImpl method enable.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    setSensorValue(HighLowValue.UNDEF);
    if (tfConfig != null) {
        logger.debug("{} found config for DigitalSensor", LoggerConstants.TFINIT);
        setPullUpResistorEnabled(tfConfig.isPullUpResistorEnabled());
        logger.debug("{} pull-up resistor state is {}", LoggerConstants.TFINIT, isPullUpResistorEnabled());
    }
    MBrickletIO16 bricklet = getMbrick();
    if (bricklet == null) {
        logger.error("{} No bricklet found for DigitalSensor: {} ", LoggerConstants.TFINIT, subId);
    } else {
        BrickletIO16 brickletIO16 = bricklet.getTinkerforgeDevice();
        try {
            logger.debug("{} setting InterruptListener for DigitalSensor: {} ", LoggerConstants.TFINIT, subId);
            interruptListener = new InterruptListener();
            brickletIO16.addInterruptListener(interruptListener);
            brickletIO16.setPortConfiguration(getPort(), (short) mask, BrickletIO16.DIRECTION_IN, isPullUpResistorEnabled());
            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 : MBrickletIO16(org.openhab.binding.tinkerforge.internal.model.MBrickletIO16) MBrickletIO16(org.openhab.binding.tinkerforge.internal.model.MBrickletIO16) BrickletIO16(com.tinkerforge.BrickletIO16) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

BrickletIO16 (com.tinkerforge.BrickletIO16)1 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 MBrickletIO16 (org.openhab.binding.tinkerforge.internal.model.MBrickletIO16)1