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


Java OnOffType.OFF属性代码示例

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


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

示例1: convertData

double convertData(org.openhab.core.types.State state) {
	if (state instanceof DecimalType) {
		return ((DecimalType) state).doubleValue();				
	}
	else if(state instanceof OnOffType) {
		if(state == OnOffType.OFF)
			return 0;
		else
			return 1;
	}
	else if(state instanceof OpenClosedType) {
		if(state == OpenClosedType.CLOSED)
			return 0;
		else
			return 1;
	}
	else {
		logger.debug("Unsupported item type in chart: {}", state.getClass().toString());
		return 0;
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:21,代码来源:DefaultChartProvider.java

示例2: createState

/**
 * Creates an openHAB {@link State} in accordance to the class of the given {@code propertyValue}. Currently
 * {@link Date}, {@link BigDecimal}, {@link Temperature} and {@link Boolean} are handled explicitly. All other
 * {@code dataTypes} are mapped to {@link StringType}.
 * <p>
 * If {@code propertyValue} is {@code null}, {@link UnDefType#NULL} will be returned.
 * 
 * Copied/adapted from the Koubachi binding.
 * 
 * @param propertyValue
 * 
 * @return the new {@link State} in accordance with {@code dataType}. Will never be {@code null}.
 */
private State createState(Object propertyValue) {
	if (propertyValue == null) {
		return UnDefType.NULL;
	}

	Class<?> dataType = propertyValue.getClass();

	if (Date.class.isAssignableFrom(dataType)) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime((Date) propertyValue);
		return new DateTimeType(calendar);
	} else if (Integer.class.isAssignableFrom(dataType)) {
		return new DecimalType((Integer) propertyValue);
	} else if (BigDecimal.class.isAssignableFrom(dataType)) {
		return new DecimalType((BigDecimal) propertyValue);
	} else if (Boolean.class.isAssignableFrom(dataType)) {
		if ((Boolean) propertyValue) {
			return OnOffType.ON;
		} else {
			return OnOffType.OFF;
		}
	} else {
		return new StringType(propertyValue.toString());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:38,代码来源:NestBinding.java

示例3: execute

@Override
protected void execute() {
	logger.debug("VDRMonitor execute called");
	if (vdrBinding != null) {
		for (VDRConfig vdrConfig : vdrBinding.vdrConfigCache.values()) {
			Boolean recording = checkRecording(vdrConfig);
			if (recording != null) {
				if (eventPublisher != null) {
					VDRBindingProvider bindingProvider = vdrBinding
							.findFirstMatchingBindingProviderByVDRId(vdrConfig.vdrId);
					if (bindingProvider != null) {
						String itemName = bindingProvider
								.getBindingItemName(vdrConfig.vdrId,
										VDRCommandType.RECORDING);
						State newState = recording.booleanValue() ? OnOffType.ON
								: OnOffType.OFF;
						eventPublisher.postUpdate(itemName, newState);

					}
				}
			}
		}
	} else {
		logger.info("VDRBinding not available");
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:26,代码来源:VDRMonitor.java

示例4: internalReceiveUpdate

/**
 * {@inheritDoc}
 */
@Override
protected void internalReceiveUpdate(String itemName, State newState) {

	PLCBusBindingConfig config = tryGetConfigFor(itemName);

	if (config == null) {
		logger.error("No config found for %s", itemName);
		return;
	}

	IPLCBusController controller = PLCBusController.create(serialPortGateway);

	if (newState == UnDefType.UNDEF) {
		StatusResponse response = controller.requestStatusFor(config.getUnit());

		State status = (response.isUnitOn()) ? OnOffType.ON : OnOffType.OFF;
		this.eventPublisher.postUpdate(itemName, status);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:22,代码来源:PLCBusBinding.java

示例5: getStateAs

/**
 * {@inheritDoc}
 */
@Override
public State getStateAs(Class<? extends State> typeClass) {
	if(typeClass==OnOffType.class) {
		// if it is not completely off, we consider the dimmer to be on
		return state.equals(PercentType.ZERO) ? OnOffType.OFF : OnOffType.ON;
	} else if(typeClass==DecimalType.class) {
		if(state instanceof PercentType) {
			return new DecimalType(((PercentType) state).toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
		}
	}
	return super.getStateAs(typeClass);
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:15,代码来源:DimmerItem.java

示例6: getOnOffState

/**
 * Returns the current heating state
 * @param itemType
 * @return
 */
public State getOnOffState(Class<? extends Item> itemType) {
	if (itemType == StringItem.class)
		return dcbState == 1 ? StringType.valueOf("ON") : StringType
				.valueOf("OFF");
	if (itemType == SwitchItem.class)
		return dcbState == 1 ? OnOffType.ON : OnOffType.OFF;

	// Default to DecimalType
	return DecimalType.valueOf(Integer.toString(dcbState));
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:15,代码来源:HeatmiserThermostat.java

示例7: getState

@Override
public State getState(LightwaveRfType type) {
	switch (type) {
	case DIMMER:
		return on ? PercentType.HUNDRED : OnOffType.OFF;
	case SWITCH:
		return on ? OnOffType.ON : OnOffType.OFF;
	default:
		return null;
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:11,代码来源:LightwaveRfOnOffCommand.java

示例8: handleEventType

/**
 * Processes a monitor event for a given binding type
 * 
 * @param event
 *            the monitor event to process
 * @param bindingType
 *            the binding type of the items to process
 */
private void handleEventType(MonitorEvent event, String bindingType) {
	for (FritzboxBindingProvider provider : providers) {
		for (String itemName : provider
				.getItemNamesForType(bindingType)) {
			Class<? extends Item> itemType = provider
					.getItemType(itemName);
			org.openhab.core.types.State state = null;
			if (event.eventType.equals("DISCONNECT")) {
				state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.OFF
						: CallType.EMPTY;
			} else if (event.eventType.equals("CONNECT")) {
				if (bindingType
						.equals(FritzboxBindingProvider.TYPE_ACTIVE)) {
					state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
							: new CallType(event.externalNo, event.line);
				} else {
					state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.OFF
							: CallType.EMPTY;
				}
			} else if (event.eventType.equals("RING")
					&& bindingType
							.equals(FritzboxBindingProvider.TYPE_INBOUND)) {
				state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
						: new CallType(event.externalNo,
								event.internalNo);
			} else if (event.eventType.equals("CALL")
					&& bindingType
							.equals(FritzboxBindingProvider.TYPE_OUTBOUND)) {
				state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
						: new CallType(event.internalNo,
								event.externalNo);
			}
			if (state != null) {
				eventPublisher.postUpdate(itemName, state);
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:46,代码来源:FritzboxBinding.java

示例9: handleSendEvent

public void handleSendEvent(TellstickBindingConfig config, TellstickDevice dev, Command command)
		throws TellstickException {

	int resend = config.getResend();
	long resendInterval = config.getResendInterval();
	for (int i = 0; i < resend; i++) {
		checkLastAndWait(resendInterval);
		logger.info("Send " + command + " to " + dev + " time=" + i + " conf " + config);
		switch (config.getValueSelector()) {

		case COMMAND:
			if (command == OnOffType.ON) {
				if (config.getUsageSelector() == TellstickValueSelector.DIMMABLE) {
					turnOff(dev);
					checkLastAndWait(resendInterval);
				}
				turnOn(config, dev);
			} else if (command == OnOffType.OFF) {
				turnOff(dev);
			}
			break;
		case DIMMING_LEVEL:
			if (command == OnOffType.ON) {
				turnOn(config, dev);
			} else if (command == OnOffType.OFF) {
				turnOff(dev);
			} else if (command instanceof PercentType) {
				dim(dev, (PercentType) command);
			} else if (command instanceof IncreaseDecreaseType) {
				increaseDecrease(dev, ((IncreaseDecreaseType) command));
			}
			break;
		default:
			break;
		}
	}

}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:38,代码来源:TellstickController.java

示例10: valueChanged

@Override
public void valueChanged(ParameterAddress parameterAddress, Value valueObject) {
    ButtonState buttonState = (ButtonState) valueObject;
    Command command = null;
    if (buttonDownPressed(parameterAddress)) {
        switch (buttonState) {
        case PRESSED:
            startDimmerThread(IncreaseDecreaseType.INCREASE);
            buttonOPressedTime = System.currentTimeMillis();
            break;
        case RELEASED:
            stopDimmerThread();
            if (isLongOButtonReleased()) {
                buttonOPressedTime = 0;
            } else {
                command = OnOffType.ON;
            }
            break;
        }
    } else if (buttonUpPressed(parameterAddress)) {
        switch (buttonState) {
        case PRESSED:
            startDimmerThread(IncreaseDecreaseType.DECREASE);
            buttonIPressedTime = System.currentTimeMillis();
            break;
        case RELEASED:
            stopDimmerThread();
            if (isLongIButtonReleased()) {
                buttonIPressedTime = 0;
            } else {
                command = OnOffType.OFF;
            }
            break;
        }
    }
    postCommand(command);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:37,代码来源:DimmerOnOffProfile.java

示例11: convertToState

@Override
public State convertToState(RFXComValueSelector valueSelector)
		throws RFXComException {

	org.openhab.core.types.State state = UnDefType.UNDEF;

	// SWITCHITEM
	if (valueSelector.getItemClass() == SwitchItem.class) {

		if (valueSelector == RFXComValueSelector.COMMAND) {
			switch (command) {
			case OFF:
				state = OnOffType.OFF;
				break;
			case ON:
				state = OnOffType.ON;
				break;
			default:
				throw new RFXComException("Can't convert value " + command
						+ " to COMMAND SwitchItem");
			}
		} else {
			throw new RFXComException("Can't convert " + valueSelector
					+ " to SwitchItem: not supported");
		}

		return state;
	}

	throw new RFXComException("Can't convert " + valueSelector + " to "
			+ valueSelector.getItemClass());

}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:33,代码来源:RFXComLighting4Message.java

示例12: sendUpdates

private void sendUpdates(YamahaReceiverProxy receiverProxy, String deviceUid) {
	// Get all item configurations belonging to this proxy
	Collection<YamahaReceiverBindingConfig> configs = getDeviceConfigs(deviceUid);
	try {
		for (Zone zone : Zone.values()) {
			// Poll the state from the device
			YamahaReceiverState state = receiverProxy.getState(zone);

			// Create state updates
			State powerUpdate = state.isPower() ? OnOffType.ON : OnOffType.OFF;
			State muteUpdate = state.isMute() ? OnOffType.ON : OnOffType.OFF;
			State inputUpdate = new StringType(state.getInput());
			State surroundUpdate = new StringType(state.getSurroundProgram());
			State updateVolumeDb = new DecimalType(state.getVolume());
			State updateVolumePercent = new PercentType(
					(int) dbToPercent(state.getVolume()));

			// Send updates
			sendUpdate(configs, zone, BindingType.power, powerUpdate);
			sendUpdate(configs, zone, BindingType.mute, muteUpdate);
			sendUpdate(configs, zone, BindingType.input, inputUpdate);
			sendUpdate(configs, zone, BindingType.surroundProgram, surroundUpdate);
			sendUpdate(configs, zone, BindingType.volumePercent, updateVolumePercent);
			sendUpdate(configs, zone, BindingType.volumeDb, updateVolumeDb);
		}
	} catch (IOException e) {
		logger.warn("Cannot communicate with " + receiverProxy.getHost());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:29,代码来源:YamahaReceiverBinding.java

示例13: booleanToState

protected State booleanToState(Item item, boolean value) {
	if (item instanceof ContactItem) {
		return value ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
	} else if (item instanceof SwitchItem) {
		return value ? OnOffType.ON : OnOffType.OFF;
	} else if (item instanceof NumberItem) {
		return value ? DECIMAL_ONE : DecimalType.ZERO;
	}

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

示例14: updateProperty

private void updateProperty(String property, OnOffType value) {
	value = (value == null ?  OnOffType.OFF : value);
	
	for (Entry<String, String> e : watches.entrySet()) {
		if (property.equals(e.getValue())) {
			eventPublisher.postUpdate(e.getKey(), value);
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:9,代码来源:XbmcConnector.java

示例15: toState

/**
 * Converts a {@link String} value to a {@link State} for a given {@link Item}
 * @param itemType
 * @param value
 * @return {@link State}
 */
private State toState(Class<? extends Item> itemType, String value) {
	if (itemType.isAssignableFrom(NumberItem.class)) {
		return new DecimalType(value);
	} else if (itemType.isAssignableFrom(SwitchItem.class)) {
		return Integer.parseInt(value) > 0 ? OnOffType.ON : OnOffType.OFF;
	} else {
		return StringType.valueOf(value);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:15,代码来源:AutelisBinding.java


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