本文整理汇总了Java中org.openhab.core.library.types.PercentType.doubleValue方法的典型用法代码示例。如果您正苦于以下问题:Java PercentType.doubleValue方法的具体用法?Java PercentType.doubleValue怎么用?Java PercentType.doubleValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openhab.core.library.types.PercentType
的用法示例。
在下文中一共展示了PercentType.doubleValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dim
import org.openhab.core.library.types.PercentType; //导入方法依赖的package包/类
private void dim(TellstickDevice dev, PercentType command) throws TellstickException {
double value = command.doubleValue();
// 0 means OFF and 100 means ON
if(value == 0 && dev instanceof DeviceIntf) {
((DeviceIntf) dev).off();
} else if(value == 100 && dev instanceof DeviceIntf) {
((DeviceIntf) dev).on();
} else if (dev instanceof DimmableDeviceIntf) {
long tdVal = Math.round((value / 100) * 255);
((DimmableDeviceIntf) dev).dim((int) tdVal);
} else {
throw new RuntimeException("Cannot send DIM to " + dev);
}
}
示例2: toNumber
import org.openhab.core.library.types.PercentType; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected Number toNumber(PercentType type, HmValueItem hmValueItem) {
Double number = (type.doubleValue() / 100) * hmValueItem.getMaxValue().doubleValue();
if (isRollerShutterLevelDatapoint(hmValueItem)) {
number = hmValueItem.getMaxValue().doubleValue() - number;
}
if (hmValueItem.isIntegerValue()) {
return number.intValue();
}
return round(number).doubleValue();
}
示例3: convertPercentType
import org.openhab.core.library.types.PercentType; //导入方法依赖的package包/类
private static FS20Command convertPercentType(PercentType percentType) {
double percentValue = percentType.doubleValue();
int step = (int) (percentValue / 6.25);
String hexValue = Integer.toHexString(step);
if (hexValue.length() == 1) {
hexValue = "0" + hexValue;
}
return FS20Command.getFromHexValue(hexValue);
}