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


Java Thing.getStatus方法代码示例

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


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

示例1: onStateUpdated

import org.eclipse.smarthome.core.thing.Thing; //导入方法依赖的package包/类
@Override
public void onStateUpdated(HmDatapoint dp) {
    Thing hmThing = getThingByUID(UidUtils.generateThingUID(dp.getChannel().getDevice(), getThing()));
    if (hmThing != null && hmThing.getHandler() != null) {
        final ThingStatus status = hmThing.getStatus();
        if (status == ThingStatus.ONLINE || status == ThingStatus.OFFLINE) {
            HomematicThingHandler thingHandler = (HomematicThingHandler) hmThing.getHandler();
            thingHandler.updateDatapointState(dp);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:12,代码来源:HomematicBridgeHandler.java

示例2: refreshNamedHandler

import org.eclipse.smarthome.core.thing.Thing; //导入方法依赖的package包/类
/**
 * Creates an "{id:x, name: 'xx'}" json string from all {@link RioNamedHandler} for a specific class and sends that
 * result to a channel id.
 *
 * @param gson a non-null {@link Gson} to use
 * @param clazz a non-null class that the results will be for
 * @param channelId a non-null, non-empty channel identifier to send the results to
 * @throws IllegalArgumentException if any argument is null or empty
 */
protected <H extends RioNamedHandler> void refreshNamedHandler(Gson gson, Class<H> clazz, String channelId) {
    if (gson == null) {
        throw new IllegalArgumentException("gson cannot be null");
    }
    if (clazz == null) {
        throw new IllegalArgumentException("clazz cannot be null");
    }
    if (StringUtils.isEmpty(channelId)) {
        throw new IllegalArgumentException("channelId cannot be null or empty");
    }

    final List<IdName> ids = new ArrayList<IdName>();
    for (Thing thn : getThing().getThings()) {
        if (thn.getStatus() == ThingStatus.ONLINE) {
            final ThingHandler handler = thn.getHandler();
            if (handler != null && handler.getClass().isAssignableFrom(clazz)) {
                final RioNamedHandler namedHandler = (RioNamedHandler) handler;
                if (namedHandler.getId() > 0) { // 0 returned when handler is initializing
                    ids.add(new IdName(namedHandler.getId(), namedHandler.getName()));
                }
            }
        }
    }

    final String json = gson.toJson(ids);
    updateState(channelId, new StringType(json));
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:37,代码来源:AbstractBridgeHandler.java


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