当前位置: 首页>>代码示例>>Java>>正文


Java PercentType.doubleValue方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:16,代码来源:TellstickController.java

示例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();
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:16,代码来源:PercentTypeConverter.java

示例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);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:10,代码来源:FS20CommandHelper.java


注:本文中的org.openhab.core.library.types.PercentType.doubleValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。