Search in sources :

Example 1 with BrickletIO16

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

the class MBrickletIO16Impl method setTinkerforgeDevice.

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

Example 2 with BrickletIO16

use of com.tinkerforge.BrickletIO16 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)

Example 3 with BrickletIO16

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

the class MBrickletIO16Impl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    tinkerforgeDevice = new BrickletIO16(getUid(), getIpConnection());
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("debouncePeriod"))) {
            setDebouncePeriod(tfConfig.getDebouncePeriod());
        }
    }
    // enable interrupts for all pins
    try {
        tinkerforgeDevice.setResponseExpectedAll(true);
        logger.debug("{} BrickletIO16 setting debouncePeriod to {}", LoggerConstants.TFINIT, getDebouncePeriod());
        tinkerforgeDevice.setDebouncePeriod(getDebouncePeriod());
        tinkerforgeDevice.setPortInterrupt('a', (short) 255);
        tinkerforgeDevice.setPortInterrupt('b', (short) 255);
    } 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) BrickletIO16(com.tinkerforge.BrickletIO16) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

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