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

Java State类代码示例

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

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



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

示例1: mapState

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private org.openhab.core.types.State mapState(State state, String itemName) {
	if(state==null) return null;
	
	Item eshItem;
	try {
		eshItem = itemRegistry.getItem(itemName);
		if(eshItem!=null) {
			return org.openhab.core.types.TypeParser.parseState(
					ItemMapper.mapToOpenHABItem(eshItem).getAcceptedDataTypes(), state.toString());
		} else {
			return null;
		}
	} catch (ItemNotFoundException e) {
		return null;
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:17,代码来源:QueryablePersistenceServiceDelegate.java


示例2: handleCommand

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
       if (command instanceof RefreshType) {
           switch (channelUID.getId()) {
           case CHANNEL_ONLINE:
           	try {
				State state = networkService.updateDeviceState() ? OnOffType.ON : OnOffType.OFF;
				updateState(CHANNEL_ONLINE, state);					
			} catch( InvalidConfigurationException invalidConfigurationException) {
				getThing().setStatus(ThingStatus.OFFLINE);
			}
           	break;
           default:
               logger.debug("Command received for an unknown channel: {}", channelUID.getId());
               break;
           }
       } else {
           logger.debug("Command {} is not supported for channel: {}", command, channelUID.getId());
       }	
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:21,代码来源:NetworkHandler.java


示例3: convertNetUsbPlayStatus

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private State convertNetUsbPlayStatus(String data) {
    State state = UnDefType.UNDEF;
    switch (data.charAt(0)) {
        case 'P':
            state = PlayPauseType.PLAY;
            break;
        case 'p':
        case 'S':
            state = PlayPauseType.PAUSE;
            break;
        case 'F':
            state = RewindFastforwardType.FASTFORWARD;
            break;
        case 'R':
            state = RewindFastforwardType.REWIND;
            break;

    }
    return state;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:21,代码来源:OnkyoHandler.java


示例4: getNAThingProperty

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
protected State getNAThingProperty(String channelId) {
    try {
        if (channelId.equalsIgnoreCase(CHANNEL_LAST_MESSAGE) && module != null) {
            Method getLastMessage = module.getClass().getMethod("getLastMessage");
            Integer lastMessage = (Integer) getLastMessage.invoke(module);
            return ChannelTypeUtils.toDateTimeType(lastMessage);
        }
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
            | InvocationTargetException e) {
        logger.error("The module has no method to access {} property ", channelId);
        return UnDefType.NULL;
    }

    return super.getNAThingProperty(channelId);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:NetatmoModuleHandler.java


示例5: getChannelState

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
protected State getChannelState(ChannelUID channelUID, SmokeDetector smokeDetector) {
    switch (channelUID.getId()) {
        case CHANNEL_CO_ALARM_STATE:
            return new StringType(smokeDetector.getCoAlarmState().toString());
        case CHANNEL_LAST_CONNECTION:
            return getAsDateTimeTypeOrNull(smokeDetector.getLastConnection());
        case CHANNEL_LAST_MANUAL_TEST_TIME:
            return getAsDateTimeTypeOrNull(smokeDetector.getLastManualTestTime());
        case CHANNEL_LOW_BATTERY:
            return getAsOnOffType(smokeDetector.getBatteryHealth() == BatteryHealth.REPLACE);
        case CHANNEL_MANUAL_TEST_ACTIVE:
            return getAsOnOffType(smokeDetector.isManualTestActive());
        case CHANNEL_SMOKE_ALARM_STATE:
            return new StringType(smokeDetector.getSmokeAlarmState().toString());
        case CHANNEL_UI_COLOR_STATE:
            return new StringType(smokeDetector.getUiColorState().toString());
        default:
            logger.error("Unsupported channelId '{}'", channelUID.getId());
            return UnDefType.UNDEF;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:23,代码来源:NestSmokeDetectorHandler.java


示例6: setBrightness

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public CompletableFuture<Void> setBrightness(Integer value) throws Exception {
    if (value == null) {
        value = 0;
    }
    State state = getItem().getStateAs(HSBType.class);
    if (state instanceof HSBType) {
        HSBType hsb = (HSBType) state;
        HSBType newState = new HSBType(hsb.getHue(), hsb.getSaturation(), new PercentType(value));
        ((ColorItem) getItem()).send(newState);
        return CompletableFuture.completedFuture(null);
    } else {
        // state is undefined (light is not connected)
        return CompletableFuture.completedFuture(null);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:HomekitColorfulLightbulbImpl.java


示例7: handleUpdate

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
    logger.debug("Update {} for channel {} received", newState, channelUID);
    switch (channelUID.getId()) {
        case CHANNEL_BRIGHTNESS:
            if (newState instanceof PercentType) {
                lastBrigthness = ((PercentType) newState).intValue();
            }
            break;
        case CHANNEL_COLOR:
            if (newState instanceof HSBType) {
                lastColor = ((HSBType) newState).getRGB();
            }
            break;
        case CHANNEL_GATEWAY_VOLUME:
            if (newState instanceof DecimalType) {
                updateLastVolume((DecimalType) newState);
            }
            break;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:22,代码来源:XiaomiActorGatewayHandler.java


示例8: convertToState

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public State convertToState(String channelId) throws RFXComUnsupportedChannelException {
    switch (channelId) {
        case CHANNEL_WIND_DIRECTION:
            return new DecimalType(windDirection);

        case CHANNEL_AVG_WIND_SPEED:
            return new DecimalType(avgWindSpeed);

        case CHANNEL_WIND_SPEED:
            return new DecimalType(windSpeed);

        case CHANNEL_TEMPERATURE:
            return new DecimalType(temperature);

        case CHANNEL_CHILL_TEMPERATURE:
            return new DecimalType(chillTemperature);

        default:
            return super.convertToState(channelId);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:23,代码来源:RFXComWindMessage.java


示例9: getNAThingProperty

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
protected State getNAThingProperty(String chanelId) {
    switch (chanelId) {
        case CHANNEL_WELCOME_CAMERA_STATUS:
            return module != null ? toOnOffType(module.getStatus()) : UnDefType.UNDEF;
        case CHANNEL_WELCOME_CAMERA_SDSTATUS:
            return module != null ? toOnOffType(module.getSdStatus()) : UnDefType.UNDEF;
        case CHANNEL_WELCOME_CAMERA_ALIMSTATUS:
            return module != null ? toOnOffType(module.getAlimStatus()) : UnDefType.UNDEF;
        case CHANNEL_WELCOME_CAMERA_ISLOCAL:
            return (module == null || module.getIsLocal() == null) ? UnDefType.UNDEF
                    : module.getIsLocal() ? OnOffType.ON : OnOffType.OFF;
        case CHANNEL_WELCOME_CAMERA_LIVEPICTURE_URL:
            return getLivePictureURL() == null ? UnDefType.UNDEF : toStringType(getLivePictureURL());
        case CHANNEL_WELCOME_CAMERA_LIVEPICTURE:
            return getLivePictureURL() == null ? UnDefType.UNDEF : HttpUtil.downloadImage(getLivePictureURL());
        case CHANNEL_WELCOME_CAMERA_LIVESTREAM_URL:
            return getLiveStreamURL() == null ? UnDefType.UNDEF : new StringType(getLiveStreamURL());
    }
    return super.getNAThingProperty(chanelId);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:22,代码来源:NAWelcomeCameraHandler.java


示例10: handleMMInfoText

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
/**
 * Helper method to handle MMInfoText notifications. There may be multiple infotext messages that represent a single
 * message. We know when we get the last info text when the MMATTR contains an 'E' (last item). Once we have the
 * last item, we update the channel with the complete message.
 *
 * @param infoTextValue the last info text value
 * @return a non-null containing the complete or null if the message isn't complete yet
 */
private String handleMMInfoText(String infoTextValue) {
    final StatefulHandlerCallback callback = ((StatefulHandlerCallback) getCallback());

    final State attr = callback.getProperty(RioConstants.CHANNEL_SOURCEMMATTR);

    infoLock.lock();
    try {
        infoText.append(infoTextValue.toString());
        if (attr != null && attr.toString().indexOf("E") >= 0) {
            final String text = infoText.toString();

            infoText.setLength(0);
            callback.removeState(RioConstants.CHANNEL_SOURCEMMATTR);

            return text;
        }
        return null;
    } finally {
        infoLock.unlock();
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:30,代码来源:RioSourceProtocol.java


示例11: handleVolumeSet

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private void handleVolumeSet(EiscpCommand.Zone zone, final State currentValue, final Command command) {
    if (command instanceof PercentType) {
        sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_SET),
                downScaleVolume((PercentType) command));
    } else if (command.equals(IncreaseDecreaseType.INCREASE)) {
        if (currentValue instanceof PercentType) {
            if (((DecimalType) currentValue).intValue() < configuration.volumeLimit) {
                sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_UP));
            } else {
                logger.info("Volume level is limited to {}, ignore volume up command.", configuration.volumeLimit);
            }
        }
    } else if (command.equals(IncreaseDecreaseType.DECREASE)) {
        sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_DOWN));
    } else if (command.equals(OnOffType.OFF)) {
        sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.MUTE_SET), command);
    } else if (command.equals(OnOffType.ON)) {
        sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.MUTE_SET), command);
    } else if (command.equals(RefreshType.REFRESH)) {
        sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.VOLUME_QUERY));
        sendCommand(EiscpCommand.getCommandForZone(zone, EiscpCommand.MUTE_QUERY));
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:24,代码来源:OnkyoHandler.java


示例12: stateUpdated

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public void stateUpdated(Item item, State state) {
    if (item instanceof GroupItem) {

        // group item update could be relevant for the client, although the state of switch group does not change
        // wenn more the one are on, the number-groupFunction changes
        Map<String, Class<? extends State>> clientItems = eventBroadcaster.getClientItems(item);
        if (clientItems != null && clientItems.size() > 0) {
            for (String cvItemName : clientItems.keySet()) {
                Class<? extends State> stateClass = clientItems.get(cvItemName);
                if (stateClass != null) {
                    StateBean stateBean = new StateBean();
                    stateBean.name = cvItemName;
                    stateBean.state = item.getStateAs(stateClass).toString();

                    eventBroadcaster.broadcastEvent(stateBean);
                }
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:22,代码来源:StateEventListener.java


示例13: convertToState

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
@Override
public State convertToState(String channelId) throws RFXComUnsupportedChannelException {
    switch (channelId) {
        case CHANNEL_CHANNEL1_AMPS:
            return new DecimalType(channel1Amps);

        case CHANNEL_CHANNEL2_AMPS:
            return new DecimalType(channel2Amps);

        case CHANNEL_CHANNEL3_AMPS:
            return new DecimalType(channel3Amps);

        default:
            return super.convertToState(channelId);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:RFXComCurrentMessage.java


示例14: itemStateEvent

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private void itemStateEvent(ItemStateEvent event) throws ItemNotFoundException {

		String itemName = event.getItemName();
		State itemState = event.getItemState();

		Item item = itemRegistry.getItem(itemName);

		for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
			subscriberStruct.eventSubscriber
					.stateUpdated(new com.incquerylabs.smarthome.eventbus.api.events.ItemStateEvent(item, itemState));
		}
		logger.trace(event.toString());
	}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:14,代码来源:EventBusImpl.java


示例15: itemStateChangedEvent

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private void itemStateChangedEvent(ItemStateChangedEvent event) throws ItemNotFoundException {

		String itemName = event.getItemName();
		State newState = event.getItemState();
		State oldState = event.getOldItemState();

		Item item = itemRegistry.getItem(itemName);

		for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
			subscriberStruct.eventSubscriber.stateChanged(
					new com.incquerylabs.smarthome.eventbus.api.events.ItemStateChangedEvent(item, newState, oldState));
		}
		logger.trace(event.toString());
	}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:15,代码来源:EventBusImpl.java


示例16: groupItemStateChangedEvent

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private void groupItemStateChangedEvent(GroupItemStateChangedEvent event) throws ItemNotFoundException {

		String itemName = event.getItemName();
		State newState = event.getItemState();
		State oldState = event.getOldItemState();

		Item item = itemRegistry.getItem(itemName);

		for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
			subscriberStruct.eventSubscriber.groupStateChanged(
					new com.incquerylabs.smarthome.eventbus.api.events.GroupItemStateChangedEvent(item, newState,
							oldState));
		}
		logger.trace(event.toString());
	}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:16,代码来源:EventBusImpl.java


示例17: processCommand

import org.eclipse.smarthome.core.types.State; //导入依赖的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


示例18: getTemperature

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private State getTemperature(String thingUID) {
    float temp = 0;

    if (DraytonWiserHeatHub != null) {
        /*
         * for (RoomStat roomstat : DraytonWiserHeatHub.getRoomStat()) {
         * temp = roomstat.getMeasuredTemperature();
         * temp = temp / 10;
         * }
         * if (temp != 0) {
         * return new DecimalType(temp);
         * }
         */
        // Added for new logic (Only interested in Rooms)
        for (Room room : DraytonWiserHeatHub.getRoom()) {
            String roomName = room.name.toLowerCase().replaceAll("\\s+", "");
            if (roomName.equals(thingUID)) {
                temp = room.calculatedTemperature;
                temp = temp / 10;
            }
        }
        if (temp != 0) {
            return new DecimalType(temp);
        }
    }
    return UnDefType.UNDEF;
    // return new DecimalType("1");
}
 
开发者ID:RobPope,项目名称:DraytonWiser,代码行数:29,代码来源:DraytonWiserHandler.java


示例19: getHumidity

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private State getHumidity(String thingUID) {
    int hum = 0;
    if (DraytonWiserHeatHub != null) {
        /*
         * for (RoomStat roomstat : DraytonWiserHeatHub.getRoomStat()) {
         * hum = roomstat.getMeasuredHumidity();
         * }
         *
         * if (hum != 0) {
         * return new DecimalType(hum);
         * }
         */
        for (Room room : DraytonWiserHeatHub.getRoom()) {
            String roomName = room.name.toLowerCase().replaceAll("\\s+", "");
            if (roomName.equals(thingUID)) {
                for (RoomStat roomstat : DraytonWiserHeatHub.getRoomStat()) {
                    if (roomstat.id == room.roomStatId) {
                        hum = roomstat.measuredHumidity;
                    }
                }
            }
        }
        if (hum != 0) {
            return new DecimalType(hum);
        }
    }
    return UnDefType.UNDEF;
    // return new DecimalType("1");
}
 
开发者ID:RobPope,项目名称:DraytonWiser,代码行数:30,代码来源:DraytonWiserHandler.java


示例20: getSetPoint

import org.eclipse.smarthome.core.types.State; //导入依赖的package包/类
private State getSetPoint(String thingUID) {
    float setpoint = 0;
    if (DraytonWiserHeatHub != null) {
        /*
         * for (RoomStat roomstat : DraytonWiserHeatHub.getRoomStat()) {
         * setpoint = roomstat.getSetPoint();
         * setpoint = setpoint / 10;
         * }
         * if (setpoint != 0) {
         * return new DecimalType(setpoint);
         * }
         */
        for (Room room : DraytonWiserHeatHub.getRoom()) {
            String roomName = room.name.toLowerCase().replaceAll("\\s+", "");
            if (roomName.equals(thingUID)) {
                setpoint = room.displayedSetPoint;
                setpoint = setpoint / 10;
            }
        }
        if (setpoint != 0) {
            return new DecimalType(setpoint);
        }

    }
    return UnDefType.UNDEF;
    // return new DecimalType("1");
}
 
开发者ID:RobPope,项目名称:DraytonWiser,代码行数:28,代码来源:DraytonWiserHandler.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SubjectConfirmationData类代码示例发布时间:2022-05-23
下一篇:
Java ControllerButtonControl类代码示例发布时间: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