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


Java GenericItem类代码示例

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


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

示例1: subscribe

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
public void subscribe(GenericItem item, String key, HomekitCharacteristicChangeCallback callback) {
    if (item == null) {
        return;
    }
    ItemKey itemKey = new ItemKey(item, key);
    if (subscriptionsByName.containsKey(itemKey)) {
        logger.error("Received duplicate subscription on {}", item.getName());
    }
    subscriptionsByName.compute(itemKey, (k, v) -> {
        if (v != null) {
            logger.error("Received duplicate subscription on {}", item.getName());
            unsubscribe(item, key);
        }
        Subscription subscription = (changedItem, oldState, newState) -> callback.changed();
        item.addStateChangeListener(subscription);
        return subscription;
    });
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:19,代码来源:HomekitAccessoryUpdater.java

示例2: processCommand

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
private void processCommand(Item item, Command command) {
    if (item instanceof GenericItem) {
        GenericItem genItem = (GenericItem) item;
        if (command instanceof State) {
            genItem.setState((State) command);
        } else {
            throw new IllegalStateException("Cannot parse command " + command + " to state");
        }
    } else {
        throw new IllegalStateException("Cannot parse command " + command + " to state");
    }
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:13,代码来源:EventBusMock.java

示例3: createItem

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
/**
 * @{inheritDoc}
 */
public GenericItem createItem(String itemTypeName, String itemName) {
	if (itemTypeName.equals(ITEM_TYPE))
		return new ESHCallItem(itemName);
	else {
		return null;
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:11,代码来源:TelItemFactory.java

示例4: registerItems

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
/**
 * listen for state changes from the requested items
 */
@Override
public void registerItems() {
    for (Item item : items.keySet()) {
        if (item instanceof GenericItem) {
            ((GenericItem) item).addStateChangeListener(stateEventListener);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:12,代码来源:ReadResource.java

示例5: registerItem

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
/**
 * listens to state changes of the given item, if it is part of the
 * requested items
 *
 * @param item
 *            - the new item, that should be listened to
 */
@Override
public void registerItem(Item item) {
    if (item == null || items.containsKey(item) || !itemNames.contains(item.getName())) {
        return;
    }
    if (item instanceof GenericItem) {
        ((GenericItem) item).addStateChangeListener(stateEventListener);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:ReadResource.java

示例6: unregisterItem

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
/**
 * listens to state changes of the given item, if it is part of the
 * requested items
 *
 * @param item
 *            - the new item, that should be listened to
 */
@Override
public void unregisterItem(Item item) {
    if (item == null || items.containsKey(item) || !itemNames.contains(item.getName())) {
        return;
    }
    if (item instanceof GenericItem) {
        ((GenericItem) item).removeStateChangeListener(stateEventListener);
        items.remove(item);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:18,代码来源:ReadResource.java

示例7: unsubscribe

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
public void unsubscribe(GenericItem item, String key) {
    if (item == null) {
        return;
    }
    subscriptionsByName.computeIfPresent(new ItemKey(item, key), (k, v) -> {
        item.removeStateChangeListener(v);
        return null;
    });
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:10,代码来源:HomekitAccessoryUpdater.java

示例8: setSwitchState

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
@Override
public CompletableFuture<Void> setSwitchState(boolean state) throws Exception {
    GenericItem item = getItem();
    if (item instanceof SwitchItem) {
        ((SwitchItem) item).send(state ? OnOffType.ON : OnOffType.OFF);
    } else if (item instanceof GroupItem) {
        ((GroupItem) item).send(state ? OnOffType.ON : OnOffType.OFF);
    }
    return CompletableFuture.completedFuture(null);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:HomekitSwitchImpl.java

示例9: getGenericItem

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends GenericItem> T getGenericItem(String name) {
    Item item = getItemRegistry().get(name);
    if (item == null) {
        return null;
    }
    if (!(item instanceof GenericItem)) {
        throw new RuntimeException("Expected GenericItem, found " + item.getClass().getCanonicalName());
    }
    return (T) item;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:12,代码来源:HomekitThermostatImpl.java

示例10: setLightbulbPowerState

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
@Override
public CompletableFuture<Void> setLightbulbPowerState(boolean value) throws Exception {
    GenericItem item = getItem();
    if (item instanceof SwitchItem) {
        ((SwitchItem) item).send(value ? OnOffType.ON : OnOffType.OFF);
    } else if (item instanceof GroupItem) {
        ((GroupItem) item).send(value ? OnOffType.ON : OnOffType.OFF);
    }
    return CompletableFuture.completedFuture(null);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:AbstractHomekitLightbulbImpl.java

示例11: setBrightness

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
@Override
public CompletableFuture<Void> setBrightness(Integer value) throws Exception {
    GenericItem item = getItem();
    if (item instanceof DimmerItem) {
        ((DimmerItem) item).send(new PercentType(value));
    } else if (item instanceof GroupItem) {
        ((GroupItem) item).send(new PercentType(value));
    }
    return CompletableFuture.completedFuture(null);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:HomekitDimmableLightbulbImpl.java

示例12: AbstractDevice

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
public AbstractDevice(DeviceType type, Item item) {
    this.type = type;
    this.item = item;
    params = new DeviceParameters();
    links = new HashMap<>();

    if (item instanceof GenericItem) {
        ((GenericItem) item).addStateChangeListener(this);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:AbstractDevice.java

示例13: destroy

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
public void destroy() {
    if (item instanceof GenericItem) {
        ((GenericItem) item).removeStateChangeListener(this);
    }

    deviceRegistry = null;
    actionRegistry = null;
    item = null;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:10,代码来源:AbstractDevice.java

示例14: setState

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
protected void setState(GenericItem item, State newState) {
    State oldState = item.getState();
    item.setState(newState);
    drools.stateChanged(new ItemStateChangedEvent(item, newState, oldState));
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:6,代码来源:BaseTest.java

示例15: ItemKey

import org.eclipse.smarthome.core.items.GenericItem; //导入依赖的package包/类
public ItemKey(GenericItem item, String key) {
    this.item = item;
    this.key = key;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:5,代码来源:HomekitAccessoryUpdater.java


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