Search in sources :

Example 1 with PercentValue

use of org.openhab.binding.tinkerforge.internal.types.PercentValue in project openhab1-addons by openhab.

the class RemoteSwitchBImpl method setPercentValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated
     */
@Override
public void setPercentValue(PercentValue newPercentValue) {
    PercentValue oldPercentValue = percentValue;
    percentValue = newPercentValue;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.REMOTE_SWITCH_B__PERCENT_VALUE, oldPercentValue, percentValue));
}
Also used : PercentValue(org.openhab.binding.tinkerforge.internal.types.PercentValue) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 2 with PercentValue

use of org.openhab.binding.tinkerforge.internal.types.PercentValue in project openhab1-addons by openhab.

the class RemoteSwitchBImpl method setSensorValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated
     */
@Override
public void setSensorValue(PercentValue newSensorValue) {
    PercentValue oldSensorValue = sensorValue;
    sensorValue = newSensorValue;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.REMOTE_SWITCH_B__SENSOR_VALUE, oldSensorValue, sensorValue));
}
Also used : PercentValue(org.openhab.binding.tinkerforge.internal.types.PercentValue) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 3 with PercentValue

use of org.openhab.binding.tinkerforge.internal.types.PercentValue in project openhab1-addons by openhab.

the class MBrickDCImpl method setValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void setValue(PercentType percentValue, DeviceOptions opts) {
    BigDecimal max = Tools.getBigDecimalOpt(ConfigOptsDimmable.MAX.toString(), opts);
    if (max == null) {
        logger.error("BrickDC dimmer option max is missing, items configuration has to be fixed!");
        return;
    } else {
        logger.debug("Brick DC max {}", max);
    }
    BigDecimal min = Tools.getBigDecimalOpt(ConfigOptsDimmable.MIN.toString(), opts);
    logger.debug("Brick DC min {}", min);
    if (min == null) {
        logger.error("BrickDC dimmer option min is missing, items configuration has to be fixed!");
        return;
    }
    setPercentValue(new PercentValue(percentValue.toBigDecimal()));
    BigDecimal abs = max.add(min.abs());
    Short newVelocity = abs.divide(new BigDecimal(100)).multiply(percentValue.toBigDecimal()).subtract(min.abs()).shortValue();
    setPoint(newVelocity, opts);
}
Also used : PercentValue(org.openhab.binding.tinkerforge.internal.types.PercentValue) BigDecimal(java.math.BigDecimal)

Example 4 with PercentValue

use of org.openhab.binding.tinkerforge.internal.types.PercentValue in project openhab1-addons by openhab.

the class MBrickDCImpl method setPercentValue.

/**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * 
     * @generated
     */
@Override
public void setPercentValue(PercentValue newPercentValue) {
    PercentValue oldPercentValue = percentValue;
    percentValue = newPercentValue;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICK_DC__PERCENT_VALUE, oldPercentValue, percentValue));
}
Also used : PercentValue(org.openhab.binding.tinkerforge.internal.types.PercentValue) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 5 with PercentValue

use of org.openhab.binding.tinkerforge.internal.types.PercentValue in project openhab1-addons by openhab.

the class MServoImpl method setValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void setValue(PercentType newPercentValue, DeviceOptions opts) {
    BigDecimal max = Tools.getBigDecimalOpt(ConfigOptsDimmable.MAX.toString(), opts);
    if (max == null) {
        logger.error("dimmer option max is missing, items configuration has to be fixed!");
        return;
    } else {
        logger.debug("max {}", max);
    }
    BigDecimal min = Tools.getBigDecimalOpt(ConfigOptsDimmable.MIN.toString(), opts);
    logger.debug("min {}", min);
    if (min == null) {
        logger.error("dimmer option min is missing, items configuration has to be fixed!");
        return;
    }
    setPercentValue(new PercentValue(newPercentValue.toBigDecimal()));
    // TODO this is only valid if min has a value < 0
    BigDecimal abs = max.add(min.abs());
    Short newVelocity = abs.divide(new BigDecimal(100)).multiply(newPercentValue.toBigDecimal()).subtract(min.abs()).shortValue();
    setPoint(newVelocity, opts);
}
Also used : PercentValue(org.openhab.binding.tinkerforge.internal.types.PercentValue) BigDecimal(java.math.BigDecimal)

Aggregations

PercentValue (org.openhab.binding.tinkerforge.internal.types.PercentValue)9 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 BigDecimal (java.math.BigDecimal)3 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 TinkerforgeBindingProvider (org.openhab.binding.tinkerforge.TinkerforgeBindingProvider)1 DecimalValue (org.openhab.binding.tinkerforge.internal.types.DecimalValue)1 DirectionValue (org.openhab.binding.tinkerforge.internal.types.DirectionValue)1 HSBValue (org.openhab.binding.tinkerforge.internal.types.HSBValue)1 HighLowValue (org.openhab.binding.tinkerforge.internal.types.HighLowValue)1 OnOffValue (org.openhab.binding.tinkerforge.internal.types.OnOffValue)1 ColorItem (org.openhab.core.library.items.ColorItem)1 ContactItem (org.openhab.core.library.items.ContactItem)1 DimmerItem (org.openhab.core.library.items.DimmerItem)1 NumberItem (org.openhab.core.library.items.NumberItem)1 RollershutterItem (org.openhab.core.library.items.RollershutterItem)1 StringItem (org.openhab.core.library.items.StringItem)1 SwitchItem (org.openhab.core.library.items.SwitchItem)1 PercentType (org.openhab.core.library.types.PercentType)1 State (org.openhab.core.types.State)1