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


Java OnOffType.ON属性代码示例

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


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

示例1: internalReceiveCommand

/**
 * Handles {@link OnOffType#ON} commands for Koubachi care actions, i.e.
 * performs the action.
 * <p>
 * After the action was performed an {@link OnOffType#OFF} update is
 * published.
 */
@Override
protected void internalReceiveCommand(final String itemName, final Command command) {
	if (command != OnOffType.ON) {
		return; // abort processing
	}

	for (KoubachiBindingProvider provider : this.providers) {
		if (provider.isCareAction(itemName)) {
			final String plantId = provider.getResourceId(itemName);
			final String actionType = provider.getActionType(itemName);

			performCareAction(plantId, actionType);
		}
	}

	this.eventPublisher.postUpdate(itemName, OnOffType.OFF);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:24,代码来源:KoubachiBinding.java

示例2: createState

/**
 * Creates an openHAB {@link State} in accordance to the class of the given
 * {@code propertyValue}. Currently {@link Date}, {@link BigDecimal} 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.
 * 
 * @param propertyValue
 * 
 * @return the new {@link State} in accordance to {@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 (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,代码行数:37,代码来源:KoubachiBinding.java

示例3: getState

/**
 * Returns the current state of the thermostat
 * This is a consolidated status that brings together a number of
 * status registers within the thermostat.
 * @param itemType
 * @return
 */
public State getState(Class<? extends Item> itemType) {
	// If this is a switch, then just treat this like the getOnOffState() function
	if (itemType == SwitchItem.class)
		return dcbState == 1 ? OnOffType.ON : OnOffType.OFF;

	// Default to a string
	if(dcbState == 0)
		return StringType.valueOf(States.OFF.toString());
	if(dcbHolidayTime != 0)
		return StringType.valueOf(States.HOLIDAY.toString());
	if(dcbHoldTime != 0)
		return StringType.valueOf(States.HOLD.toString());

	return StringType.valueOf(States.ON.toString());
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:22,代码来源:HeatmiserThermostat.java

示例4: 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

示例5: convertReadValueToType

@Override
public Type convertReadValueToType(String pvReadValue) {
	Type lvType = super.convertReadValueToType(pvReadValue);

	// Must be Number Tyoe
	DecimalType lvDecimalType = (DecimalType) lvType;

	// Check if readValue greater then MaxWarningValue or less then
	// MinWarningValue
	if (ivMaxWarningValue != null && lvDecimalType.toBigDecimal().compareTo(ivMaxWarningValue) == 1) {
		return OnOffType.ON;
	} else if (ivMinWarningValue != null && lvDecimalType.toBigDecimal().compareTo(ivMinWarningValue) == -1) {
		return OnOffType.ON;
	} else {
		return OnOffType.OFF;
	}

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

示例6: setState

/**
 * {@inheritDoc}
 */
@Override
public void setState(State state) {
	// we map ON/OFF values to the percent values 0 and 100
	if(state==OnOffType.OFF) {
		super.setState(PercentType.ZERO);
	} else if(state==OnOffType.ON) {
		super.setState(PercentType.HUNDRED);
	} else {
		super.setState(state);
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:14,代码来源:DimmerItem.java

示例7: setState

/**
 * {@inheritDoc}
 */
@Override
public void setState(State state) {
	State currentState = this.state;
	
	if(currentState instanceof HSBType) {
		DecimalType hue = ((HSBType) currentState).getHue();
		PercentType saturation = ((HSBType) currentState).getSaturation();
		// we map ON/OFF values to dark/bright, so that the hue and saturation values are not changed 
		if(state==OnOffType.OFF) {
			super.setState(new HSBType(hue, saturation, PercentType.ZERO));
		} else if(state==OnOffType.ON) {
			super.setState(new HSBType(hue, saturation, PercentType.HUNDRED));
		} else if(state instanceof PercentType && !(state instanceof HSBType)) {
			super.setState(new HSBType(hue, saturation, (PercentType) state));
		} else {
			super.setState(state);
		}
	} else {
		// we map ON/OFF values to black/white and percentage values to grey scale 
		if(state==OnOffType.OFF) {
			super.setState(HSBType.BLACK);
		} else if(state==OnOffType.ON) {
			super.setState(HSBType.WHITE);
		} else if(state instanceof PercentType && !(state instanceof HSBType)) {
			super.setState(new HSBType(DecimalType.ZERO, PercentType.ZERO, (PercentType) state));
		} else {
			super.setState(state);
		}
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:33,代码来源:ColorItem.java

示例8: getHolidaySet

public State getHolidaySet(Class<? extends Item> itemType) {
	if (itemType == SwitchItem.class)
		return dcbHolidayTime > 0 ? OnOffType.ON : OnOffType.OFF;

	// Return the number of days (midnights) remaining
	// ie midnight tonight == 1
	int days = 0;
	if(dcbHolidayTime > 0)
		days = dcbHolidayTime / 24 + 1;

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

示例9: internalReceiveCommand

/**
 * {@inheritDoc}
 */
@Override
protected void internalReceiveCommand(String itemName, Command command) {

	PLCBusBindingConfig config = tryGetConfigFor(itemName);

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

	IPLCBusController controller = PLCBusController.create(serialPortGateway);
	if (command == OnOffType.ON) {
		controller.switchOn(config.getUnit());
	} else if (command == OnOffType.OFF) {
		controller.switchOff(config.getUnit());
	} else if (command == IncreaseDecreaseType.INCREASE) {
		controller.bright(config.getUnit(), config.getSeconds());
	} else if (command == IncreaseDecreaseType.DECREASE) {
		controller.dim(config.getUnit(), config.getSeconds());
	} else if (command == StopMoveType.STOP) {
		controller.fadeStop(config.getUnit());
	} else if (command == UpDownType.UP) {
		controller.switchOn(config.getUnit());
	} else if (command == UpDownType.DOWN) {
		controller.switchOff(config.getUnit());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:30,代码来源:PLCBusBinding.java

示例10: convertFromState

@Override
public void convertFromState(RFXComValueSelector valueSelector, String id,
		Object subType, Type type, byte seqNumber) throws RFXComException {

	this.subType = ((SubType) subType);
	seqNbr = seqNumber;
	String ids = id;
	sensorId = Integer.parseInt(ids);

	switch (valueSelector) {
	case COMMAND:
		if ((type instanceof OnOffType) && (subType == SubType.X10_SECURITY_REMOTE)) {
			status = (type == OnOffType.ON ? Status.ARM_AWAY_DELAYED : Status.DISARM);
		} else {
			throw new RFXComException("Can't convert " + type + " to Command");
		}
		break;

	case STATUS:
		if (type instanceof StringType) {
			status = Status.valueOf(type.toString());
		} else {
			throw new RFXComException("Can't convert " + type + " to Status");
		}
		break;

	default:
		throw new RFXComException("Can't convert " + type + " to " + valueSelector);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:30,代码来源:RFXComSecurity1Message.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: run

@Override
public void run() {
	if (command instanceof OnOffType) {
		if (((OnOffType) command) == OnOffType.ON)
			sendToDevices(SetTemperatureMsg.TEMPERATURE_ON);
		else if (((OnOffType) command) == OnOffType.OFF)
			sendToDevices(SetTemperatureMsg.TEMPERATURE_OFF);
	} else if (command instanceof DecimalType) {
		sendToDevices(((DecimalType) command).doubleValue());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:11,代码来源:MaxCulPacedThermostatTransmitTask.java

示例13: translateBoolean2State

/**
 * Calculates new item state based on the new boolean value, current item state and item class
 * Used with item bound to "coil" type slaves
 * 
 * @param b new boolean value
 * @param c class of the current item state
 * @param itemClass class of the item
 * 
 * @return new item state
 */
protected State translateBoolean2State(boolean b) {
	
	Class<? extends State> c = item.getState().getClass();
	Class<? extends Item> itemClass = item.getClass();
	
	if (c == UnDefType.class && itemClass == SwitchItem.class) {
		return b ? OnOffType.ON : OnOffType.OFF;
	}
	else if (c == UnDefType.class && itemClass == ContactItem.class) {
		return b ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
	}
	else if (c == OnOffType.class && itemClass == SwitchItem.class) {
		return b ? OnOffType.ON : OnOffType.OFF;
	}
	else if (c == OpenClosedType.class && itemClass == SwitchItem.class) {
		return b ? OnOffType.ON : OnOffType.OFF;
	}
	else if (c == OnOffType.class && itemClass == ContactItem.class) {
		return b ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
	}
	else if (c == OpenClosedType.class && itemClass == ContactItem.class) {
		return b ? OpenClosedType.OPEN : OpenClosedType.CLOSED;
	} else {
		return UnDefType.UNDEF;
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:36,代码来源:ModbusGenericBindingProvider.java

示例14: convert

@SuppressWarnings("rawtypes")
@Override
public Object convert(Class type, Object value) {
	if (value instanceof OnOffType) {
		return ((OnOffType) value) == OnOffType.ON;
	} else {
		return null;
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:9,代码来源:DataModel.java

示例15: 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 if (Temperature.class.isAssignableFrom(dataType)) {
		return new DecimalType(((Temperature) propertyValue).toLocalTemperature());
	} else if (State.class.isAssignableFrom(dataType)) {
		return (State) propertyValue;
	} else {
		return new StringType(propertyValue.toString());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:42,代码来源:EcobeeBinding.java


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