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


Java EiscpCommand.getCommand方法代码示例

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


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

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

示例2: sendCommand

import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand; //导入方法依赖的package包/类
private void sendCommand(EiscpCommand deviceCommand, Command command) {
    if (connection != null) {

        final String cmd = deviceCommand.getCommand();
        String valTemplate = deviceCommand.getValue();
        String val;

        if (command instanceof OnOffType) {
            val = String.format(valTemplate, command == OnOffType.ON ? 1 : 0);

        } else if (command instanceof StringType) {
            val = String.format(valTemplate, command);

        } else if (command instanceof DecimalType) {
            val = String.format(valTemplate, ((DecimalType) command).intValue());

        } else if (command instanceof PercentType) {
            val = String.format(valTemplate, ((DecimalType) command).intValue());
        } else {
            val = valTemplate;
        }

        logger.debug("Sending command '{}' with value '{}' to Onkyo Receiver @{}", cmd, val,
                connection.getConnectionName());
        connection.send(cmd, val);
    } else {
        logger.debug("Connect send command to onkyo receiver since the onkyo binding is not initialized");
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:30,代码来源:OnkyoHandler.java

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

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

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


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