本文整理匯總了Java中org.eclipse.smarthome.core.library.types.IncreaseDecreaseType類的典型用法代碼示例。如果您正苦於以下問題:Java IncreaseDecreaseType類的具體用法?Java IncreaseDecreaseType怎麽用?Java IncreaseDecreaseType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IncreaseDecreaseType類屬於org.eclipse.smarthome.core.library.types包,在下文中一共展示了IncreaseDecreaseType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initGlobals
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
private void initGlobals() {
kSession.setGlobal("logger", droolsLogger);
kSession.setGlobal("ON", OnOffType.ON);
kSession.setGlobal("OFF", OnOffType.OFF);
kSession.setGlobal("OPEN", OpenClosedType.OPEN);
kSession.setGlobal("CLOSED", OpenClosedType.CLOSED);
kSession.setGlobal("ZERO", PercentType.ZERO);
kSession.setGlobal("HUNDRED", PercentType.HUNDRED);
kSession.setGlobal("INCREASE", IncreaseDecreaseType.INCREASE);
kSession.setGlobal("DECREASE", IncreaseDecreaseType.DECREASE);
if (eventPublisher != null) {
kSession.setGlobal("openhab", eventPublisher);
}
logger.debug("Initialized global variables");
}
示例2: sendInputSourceCommand
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
@Override
public boolean sendInputSourceCommand(Command command, int zone) throws CommandTypeNotSupportedException {
AvrCommand commandToSend = null;
if (command == IncreaseDecreaseType.INCREASE) {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.INPUT_CHANGE_CYCLIC, zone);
} else if (command == IncreaseDecreaseType.DECREASE) {
commandToSend = RequestResponseFactory.getIpControlCommand(SimpleCommandType.INPUT_CHANGE_REVERSE, zone);
} else if (command instanceof StringType) {
String inputSourceValue = ((StringType) command).toString();
commandToSend = RequestResponseFactory.getIpControlCommand(ParameterizedCommandType.INPUT_CHANNEL_SET, zone)
.setParameter(inputSourceValue);
} else {
throw new CommandTypeNotSupportedException("Command type not supported.");
}
return sendCommand(commandToSend);
}
示例3: convertCommandToIntValue
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
/**
* Convert openHAB command to int.
*
* @param command
* @param min
* @param max
* @param currentValue
* @return
*/
public static int convertCommandToIntValue(Command command, int min, int max, int currentValue) {
if (command instanceof IncreaseDecreaseType || command instanceof DecimalType) {
int value;
if (command instanceof IncreaseDecreaseType && command == IncreaseDecreaseType.INCREASE) {
value = Math.min(max, currentValue + 1);
} else if (command instanceof IncreaseDecreaseType && command == IncreaseDecreaseType.DECREASE) {
value = Math.max(min, currentValue - 1);
} else if (command instanceof DecimalType) {
value = ((DecimalType) command).intValue();
} else {
throw new NumberFormatException("Command '" + command + "' not supported");
}
return value;
} else {
throw new NumberFormatException("Command '" + command + "' not supported");
}
}
示例4: handleVolumeSet
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的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));
}
}
示例5: initGlobals
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
private void initGlobals() {
kSession.setGlobal("logger", droolsLogger);
kSession.setGlobal("ON", OnOffType.ON);
kSession.setGlobal("OFF", OnOffType.OFF);
kSession.setGlobal("OPEN", OpenClosedType.OPEN);
kSession.setGlobal("CLOSED", OpenClosedType.CLOSED);
kSession.setGlobal("ZERO", PercentType.ZERO);
kSession.setGlobal("HUNDRED", PercentType.HUNDRED);
kSession.setGlobal("INCREASE", IncreaseDecreaseType.INCREASE);
kSession.setGlobal("DECREASE", IncreaseDecreaseType.DECREASE);
kSession.setGlobal("ARMED", OpenClosedType.OPEN);
kSession.setGlobal("DISARMED", OpenClosedType.CLOSED);
kSession.setGlobal("BRIGHTNESS", OpenClosedType.CLOSED);
kSession.setGlobal("DARKNESS", OpenClosedType.OPEN);
kSession.setGlobal("MOTION", OpenClosedType.OPEN);
kSession.setGlobal("NOMOTION", OpenClosedType.CLOSED);
kSession.setGlobal("DOOR_OPENED", OpenClosedType.OPEN);
kSession.setGlobal("DOOR_CLOSED", OpenClosedType.CLOSED);
kSession.setGlobal("PRESSED", OpenClosedType.OPEN);
kSession.setGlobal("RELEASED", OpenClosedType.CLOSED);
if (eventPublisher != null) {
kSession.setGlobal("openhab", eventPublisher);
}
logger.debug("Initialized global variables");
}
示例6: DimmerCommand
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
public DimmerCommand(Item item, IncreaseDecreaseType type, int value, long first, long period) {
if (type != null && type == IncreaseDecreaseType.DECREASE) {
if (value > 0) {
value = value * (-1);
}
}
this.item = item;
this.value = value;
this.first = first;
this.period = period;
this.timer = new Timer();
}
示例7: setBrightness
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
public void setBrightness(Command command) throws FreeboxException {
if (command != null) {
if (command instanceof OnOffType || command instanceof IncreaseDecreaseType ||
command instanceof DecimalType || command instanceof PercentType) {
LCDConfig lcd = fbClient.getLCDManager().getLCDConfig();
int value = 0;
int newValue = 0;
if (command instanceof IncreaseDecreaseType) {
value = lcd.getBrightness();
if (command == IncreaseDecreaseType.INCREASE) {
newValue = Math.min(100, value + 1);
} else {
newValue = Math.max(0, value - 1);
}
} else if (command instanceof OnOffType) {
newValue = (command == OnOffType.ON) ? 100 : 0;
} else if (command instanceof DecimalType) {
newValue = Math.min(100, ((DecimalType) command).intValue());
newValue = Math.max(newValue, 0);
} else {
return;
}
lcd.setBrightness(newValue);
fbClient.getLCDManager().setLCDConfig(lcd);
fetchLCDConfig();
}
}
}
示例8: handleSendEvent
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
@Override
public void handleSendEvent(Device device, int resendCount, boolean isdimmer, Command command)
throws TellstickException {
logger.info("Send {} to {}", command, device);
if (device instanceof TellstickNetDevice) {
if (command == OnOffType.ON) {
turnOn(device);
} else if (command == OnOffType.OFF) {
turnOff(device);
} else if (command instanceof PercentType) {
dim(device, (PercentType) command);
} else if (command instanceof IncreaseDecreaseType) {
increaseDecrease(device, ((IncreaseDecreaseType) command));
}
} else if (device instanceof SwitchableDevice) {
if (command == OnOffType.ON) {
if (isdimmer) {
logger.debug("Turn off first in case it is allready on");
turnOff(device);
}
turnOn(device);
} else if (command == OnOffType.OFF) {
turnOff(device);
}
} else {
logger.warn("Cannot send to {}", device);
}
}
示例9: increaseDecrease
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
private void increaseDecrease(Device dev, IncreaseDecreaseType increaseDecreaseType) throws TellstickException {
String strValue = ((TellstickDevice) dev).getData();
double value = 0;
if (strValue != null) {
value = Double.valueOf(strValue);
}
int percent = (int) Math.round((value / 255) * 100);
if (IncreaseDecreaseType.INCREASE == increaseDecreaseType) {
percent = Math.min(percent + 10, 100);
} else if (IncreaseDecreaseType.DECREASE == increaseDecreaseType) {
percent = Math.max(percent - 10, 0);
}
dim(dev, new PercentType(percent));
}
示例10: sendEvent
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
private void sendEvent(Device device, int resendCount, boolean isdimmer, Command command)
throws TellstickException {
for (int i = 0; i < resendCount; i++) {
checkLastAndWait(resendInterval);
logger.debug("Send {} to {} times={}", command, device, i);
if (device instanceof DimmableDevice) {
if (command == OnOffType.ON) {
turnOn(device);
} else if (command == OnOffType.OFF) {
turnOff(device);
} else if (command instanceof PercentType) {
dim(device, (PercentType) command);
} else if (command instanceof IncreaseDecreaseType) {
increaseDecrease(device, ((IncreaseDecreaseType) command));
}
} else if (device instanceof SwitchableDevice) {
if (command == OnOffType.ON) {
if (isdimmer) {
logger.debug("Turn off first in case it is allready on");
turnOff(device);
checkLastAndWait(resendInterval);
}
turnOn(device);
} else if (command == OnOffType.OFF) {
turnOff(device);
}
} else {
logger.warn("Cannot send to {}", device);
}
}
}
示例11: increaseDecrease
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
private void increaseDecrease(Device dev, IncreaseDecreaseType increaseDecreaseType) throws TellstickException {
String strValue = ((TellstickDevice) dev).getData();
double value = 0;
if (strValue != null) {
value = Double.valueOf(strValue);
}
int percent = (int) Math.round((value / 255) * 100);
if (IncreaseDecreaseType.INCREASE == increaseDecreaseType) {
percent = Math.min(percent + 10, 100);
} else if (IncreaseDecreaseType.DECREASE == increaseDecreaseType) {
percent = Math.max(percent - 10, 0);
}
dim(dev, new PercentType(percent));
}
示例12: handleVolumeCommand
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
/**
* Uses the given {@link Command} to change the volume of the speaker.
*
* @param command The {@link Command} with the new volume
* @throws SpeakerException Exception if the volume change failed
*/
public void handleVolumeCommand(Command command) throws SpeakerException {
if (command instanceof PercentType) {
speaker.volume().setVolume(convertPercentToAbsoluteVolume((PercentType) command));
} else if (command instanceof IncreaseDecreaseType) {
int stepSize = (command == IncreaseDecreaseType.DECREASE ? -getVolumeStepSize() : getVolumeStepSize());
speaker.volume().adjustVolume(stepSize);
}
}
示例13: handleVolume
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
private void handleVolume(Command command) throws IOException {
if (command instanceof IncreaseDecreaseType && command == IncreaseDecreaseType.INCREASE) {
sendIfPowerOn("volume_up!");
} else if (command instanceof IncreaseDecreaseType && command == IncreaseDecreaseType.DECREASE) {
sendIfPowerOn("volume_down!");
} else if (command instanceof DecimalType) {
double value = Double.parseDouble(command.toString()) * maximumVolume / 100.0;
sendIfPowerOn("volume_" + ((int) value) + "!");
} else if (command instanceof RefreshType) {
sendIfPowerOn("get_current_volume!");
}
}
示例14: setBrightness
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
public void setBrightness(Command command) throws FreeboxException {
if (command != null) {
if (command instanceof OnOffType || command instanceof IncreaseDecreaseType
|| command instanceof DecimalType || command instanceof PercentType) {
LCDConfig lcd = fbClient.getLCDManager().getLCDConfig();
int value = 0;
int newValue = 0;
if (command instanceof IncreaseDecreaseType) {
value = lcd.getBrightness();
if (command == IncreaseDecreaseType.INCREASE) {
newValue = Math.min(100, value + 1);
} else {
newValue = Math.max(0, value - 1);
}
} else if (command instanceof OnOffType) {
newValue = (command == OnOffType.ON) ? 100 : 0;
} else if (command instanceof DecimalType) {
newValue = Math.min(100, ((DecimalType) command).intValue());
newValue = Math.max(newValue, 0);
} else {
return;
}
lcd.setBrightness(newValue);
fbClient.getLCDManager().setLCDConfig(lcd);
fetchLCDConfig();
}
}
}
示例15: onReceiveCommand
import org.eclipse.smarthome.core.library.types.IncreaseDecreaseType; //導入依賴的package包/類
@Override
public void onReceiveCommand(ConnectableDevice device, String channelId, LGWebOSHandler handler, Command command) {
if (device == null) {
return;
}
if (IncreaseDecreaseType.INCREASE == command) {
if (device.hasCapabilities(TVControl.Channel_Up)) {
getControl(device).channelUp(createDefaultResponseListener());
}
} else if (IncreaseDecreaseType.DECREASE == command) {
if (device.hasCapabilities(TVControl.Channel_Down)) {
getControl(device).channelDown(createDefaultResponseListener());
}
} else if (device.hasCapabilities(TVControl.Channel_List, TVControl.Channel_Set)) {
final String value = command.toString();
final TVControl control = getControl(device);
control.getChannelList(new TVControl.ChannelListListener() {
@Override
public void onError(ServiceCommandError error) {
logger.warn("error requesting channel list: {}.", error.getMessage());
}
@Override
public void onSuccess(List<ChannelInfo> channels) {
if (logger.isDebugEnabled()) {
channels.forEach(c -> logger.debug("Channel {} - {}", c.getNumber(), c.getName()));
}
Optional<ChannelInfo> channelInfo = channels.stream().filter(c -> c.getNumber().equals(value))
.findFirst();
if (channelInfo.isPresent()) {
control.setChannel(channelInfo.get(), createDefaultResponseListener());
} else {
logger.warn("TV does not have a channel: {}.", value);
}
}
});
}
}