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


Java EiscpCommand类代码示例

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


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

示例1: handleNetMenuCommand

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
private void handleNetMenuCommand(String cmdName) {
    if ("Up".equals(cmdName)) {
        sendCommand(EiscpCommand.NETUSB_OP_UP);
    } else if ("Down".equals(cmdName)) {
        sendCommand(EiscpCommand.NETUSB_OP_DOWN);
    } else if ("Select".equals(cmdName)) {
        sendCommand(EiscpCommand.NETUSB_OP_SELECT);
    } else if ("PageUp".equals(cmdName)) {
        sendCommand(EiscpCommand.NETUSB_OP_LEFT);
    } else if ("PageDown".equals(cmdName)) {
        sendCommand(EiscpCommand.NETUSB_OP_RIGHT);
    } else if ("Back".equals(cmdName)) {
        sendCommand(EiscpCommand.NETUSB_OP_RETURN);
    } else if (cmdName.matches("Select[0-9]")) {
        int pos = Integer.parseInt(cmdName.substring(6));
        sendCommand(EiscpCommand.NETUSB_MENU_SELECT, new DecimalType(pos));
    } else {
        logger.debug("Received unknown menucommand {}", cmdName);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:21,代码来源:OnkyoHandler.java

示例2: handleVolumeSet

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的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

示例3: parseBindingConfig

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
protected void parseBindingConfig(String bindingConfigs,
		OnkyoBindingConfig config) throws BindingConfigParseException {

	String bindingConfig = StringUtils.substringBefore(bindingConfigs, ",");
	String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ",");

	String[] configParts = bindingConfig.trim().split(":");

	if (configParts.length != 3) {
		throw new BindingConfigParseException(
			"Onkyo binding must contain three parts separated by ':'");
	}

	String command = StringUtils.trim(configParts[0]);
	String deviceId = StringUtils.trim(configParts[1]);
	String deviceCommand = StringUtils.trim(configParts[2]);

	// Advanced command start with # character
	
	if( !deviceCommand.startsWith(ADVANCED_COMMAND_KEY)) {
		
		try {
			EiscpCommand.valueOf(deviceCommand);
		} catch (Exception e) {
			throw new BindingConfigParseException("Unregonized command '" + deviceCommand + "'");
		}
		
	}
	
	// if there are more commands to parse do that recursively ...
	if (StringUtils.isNotBlank(bindingConfigTail)) {
		parseBindingConfig(bindingConfigTail, config);
	}

	config.put(command, deviceId + ":" + deviceCommand);
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:37,代码来源:OnkyoGenericBindingProvider.java

示例4: initializeItem

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
/**
 * Initialize item value. Method send query to receiver if init query is configured to binding item configuration
 * 
 * @param itemType
 * 
 */
private void initializeItem(String itemName) {
	for (OnkyoBindingProvider provider : providers) {
		String initCmd = provider.getItemInitCommand(itemName);
		if (initCmd != null) {
			logger.debug("Initialize item {}", itemName);

			String[] commandParts = initCmd.split(":");
			String deviceId = commandParts[0];
			String deviceCmd = commandParts[1];

			DeviceConfig device = deviceConfigCache.get(deviceId);
			OnkyoConnection remoteController = device.getConnection();

			if (device != null && remoteController != null) {
				if (deviceCmd.startsWith(ADVANCED_COMMAND_KEY)) {
					deviceCmd = deviceCmd.replace(ADVANCED_COMMAND_KEY, "");
				} else {
					EiscpCommand cmd = EiscpCommand.valueOf(deviceCmd);
					deviceCmd = cmd.getCommand();
				}

				remoteController.send(deviceCmd);
			} else {
				logger.warn(
						"Cannot find connection details for device id '{}'",
						deviceId);
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:37,代码来源:OnkyoBinding.java

示例5: sendCommand

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
private void sendCommand(EiscpCommand deviceCommand) {
    if (connection != null) {
        connection.send(deviceCommand.getCommand(), deviceCommand.getValue());
    } else {
        logger.debug("Connect send command to onkyo receiver since the onkyo binding is not initialized");
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:8,代码来源:OnkyoHandler.java

示例6: checkStatus

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
/**
 * Check the status of the AVR.
 *
 * @return
 */
private void checkStatus() {
    sendCommand(EiscpCommand.POWER_QUERY);

    if (connection != null && connection.isConnected()) {

        sendCommand(EiscpCommand.VOLUME_QUERY);
        sendCommand(EiscpCommand.SOURCE_QUERY);
        sendCommand(EiscpCommand.MUTE_QUERY);
        sendCommand(EiscpCommand.NETUSB_TITLE_QUERY);
        sendCommand(EiscpCommand.LISTEN_MODE_QUERY);

        if (isChannelAvailable(CHANNEL_POWERZONE2)) {
            sendCommand(EiscpCommand.ZONE2_POWER_QUERY);
            sendCommand(EiscpCommand.ZONE2_VOLUME_QUERY);
            sendCommand(EiscpCommand.ZONE2_SOURCE_QUERY);
            sendCommand(EiscpCommand.ZONE2_MUTE_QUERY);
        }

        if (isChannelAvailable(CHANNEL_POWERZONE3)) {
            sendCommand(EiscpCommand.ZONE3_POWER_QUERY);
            sendCommand(EiscpCommand.ZONE3_VOLUME_QUERY);
            sendCommand(EiscpCommand.ZONE3_SOURCE_QUERY);
            sendCommand(EiscpCommand.ZONE3_MUTE_QUERY);
        }
    } else {
        updateStatus(ThingStatus.OFFLINE);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:34,代码来源:OnkyoHandler.java

示例7: parseBindingConfig

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
protected void parseBindingConfig(String bindingConfigs, OnkyoBindingConfig config)
        throws BindingConfigParseException {

    String bindingConfig = StringUtils.substringBefore(bindingConfigs, ",");
    String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ",");

    String[] configParts = bindingConfig.trim().split(":");

    if (configParts.length != 3) {
        throw new BindingConfigParseException("Onkyo binding must contain three parts separated by ':'");
    }

    String command = StringUtils.trim(configParts[0]);
    String deviceId = StringUtils.trim(configParts[1]);
    String deviceCommand = StringUtils.trim(configParts[2]);

    // Advanced command start with # character

    if (!deviceCommand.startsWith(ADVANCED_COMMAND_KEY)) {

        try {
            EiscpCommand.valueOf(deviceCommand);
        } catch (Exception e) {
            throw new BindingConfigParseException("Unregonized command '" + deviceCommand + "'");
        }

    }

    // if there are more commands to parse do that recursively ...
    if (StringUtils.isNotBlank(bindingConfigTail)) {
        parseBindingConfig(bindingConfigTail, config);
    }

    config.put(command, deviceId + ":" + deviceCommand);
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:36,代码来源:OnkyoGenericBindingProvider.java

示例8: initializeItem

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
/**
 * Initialize item value. Method send query to receiver if init query is
 * configured to binding item configuration
 *
 * @param itemType
 *
 */
private void initializeItem(String itemName) {
    for (OnkyoBindingProvider provider : providers) {
        String initCmd = provider.getItemInitCommand(itemName);
        if (initCmd != null) {
            logger.debug("Initialize item {}", itemName);

            String[] commandParts = initCmd.split(":");
            String deviceId = commandParts[0];
            String deviceCmd = commandParts[1];

            DeviceConfig device = deviceConfigCache.get(deviceId);
            OnkyoConnection remoteController = device.getConnection();

            if (device != null && remoteController != null) {
                if (deviceCmd.startsWith(ADVANCED_COMMAND_KEY)) {
                    deviceCmd = deviceCmd.replace(ADVANCED_COMMAND_KEY, "");
                } else {
                    EiscpCommand cmd = EiscpCommand.valueOf(deviceCmd);
                    deviceCmd = cmd.getCommand();
                }

                remoteController.send(deviceCmd);
            } else {
                logger.warn("Cannot find connection details for device id '{}'", deviceId);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:36,代码来源:OnkyoBinding.java

示例9: internalReceiveCommand

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
/**
 * @{inheritDoc
 */
@Override
protected void internalReceiveCommand(String itemName, Command command) {

	if (itemName != null) {
		OnkyoBindingProvider provider = 
			findFirstMatchingBindingProvider(itemName, command.toString());

		if (provider == null) {
			logger.warn("Doesn't find matching binding provider [itemName={}, command={}]", itemName, command);
			return;
		}

		logger.debug(
			"Received command (item='{}', state='{}', class='{}')",
			new Object[] { itemName, command.toString(), command.getClass().toString() });

		String tmp = provider.getDeviceCommand(itemName, command.toString());

		if (tmp == null) {
			tmp = provider.getDeviceCommand(itemName, WILDCARD_COMMAND_KEY);	
		}
		
		String[] commandParts = tmp.split(":");
		String deviceId = commandParts[0];
		String deviceCmd = commandParts[1];
		
		DeviceConfig device = deviceConfigCache.get(deviceId);
		OnkyoConnection remoteController = device.getConnection();

		if (device != null && remoteController != null) {
	
			if (deviceCmd.startsWith(ADVANCED_COMMAND_KEY)) {
				
				// advanced command
				
				deviceCmd = deviceCmd.replace(ADVANCED_COMMAND_KEY, "");
		
				if (deviceCmd.contains("%")) {

					// eISCP command is a template where value should be updated 
					deviceCmd = convertOpenHabCommandToDeviceCommand( command, deviceCmd);
				}
				
			} else {
				
				// normal command
				
				EiscpCommand cmd = EiscpCommand.valueOf(deviceCmd);
				deviceCmd = cmd.getCommand();
				
				if (deviceCmd.contains("%")) {

					// eISCP command is a template where value should be updated 
					deviceCmd = convertOpenHabCommandToDeviceCommand( command, deviceCmd);
				} 
			}
			
			if (deviceCmd != null) {
				remoteController.send(deviceCmd);
			} else {
				logger.warn("Cannot convert value '{}' to eISCP format", command);
			}

		} else {
			logger.warn("Cannot find connection details for device id '{}'", deviceId);
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:72,代码来源:OnkyoBinding.java

示例10: statusUpdateReceived

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
@Override
public void statusUpdateReceived(EventObject event, String ip, String data) {
	// find correct device from device cache
	DeviceConfig deviceConfig = findDevice(ip);

	if (deviceConfig != null) {
		logger.debug("Received status update '{}' from device {}", data, deviceConfig.host);

		for (OnkyoBindingProvider provider : providers) {
			for (String itemName : provider.getItemNames()) {
				// Update all items which refer to command
				HashMap<String, String> values = provider.getDeviceCommands(itemName);

				for (String cmd : values.keySet()) {
					String[] commandParts = values.get(cmd).split(":");
					String deviceCmd = commandParts[1];

					boolean match = false;
					if (deviceCmd.startsWith(ADVANCED_COMMAND_KEY)) {
						// skip advanced command key and compare 3 first character
						if (data.startsWith(deviceCmd.substring(1, 4))) {
							match = true;
						}
					} else {
						try {
							String eiscpCmd = EiscpCommand.valueOf(deviceCmd).getCommand();
							
							// compare 3 first character
							if (data.startsWith(eiscpCmd.substring(0, 3))) {
								match = true;
							}
							
						} catch (Exception e) {
							logger.error("Unregonized command '" + deviceCmd + "'", e);
						}
					}

					if (match) {
						Class<? extends Item> itemType = provider.getItemType(itemName);
						State v = convertDeviceValueToOpenHabState(itemType, data);
						eventPublisher.postUpdate(itemName, v);
						break;
					}
				}
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:49,代码来源:OnkyoBinding.java

示例11: selectInput

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
private void selectInput(int inputId) {
    sendCommand(EiscpCommand.SOURCE_SET, new DecimalType(inputId));
    currentInput = inputId;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:5,代码来源:OnkyoHandler.java

示例12: setVolume

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
@Override
public void setVolume(PercentType volume) throws IOException {
    handleVolumeSet(EiscpCommand.Zone.ZONE1, volumeLevelZone1, downScaleVolume(volume));
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:5,代码来源:OnkyoHandler.java

示例13: run

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
@Override
public void run() {
    logger.debug("Test connection to {}:{}", ip, port);
    sendCommand(new EiscpMessage.MessageBuilder().command(EiscpCommand.POWER_QUERY.getCommand())
            .value(EiscpCommand.POWER_QUERY.getValue()).build());
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:7,代码来源:OnkyoConnection.java

示例14: internalReceiveCommand

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
/**
 * @{inheritDoc
 */
@Override
protected void internalReceiveCommand(String itemName, Command command) {

    if (itemName != null) {
        OnkyoBindingProvider provider = findFirstMatchingBindingProvider(itemName, command.toString());

        if (provider == null) {
            logger.warn("Doesn't find matching binding provider [itemName={}, command={}]", itemName, command);
            return;
        }

        logger.debug("Received command (item='{}', state='{}', class='{}')",
                new Object[] { itemName, command.toString(), command.getClass().toString() });

        String tmp = provider.getDeviceCommand(itemName, command.toString());

        if (tmp == null) {
            tmp = provider.getDeviceCommand(itemName, WILDCARD_COMMAND_KEY);
        }

        String[] commandParts = tmp.split(":");
        String deviceId = commandParts[0];
        String deviceCmd = commandParts[1];

        DeviceConfig device = deviceConfigCache.get(deviceId);
        OnkyoConnection remoteController = device.getConnection();

        if (device != null && remoteController != null) {

            if (deviceCmd.startsWith(ADVANCED_COMMAND_KEY)) {

                // advanced command

                deviceCmd = deviceCmd.replace(ADVANCED_COMMAND_KEY, "");

                if (deviceCmd.contains("%")) {

                    // eISCP command is a template where value should be
                    // updated
                    deviceCmd = convertOpenHabCommandToDeviceCommand(command, deviceCmd);
                }

            } else {

                // normal command

                EiscpCommand cmd = EiscpCommand.valueOf(deviceCmd);
                deviceCmd = cmd.getCommand();

                if (deviceCmd.contains("%")) {

                    // eISCP command is a template where value should be
                    // updated
                    deviceCmd = convertOpenHabCommandToDeviceCommand(command, deviceCmd);
                }
            }

            if (deviceCmd != null) {
                remoteController.send(deviceCmd);
            } else {
                logger.warn("Cannot convert value '{}' to eISCP format", command);
            }

        } else {
            logger.warn("Cannot find connection details for device id '{}'", deviceId);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:72,代码来源:OnkyoBinding.java

示例15: statusUpdateReceived

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入依赖的package包/类
@Override
public void statusUpdateReceived(EventObject event, String iporSerialPort, String data) {
    // find correct device from device cache
    DeviceConfig deviceConfig = findDevice(iporSerialPort);

    if (deviceConfig != null) {
        logger.debug("Received status update '{}' from device {}", data,
                (deviceConfig.serialPortName != null) ? deviceConfig.serialPortName : deviceConfig.host);
        for (OnkyoBindingProvider provider : providers) {
            for (String itemName : provider.getItemNames()) {
                // Update all items which refer to command
                HashMap<String, String> values = provider.getDeviceCommands(itemName);

                for (String cmd : values.keySet()) {
                    String[] commandParts = values.get(cmd).split(":");
                    String deviceId = commandParts[0];
                    String deviceCmd = commandParts[1];

                    if (!deviceConfig.deviceId.equals(deviceId)) {
                        continue;
                    }

                    boolean match = false;

                    if (deviceCmd.startsWith(ADVANCED_COMMAND_KEY)) {
                        // skip advanced command key and compare remaining
                        // characters
                        if (data.startsWith(deviceCmd.substring(1))) {
                            match = true;
                        }
                    } else {
                        try {
                            String eiscpCmd = EiscpCommand.valueOf(deviceCmd).getCommand();

                            // compare 3 first character
                            if (data.startsWith(eiscpCmd.substring(0, 3))) {
                                match = true;
                            }
                        } catch (Exception e) {
                            logger.error("Unrecognized command ", e);
                        }
                    }

                    if (match) {
                        Class<? extends Item> itemType = provider.getItemType(itemName);
                        State v = convertDeviceValueToOpenHabState(itemType, data);
                        eventPublisher.postUpdate(itemName, v);
                        break;
                    }
                }
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:55,代码来源:OnkyoBinding.java


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