當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。