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


Java OnOffType.valueOf方法代码示例

本文整理汇总了Java中org.openhab.core.library.types.OnOffType.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java OnOffType.valueOf方法的具体用法?Java OnOffType.valueOf怎么用?Java OnOffType.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openhab.core.library.types.OnOffType的用法示例。


在下文中一共展示了OnOffType.valueOf方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
 * Returns a {@link State} which is inherited from the {@link Item}s
 * accepted DataTypes. The call is delegated to the  {@link TypeParser}. If
 * <code>item</code> is <code>null</code> the {@link StringType} is used.
 *  
 * @param itemType
 * @param transformedResponse
 * 
 * @return a {@link State} which type is inherited by the {@link TypeParser}
 * or a {@link StringType} if <code>item</code> is <code>null</code> 
 */
private State createState(Class<? extends Item> itemType, String transformedResponse) {
	try {
		if (itemType.isAssignableFrom(NumberItem.class)) {
			return DecimalType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(ContactItem.class)) {
			return OpenClosedType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(SwitchItem.class)) {
			return OnOffType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
			return PercentType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(DateTimeItem.class)) {
			return DateTimeType.valueOf(transformedResponse);
		} else {
			return StringType.valueOf(transformedResponse);
		}
	} catch (Exception e) {
		logger.debug("Couldn't create state of type '{}' for value '{}'", itemType, transformedResponse);
		return StringType.valueOf(transformedResponse);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:32,代码来源:HttpBinding.java

示例2: createState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
private State createState(Class<? extends Item> itemType,
		String transformedResponse) {
	try {
		if (itemType.isAssignableFrom(NumberItem.class)) {
			return DecimalType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(SwitchItem.class)) {
			return OnOffType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(DimmerItem.class)) {
			return PercentType.valueOf(transformedResponse);
		} else {
			return StringType.valueOf(transformedResponse);
		}
	} catch (Exception e) {
		logger.debug("Couldn't create state of type '{}' for value '{}'",
				itemType, transformedResponse);
		return StringType.valueOf(transformedResponse);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:19,代码来源:Enigma2Binding.java

示例3: getOHState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
/**
 * Returns a type used by openHAB to show the actual state of the souliss' typical
 * @return org.openhab.core.types.State
 */
public State getOHState() {
	String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
			this.getType(), (short) this.getState());
	if (sOHState != null) {
		if (this.getNote().equals("ContactItem"))
			return OpenClosedType.valueOf(sOHState);
		else
			return OnOffType.valueOf(sOHState);
	}
	return null;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:17,代码来源:SoulissT11.java

示例4: createState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
 * Returns a {@link State} which is inherited from the {@link Item}s
 * accepted DataTypes. The call is delegated to the {@link TypeParser}. If
 * <code>item</code> is <code>null</code> the {@link StringType} is used.
 * 
 * @param itemType
 * @param transformedResponse
 * 
 * @return a {@link State} which type is inherited by the {@link TypeParser}
 *         or a {@link StringType} if <code>item</code> is <code>null</code>
 */
private State createState(Class<? extends Item> itemType,
		String transformedResponse) {
	try {
		if (itemType.isAssignableFrom(NumberItem.class)) {
			return DecimalType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(ContactItem.class)) {
			return OpenClosedType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(SwitchItem.class)) {
			return OnOffType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
			return PercentType.valueOf(transformedResponse);
		} else {
			return StringType.valueOf(transformedResponse);
		}
	} catch (Exception e) {
		logger.debug("Couldn't create state of type '{}' for value '{}'",
				itemType, transformedResponse);
		return StringType.valueOf(transformedResponse);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:32,代码来源:OWServerBinding.java

示例5: createState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
 * Returns a {@link State} which is inherited from the {@link Item}s
 * accepted DataTypes. The call is delegated to the  {@link TypeParser}. If
 * <code>item</code> is <code>null</code> the {@link StringType} is used.
 *  
 * @param itemType
 * @param transformedResponse
 * 
 * @return a {@link State} which type is inherited by the {@link TypeParser}
 * or a {@link StringType} if <code>item</code> is <code>null</code> 
 */
private State createState(Class<? extends Item> itemType, String transformedResponse) {
	try {
		if (itemType.isAssignableFrom(NumberItem.class)) {
			return DecimalType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(ContactItem.class)) {
			return OpenClosedType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(SwitchItem.class)) {
			return OnOffType.valueOf(transformedResponse);
		} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
			return PercentType.valueOf(transformedResponse);
		} else {
			return StringType.valueOf(transformedResponse);
		}
	} catch (Exception e) {
		logger.debug("Couldn't create state of type '{}' for value '{}'", itemType, transformedResponse);
		return StringType.valueOf(transformedResponse);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:30,代码来源:ExecBinding.java

示例6: getOHState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
public State getOHState() {
	String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
			this.getType(), (short) this.getState());
	if (sOHState != null) {
		if (this.getNote().equals("ContactItem"))
			return OpenClosedType.valueOf(sOHState);
		else
			return OnOffType.valueOf(sOHState);
	}
	return null;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:13,代码来源:SoulissT13.java

示例7: getOHState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
/**
 * Returns a type used in openHAB to show the actual state of the souliss' typical
 * @return org.openhab.core.types.State
 */
public State getOHState() {
	String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
			this.getType(), (short) this.getState());
	if (sOHState != null) {
		return OnOffType.valueOf(sOHState);
	} else {
		return new PercentType(
				String.valueOf((this.getState() / 250) * 100));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:16,代码来源:SoulissT19.java

示例8: getOHState

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
public State getOHState() {
	String sOHState = StateTraslator.statesSoulissToOH(this.getNote(),
			this.getType(), (short) this.getState(iBit));
	if (sOHState != null) {
		if (this.getNote().equals("ContactItem"))
			return OpenClosedType.valueOf(sOHState);
		else
			return OnOffType.valueOf(sOHState);
	}
	return null;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:13,代码来源:SoulissT1A.java

示例9: convertToImpl

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
protected OnOffType convertToImpl(OnOffState source) {
    return OnOffType.valueOf(source.name());
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:5,代码来源:OnOffStateConverter.java

示例10: dispatchPdu

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
private void dispatchPdu(Address address, PDU pdu) {
	if (pdu != null & address != null) {
		logger.debug("Received PDU from '{}' '{}'", address, pdu);
		for (SnmpBindingProvider provider : providers) {
			for (String itemName : provider.getItemNames()) {
				// Check the IP address
				if (!provider.getAddress(itemName).equals(address)) {
					continue;
				}

				// Check the OID
				OID oid = provider.getOID(itemName);
				Variable variable = pdu.getVariable(oid);
				if (variable != null) {
					Class<? extends Item> itemType = provider.getItemType(itemName);

					// Do any transformations
					String value = variable.toString();
					try {
						value = provider.doTransformation(itemName, value);
					} catch (TransformationException e) {
						logger.error("Transformation error with item {}: {}", itemName, e);
					}

					// Change to a state
					State state = null;
					if (itemType.isAssignableFrom(StringItem.class)) {
						state = StringType.valueOf(value);
					} else if (itemType.isAssignableFrom(NumberItem.class)) {
						state = DecimalType.valueOf(value);
					} else if (itemType.isAssignableFrom(SwitchItem.class)) {
						state = OnOffType.valueOf(value);
					}

					if (state != null) {
						eventPublisher.postUpdate(itemName, state);
					} else {
						logger.debug(
								"'{}' couldn't be parsed to a State. Valid State-Types are String and Number",
								variable.toString());
					}
				} else {
					logger.trace("PDU doesn't contain a variable with OID ‘{}‘", oid.toString());
				}
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:49,代码来源:SnmpBinding.java

示例11: getOpenhabStateFromZibaseValue

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
/**
 * {@link Inherited}
 */
@Override
public State getOpenhabStateFromZibaseValue(Zibase zibase, String zbResponseStr) {
	return OnOffType.valueOf(zibase.getState(this.getId()) ? "ON":"OFF");
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:8,代码来源:ZibaseBindingConfigReceiver.java

示例12: getCommandValue

import org.openhab.core.library.types.OnOffType; //导入方法依赖的package包/类
@Override
public OnOffType getCommandValue() {
    return OnOffType.valueOf(data.name());
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:5,代码来源:OpenhabOnOffData.java


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