Search in sources :

Example 1 with BrickletLaserRangeFinder

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

the class MBrickletLaserRangeFinderImpl method setTinkerforgeDevice.

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

Example 2 with BrickletLaserRangeFinder

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

the class MBrickletLaserRangeFinderImpl method enable.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void enable() {
    if (tfConfig != null) {
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("distanceAverageLength"))) {
            Short distanceAverageLength = tfConfig.getDistanceAverageLength();
            logger.debug("distanceAverageLength {}", distanceAverageLength);
            setDistanceAverageLength(distanceAverageLength);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("velocityAverageLength"))) {
            Short velocityAverageLength = tfConfig.getVelocityAverageLength();
            logger.debug("velocityAverageLength {}", velocityAverageLength);
            setVelocityAverageLength(velocityAverageLength);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("mode"))) {
            Short mode = tfConfig.getMode();
            logger.debug("mode {}", mode);
            setMode(mode);
        }
        if (tfConfig.eIsSet(tfConfig.eClass().getEStructuralFeature("enableLaserOnStartup"))) {
            boolean enableLaser = tfConfig.getEnableLaserOnStartup();
            logger.debug("enable laser on startup {}", enableLaser);
            setEnableLaserOnStartup(enableLaser);
        } else {
            boolean enableLaser = tfConfig.getEnableLaserOnStartup();
            logger.debug("enable laser on startup {}", enableLaser);
        }
    }
    try {
        tinkerforgeDevice = new BrickletLaserRangeFinder(getUid(), getIpConnection());
        tinkerforgeDevice.setMode(getMode());
        tinkerforgeDevice.setMovingAverage(getDistanceAverageLength(), getVelocityAverageLength());
        if (getEnableLaserOnStartup()) {
            logger.debug("enabling laser");
            tinkerforgeDevice.enableLaser();
        }
    } 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 : MBrickletLaserRangeFinder(org.openhab.binding.tinkerforge.internal.model.MBrickletLaserRangeFinder) BrickletLaserRangeFinder(com.tinkerforge.BrickletLaserRangeFinder) NotConnectedException(com.tinkerforge.NotConnectedException) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

BrickletLaserRangeFinder (com.tinkerforge.BrickletLaserRangeFinder)2 MBrickletLaserRangeFinder (org.openhab.binding.tinkerforge.internal.model.MBrickletLaserRangeFinder)2 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1