• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Item类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openhab.core.items.Item的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Item类属于org.openhab.core.items包,在下文中一共展示了Item类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: processBindingConfiguration

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void processBindingConfiguration(String context, Item item,
		String bindingConfig) throws BindingConfigParseException {
	super.processBindingConfiguration(context, item, bindingConfig);
	BenqProjectorBindingConfig config = new BenqProjectorBindingConfig();

	if (bindingConfig.equalsIgnoreCase("power")) {
		config.mode = BenqProjectorItemMode.POWER;
	} else if (bindingConfig.equalsIgnoreCase("mute")) {
		config.mode = BenqProjectorItemMode.MUTE;
	} else if (bindingConfig.equalsIgnoreCase("volume")) {
		config.mode = BenqProjectorItemMode.VOLUME;
	} else if (bindingConfig.equalsIgnoreCase("lamp_hours")) {
		config.mode = BenqProjectorItemMode.LAMP_HOURS;
	} else if (bindingConfig.equalsIgnoreCase("source_number")) {
		config.mode = BenqProjectorItemMode.SOURCE_NUMBER;
	} else if (bindingConfig.equalsIgnoreCase("source_string")) {
		config.mode = BenqProjectorItemMode.SOURCE_STRING;
	} else {
		throw new BindingConfigParseException("Unable to parse '"
				+ bindingConfig + "' to create a valid item binding.");
	}
	logger.debug("Adding " + item.getName() + " as " + config.mode);
	addBindingConfig(item, config);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:29,代码来源:BenqProjectorGenericBindingProvider.java


示例2: updateItemState

import org.openhab.core.items.Item; //导入依赖的package包/类
private void updateItemState(String itemName, int value) {
   	Class<? extends Item> itemType = getItemType(itemName);
   	if (itemType.equals(SwitchItem.class)) {
    	if (value == 0) {
    		eventPublisher.postUpdate(itemName, OnOffType.OFF);
    	} else if (value == 1) {
    		eventPublisher.postUpdate(itemName, OnOffType.ON);
    	}
   	} 
   	
   	if (itemType.equals(ContactItem.class)) {
    	if (value == 0) {
    		eventPublisher.postUpdate(itemName, OpenClosedType.OPEN);
    	} else if (value == 1) {
    		eventPublisher.postUpdate(itemName, OpenClosedType.CLOSED);
    	}
   	}		
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:19,代码来源:PifaceBinding.java


示例3: parseAndAddBindingConfig

import org.openhab.core.items.Item; //导入依赖的package包/类
private void parseAndAddBindingConfig(Item item, String bindingConfig) throws BindingConfigParseException {
	ProtocolBindingConfig newConfig = new ProtocolBindingConfig();
	Matcher matcher = BASE_CONFIG_PATTERN.matcher(bindingConfig);

	if (!matcher.matches()) {
		throw new BindingConfigParseException("bindingConfig '" + bindingConfig + "' doesn't contain a valid binding configuration");
	}
	matcher.reset();

	while (matcher.find()) {
		String bindingConfigPart = matcher.group(1);
		if (StringUtils.isNotBlank(bindingConfigPart)) {
			parseBindingConfig(newConfig,item, bindingConfigPart);
			addBindingConfig(item, newConfig);
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:18,代码来源:ProtocolGenericBindingProvider.java


示例4: processBindingConfiguration

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig)
		throws BindingConfigParseException {
	super.processBindingConfiguration(context, item, bindingConfig);

	try {
		MiosBindingConfig config = parseBindingConfig(context, item, bindingConfig);
		config.validateItemType(item);

		logger.debug("processBindingConfiguration: Adding Item '{}' Binding '{}', from '{}'",
				new Object[] { item.getName(), config, context });
		addBindingConfig(item, config);
	} catch (BindingConfigParseException bcpe) {
		logger.debug(String
				.format("processBindingConfiguration: Exception parsing/validating context '%s', item'%s', bindingConfig '%s'.  Exception is %s.",
						context, item, bindingConfig, bcpe.getMessage()));

		throw bcpe;
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:24,代码来源:MiosBindingProviderImpl.java


示例5: getAllItems

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * Collects all items that are represented by a given list of widgets
 * 
 * @param widgets the widget list to get the items for
 * @return all items that are represented by the list of widgets
 */
private Set<GenericItem> getAllItems(EList<Widget> widgets) {
	Set<GenericItem> items = new HashSet<GenericItem>();
	if(itemRegistry!=null) {
		for(Widget widget : widgets) {
			String itemName = widget.getItem();
			if(itemName!=null) {
				try {
					Item item = itemRegistry.getItem(itemName);
					if (item instanceof GenericItem) {
						final GenericItem gItem = (GenericItem) item;
						items.add(gItem);
					}
				} catch (ItemNotFoundException e) {
					// ignore
				}
			} else {
				if(widget instanceof Frame) {
					items.addAll(getAllItems(((Frame) widget).getChildren()));
				}
			}
		}
	}
	return items;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:31,代码来源:WebAppServlet.java


示例6: handleItems

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * This method handles an items command. 
 * 
 * @param args array which contains the arguments for the items command
 * @param console the console for printing messages for the user
 */
static public void handleItems(String[] args, Console console) {
	ItemRegistry registry = (ItemRegistry) CompatibilityActivator.itemRegistryTracker.getService();
	if(registry!=null) {
		String pattern = (args.length == 0) ? "*" : args[0];
		Collection<Item> items = registry.getItems(pattern);
		if(items.size()>0) {
			for(Item item : items) {
				console.println(item.toString());
			}
		} else {
			console.println("No items found for this pattern.");
		}
	} else {
		console.println("Sorry, no item registry service available!");
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:23,代码来源:ConsoleInterpreter.java


示例7: sumSince

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * Gets the sum of the state of a given <code>item</code> since a certain point in time. 
 * The {@link PersistenceService} identified by the <code>serviceName</code> is used. 
 * 
 * @param item the item to get the average state value for
 * @param the point in time to start the check 
 * @param serviceName the name of the {@link PersistenceService} to use
 * @return the sum state value since the given point in time
 */

static public DecimalType sumSince(Item item, AbstractInstant timestamp, String serviceName) {
	Iterable<HistoricItem> result = getAllStatesSince(item, timestamp, serviceName);
	Iterator<HistoricItem> it = result.iterator();
	
	double sum = 0;
	while(it.hasNext()) {
		State state = it.next().getState();
		if (state instanceof DecimalType) {
			sum += ((DecimalType) state).doubleValue();
		}
	}

	return new DecimalType(sum);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:25,代码来源:PersistenceExtensions.java


示例8: receiveCommand

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void receiveCommand(Item item, Command command, ZWaveNode node,
		ZWaveMeterCommandClass commandClass, int endpointId, Map<String,String> arguments) {
	
	// It's not an ON command from a button switch, do not reset
	if (command != OnOffType.ON)
		return;
	
	// get the reset message - will return null if not supported
	SerialMessage serialMessage = node.encapsulate(commandClass.getResetMessage(), commandClass, endpointId);
	
	if (serialMessage == null) {
		logger.warn("NODE {}: Meter reset not supported for item = {}, endpoint = {}, ignoring event.", node.getNodeId(), item.getName(), endpointId);
		return;
	}
	
	// send reset message
	this.getController().sendData(serialMessage);
	
	// poll the device
	for (SerialMessage serialGetMessage : commandClass.getDynamicValues(true)) {
		this.getController().sendData(node.encapsulate(serialGetMessage, commandClass, endpointId));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:28,代码来源:ZWaveMeterConverter.java


示例9: processBindingConfiguration

import org.openhab.core.items.Item; //导入依赖的package包/类
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig)
		throws BindingConfigParseException {
	super.processBindingConfiguration(context, item, bindingConfig);

	final String[] configParts = bindingConfig.trim().split(":");
	if (configParts.length != 2) {
		throw new BindingConfigParseException(
				"FrontierSiliconRadio configuration must contain of two parts separated by a ':'");
	}

	final String deviceId = configParts[0];
	final String property = configParts[1];
	final Class<? extends Item> itemType = item.getClass();
	final FrontierSiliconRadioBindingConfig config = new FrontierSiliconRadioBindingConfig(deviceId, property,
			itemType);

	addBindingConfig(item, config);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:20,代码来源:FrontierSiliconRadioGenericBindingProvider.java


示例10: handleItems

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * This method handles an items command. 
 * 
 * @param args array which contains the arguments for the items command
 * @param console the console for printing messages for the user
 */
static public void handleItems(String[] args, Console console) {
	ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
	if(registry!=null) {
		String pattern = (args.length == 0) ? "*" : args[0];
		Collection<Item> items = registry.getItems(pattern);
		if(items.size()>0) {
			for(Item item : items) {
				console.println(item.toString());
			}
		} else {
			console.println("No items found for this pattern.");
		}
	} else {
		console.println("Sorry, no item registry service available!");
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:23,代码来源:ConsoleInterpreter.java


示例11: createOneWireDeviceProperty

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * @param pvItem
 * @param pvBindingConfig
 * @return a new BindingConfig, corresponding to the given <code><pvItem/code> and <code><pvBindingConfig/code>
 * @throws BindingConfigParseException
 */
public static OneWireBindingConfig createOneWireDeviceProperty(Item pvItem, String pvBindingConfig) throws BindingConfigParseException {
	logger.debug("createOneWireDeviceProperty: " + pvItem.getName() + " - bindingConfig:" + pvBindingConfig);

	OneWireBindingConfig lvNewBindingConfig = null;
	if (OneWireClearCacheControlBindingConfig.isBindingConfigToCreate(pvItem, pvBindingConfig)) {
		lvNewBindingConfig = new OneWireClearCacheControlBindingConfig(pvBindingConfig);
	} else if (OneWireDevicePropertySwitchMinMaxNumberWarningBindingConfig.isBindingConfigToCreate(pvItem, pvBindingConfig)) {
		lvNewBindingConfig = new OneWireDevicePropertySwitchMinMaxNumberWarningBindingConfig(pvBindingConfig);
	} else if (pvItem instanceof NumberItem) {
		lvNewBindingConfig = new OneWireDevicePropertyNumberBindingConfig(pvBindingConfig);
	} else if (pvItem instanceof ContactItem) {
		lvNewBindingConfig = new OneWireDevicePropertyContactBindingConfig(pvBindingConfig);
	} else if (pvItem instanceof SwitchItem) {
		lvNewBindingConfig = new OneWireDevicePropertySwitchBindingConfig(pvBindingConfig);
	} else if (pvItem instanceof StringItem) {
		lvNewBindingConfig = new OneWireDevicePropertyStringBindingConfig(pvBindingConfig);
	} else {
		throw new UnsupportedOperationException("the item-type " + pvItem.getClass() + " cannot be a onewire device");
	}

	logger.debug("created newBindingConfig: " + lvNewBindingConfig.toString());

	return lvNewBindingConfig;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:31,代码来源:OneWireBindingConfigFactory.java


示例12: processBindingConfiguration

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * Binding config in the style {em=
 * "type=01|02|03;address=AA;datapoint=CUMULATED_VALUE;correctionFactor=NN"}
 * {@inheritDoc}
 */
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig)
		throws BindingConfigParseException {
	super.processBindingConfiguration(context, item, bindingConfig);
	String[] parts = bindingConfig.split(";");
	String address = null;
	EMType type = null;
	Datapoint datapoint = null;
	double correctionFactor = 0;
	for (String part : parts) {
		String[] keyValue = part.split("=");
		if ("type".equals(keyValue[0])) {
			type = EMType.getFromTypeValue(keyValue[1]);
		} else if ("address".equals(keyValue[0])) {
			address = keyValue[1];
		} else if ("datapoint".equals(keyValue[0])) {
			datapoint = Datapoint.valueOf(keyValue[1]);
		} else if ("correctionFactor".equals(keyValue[0])) {
			correctionFactor = Double.parseDouble(keyValue[1]);
		}
	}
	EMBindingConfig config = new EMBindingConfig(type, address, datapoint, item, correctionFactor);

	addBindingConfig(item, config);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:31,代码来源:EMGenericBindingProvider.java


示例13: changedSince

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * Checks if the state of a given <code>item</code> has changed since a certain point in time. 
 * The {@link PersistenceService} identified by the <code>serviceName</code> is used. 
 * 
 * @param item the item to check for state changes
 * @param the point in time to start the check 
 * @param serviceName the name of the {@link PersistenceService} to use
 * @return true, if item state had changed
 */
static public Boolean changedSince(Item item, AbstractInstant timestamp, String serviceName) {
	Iterable<HistoricItem> result = getAllStatesSince(item, timestamp, serviceName);
	Iterator<HistoricItem> it = result.iterator();
	HistoricItem itemThen = historicState(item, timestamp);
	if(itemThen == null) {
		// Can't get the state at the start time
		// If we've got results more recent that this, it must have changed
		return(it.hasNext());
	}

	State state = itemThen.getState();
	while(it.hasNext()) {
		HistoricItem hItem = it.next();
		if(state!=null && !hItem.getState().equals(state)) {
			return true;
		}
		state = hItem.getState();
	}
	return false;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:30,代码来源:PersistenceExtensions.java


示例14: getSingleResponseObject

import org.openhab.core.items.Item; //导入依赖的package包/类
@Override
protected Object getSingleResponseObject(Item item, HttpServletRequest request) {
	ItemStateListBean responseBean ;
	Collection<ItemBean> beans = new LinkedList<ItemBean>();
	if (itemNames.containsKey(item.getName())) {
		for (ReturnType rt : itemNames.get(item.getName())) {
			if (rt.getStateClass()!=null) {
				beans.add(new ItemBean(rt.getClientItemName(), item.getStateAs(rt.getStateClass()).toString()));
			} else {
				beans.add(new ItemBean(rt.getClientItemName(), item.getState().toString()));
			}
		}
	} else {
		beans.add(new ItemBean(item.getName(), item.getState().toString()));
	}
	responseBean = new ItemStateListBean( new ItemListBean(beans));
	responseBean.index = System.currentTimeMillis();
	return responseBean;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:20,代码来源:ItemStateChangeListener.java


示例15: putItemState

import org.openhab.core.items.Item; //导入依赖的package包/类
@PUT @Path("/{itemname: [a-zA-Z_0-9]*}/state")
@Consumes(MediaType.TEXT_PLAIN)	
public Response putItemState(@PathParam("itemname") String itemname, String value) {
   	final Item item = getItem(itemname);
   	if(item!=null) {
   		final State state = TypeParser.parseState(item.getAcceptedDataTypes(), value);
   		if(state!=null) {
   			if (logger.isDebugEnabled()) logger.debug("Received HTTP PUT request at '{}' with value '{}'.", uriInfo.getPath(), value);
   			RESTApplication.getEventPublisher().postUpdate(itemname, state);
   			return Response.ok().build();
   		} else {
   			if (logger.isDebugEnabled()) logger.warn("Received HTTP PUT request at '{}' with an invalid status value '{}'.", uriInfo.getPath(), value);
   			return Response.status(Status.BAD_REQUEST).build();
   		}
   	} else {
   		logger.info("Received HTTP PUT request at '{}' for the unknown item '{}'.", uriInfo.getPath(), itemname);
   		throw new WebApplicationException(404);
   	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:20,代码来源:ItemResource.java


示例16: calculate

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * @{inheritDoc
 */
public State calculate(List<Item> items) {
	if(items!=null && items.size()>0) {
		BigDecimal min = null;
		for(Item item : items) {
			DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
			if(itemState!=null) {
				if(min==null || min.compareTo(itemState.toBigDecimal()) > 0) {
					min = itemState.toBigDecimal();
				}
			}
		}
		if(min!=null) {
			return new DecimalType(min);
		}
	}
	return UnDefType.UNDEF;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:21,代码来源:ArithmeticGroupFunction.java


示例17: validateItemType

import org.openhab.core.items.Item; //导入依赖的package包/类
/**
 * @{inheritDoc}
 */
@Override
public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException {
    // if (!(item instanceof SwitchItem || item instanceof DimmerItem)) {
    // throw new BindingConfigParseException("item '" + item.getName()
    // + "' is of type '" + item.getClass().getSimpleName()
    // + "', only Switch- and DimmerItems are allowed - please check your *.items configuration");
    // }
}
 
开发者ID:docbender,项目名称:openHAB-Simatic,代码行数:12,代码来源:SimaticGenericBindingProvider.java


示例18: resolveConfigDataLength

import org.openhab.core.items.Item; //导入依赖的package包/类
int resolveConfigDataLength(String configParameters, Item item) throws BindingConfigParseException {
    String[] optionalConfigs = configParameters.substring(1).split(":");

    for (int i = 0; i < optionalConfigs.length; i++) {
        String param = optionalConfigs[i].toLowerCase();
        // is datatype?
        if (!(param.equals("i") || param.equals("o") || param.equals("io"))) {

            Matcher matcher = Pattern.compile("^array\\[(\\d+)\\]$").matcher(param);

            if (matcher.matches()) {
                if (item.getClass().isAssignableFrom(StringItem.class)) {
                    if (!param.startsWith("array")) {
                        logger.warn(
                                "Item %s support datatype array only. Type %s is ignored. Setted to ARRAY with length 32.",
                                item.getName(), param);
                        return 32;
                    } else {
                        return Integer.valueOf(matcher.group(1)).intValue();
                    }
                }
            }
        }
    }

    return 1;
}
 
开发者ID:docbender,项目名称:openHAB-Simatic,代码行数:28,代码来源:SimaticGenericBindingProvider.java


示例19: resolveDataTypeFromItemType

import org.openhab.core.items.Item; //导入依赖的package包/类
SimaticTypes resolveDataTypeFromItemType(Item item, String address) throws BindingConfigParseException {
    Class<? extends Item> itemType = item.getClass();

    if (itemType.isAssignableFrom(NumberItem.class)) {
        switch (SimaticPLCAddress.create(address).dataType) {
            case DWORD:
                return SimaticTypes.DWORD;
            case WORD:
                return SimaticTypes.WORD;
            default:
                return SimaticTypes.BYTE;
        }
    } else if (itemType.isAssignableFrom(SwitchItem.class)) {
        return SimaticTypes.BYTE;
    } else if (itemType.isAssignableFrom(DimmerItem.class)) {
        return SimaticTypes.BYTE;
    } else if (itemType.isAssignableFrom(ColorItem.class)) {
        logger.warn("Item %s has not specified datatype. Setted to RGB.", item.getName());
        return SimaticTypes.RGB;
    } else if (itemType.isAssignableFrom(StringItem.class)) {
        logger.warn("Item %s has not specified datatype with length. Setted to ARRAY with length 32.",
                item.getName());
        return SimaticTypes.ARRAY;
    } else if (itemType.isAssignableFrom(ContactItem.class)) {
        return SimaticTypes.BYTE;
    } else if (itemType.isAssignableFrom(RollershutterItem.class)) {
        return SimaticTypes.WORD;
    } else {
        throw new BindingConfigParseException("Unsupported item type: " + item);
    }
}
 
开发者ID:docbender,项目名称:openHAB-Simatic,代码行数:32,代码来源:SimaticGenericBindingProvider.java


示例20: SimaticBindingConfig

import org.openhab.core.items.Item; //导入依赖的package包/类
public SimaticBindingConfig(Item item, String device, String address, SimaticTypes datatype, int direction) {
    super();

    this.item = item;
    this.device = device;
    this.direction = direction;
    this.datatype = datatype;

    this.address = new SimaticPLCAddress(address);
}
 
开发者ID:docbender,项目名称:openHAB-Simatic,代码行数:11,代码来源:SimaticGenericBindingProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IStorage2UriMapper类代码示例发布时间:2022-05-23
下一篇:
Java ContextExtensionPoint类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap