Search in sources :

Example 1 with BrickletIO4

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

the class MBrickletIO4Impl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("debouncePeriod"))) {
            setDebouncePeriod(tfConfig.getDebouncePeriod());
        }
    }
    try {
        tinkerforgeDevice = new BrickletIO4(getUid(), getIpConnection());
        logger.debug("{} BrickletIO4 setting debouncePeriod to {}", LoggerConstants.TFINIT, getDebouncePeriod());
        tinkerforgeDevice.setDebouncePeriod(getDebouncePeriod());
        tinkerforgeDevice.setInterrupt((short) 15);
    } 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) BrickletIO4(com.tinkerforge.BrickletIO4) MBrickletIO4(org.openhab.binding.tinkerforge.internal.model.MBrickletIO4) TimeoutException(com.tinkerforge.TimeoutException)

Example 2 with BrickletIO4

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

the class DigitalSensorIO4Impl method enable.

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

Example 3 with BrickletIO4

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

the class MBrickletIO4Impl method setTinkerforgeDevice.

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

Aggregations

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