本文整理汇总了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);
}
}
}
}
示例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");
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}