本文整理汇总了Java中org.openhab.core.types.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于org.openhab.core.types包,在下文中一共展示了Command类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: receiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* <p>Iterates through all registered {@link AutoUpdateBindingProvider}s and
* checks whether an autoupdate configuration is available for <code>itemName</code>.</p>
*
* <p>If there are more then one {@link AutoUpdateBindingProvider}s providing
* a configuration the results are combined by a logical <em>OR</em>. If no
* configuration is provided at all the autoupdate defaults to <code>true</code>
* and an update is posted for the corresponding {@link State}.</p>
*
* @param itemName the item for which to find an autoupdate configuration
* @param command the command being received and posted as {@link State}
* update if <code>command</code> is instance of {@link State} as well.
*/
@Override
public void receiveCommand(String itemName, Command command) {
Boolean autoUpdate = null;
for (AutoUpdateBindingProvider provider : providers) {
Boolean au = provider.autoUpdate(itemName);
if (au != null) {
autoUpdate = au;
if (Boolean.TRUE.equals(autoUpdate)) {
break;
}
}
}
// we didn't find any autoupdate configuration, so apply the default now
if (autoUpdate == null) {
autoUpdate = Boolean.TRUE;
}
if (autoUpdate && command instanceof State) {
postUpdate(itemName, (State) command);
} else {
logger.trace("Won't update item '{}' as it is not configured to update its state automatically.", itemName);
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:38,代码来源:AutoUpdateBinding.java
示例2: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* Handles a command update by sending the appropriate Z-Wave instructions
* to the controller.
* {@inheritDoc}
*/
@Override
protected void internalReceiveCommand(String itemName, Command command) {
boolean handled = false;
// if we are not yet initialized, don't waste time and return
if(this.isProperlyConfigured() == false) {
logger.debug("internalReceiveCommand Called, But Not Properly Configure yet, returning.");
return;
}
logger.trace("internalReceiveCommand(itemname = {}, Command = {})", itemName, command.toString());
for (ZWaveBindingProvider provider : providers) {
if (!provider.providesBindingFor(itemName)) {
continue;
}
converterHandler.receiveCommand(provider, itemName, command);
handled = true;
}
if (!handled) {
logger.warn("No converter found for item = {}, command = {}, ignoring.", itemName, command.toString());
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:31,代码来源:ZWaveActiveBinding.java
示例3: parseBuffer
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
*
* Main function to parse ASCII string received
* @return
*
*/
@Override
protected void parseBuffer(String itemName, Command aCommand, Direction theDirection,ByteBuffer byteBuffer){
String theUpdate = "";
try {
theUpdate = new String(byteBuffer.array(), charset).split("\0")[0];
} catch (UnsupportedEncodingException e) {
logger.warn("Exception while attempting an unsupported encoding scheme");
}
ProtocolBindingProvider provider = findFirstMatchingBindingProvider(itemName);
List<Class<? extends State>> stateTypeList = provider.getAcceptedDataTypes(itemName,aCommand);
String transformedResponse = transformResponse(provider.getProtocolCommand(itemName, aCommand),theUpdate);
State newState = createStateFromString(stateTypeList,transformedResponse);
if(newState != null) {
eventPublisher.postUpdate(itemName, newState);
} else {
logger.warn("Can not parse input "+theUpdate+" to match command {} on item {} ",aCommand,itemName);
}
}
开发者ID:Neulinet,项目名称:Zoo,代码行数:30,代码来源:TCPBinding.java
示例4: getQualifiedCommands
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<Command> getQualifiedCommands(String itemName,Command command){
List<Command> commands = new ArrayList<Command>();
ProtocolBindingConfig aConfig = (ProtocolBindingConfig) bindingConfigs.get(itemName);
for(Command aCommand : aConfig.keySet()) {
if(aCommand == command) {
commands.add(aCommand);
} else {
if(aCommand instanceof DecimalType) {
commands.add(aCommand);
}
}
}
return commands;
}
开发者ID:Neulinet,项目名称:Zoo,代码行数:19,代码来源:ProtocolGenericBindingProvider.java
示例5: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
@Override
public void internalReceiveCommand(String itemName, Command command) {
if (password != null && !password.isEmpty()) {
String type = null;
for (FritzboxBindingProvider provider : providers) {
type = provider.getType(itemName);
if (type != null) {
break;
}
}
logger.info("Fritzbox type: {}", type);
if (type == null)
return;
TelnetCommandThread thread = new TelnetCommandThread(type, command);
thread.start();
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:23,代码来源:FritzboxBinding.java
示例6: findFirstMatchingBindingProvider
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* Find the first matching {@link ChannelBindingProvider}
* according to <code>itemName</code>
*
* @param itemName
*
* @return the matching binding provider or <code>null</code> if no binding
* provider could be found
*/
protected P findFirstMatchingBindingProvider(String itemName) {
P firstMatchingProvider = null;
for (P provider : this.providers) {
if(!useAddressMask) {
List<InetSocketAddress> socketAddresses = provider
.getInetSocketAddresses(itemName);
if (socketAddresses != null && socketAddresses.size() > 0) {
firstMatchingProvider = provider;
break;
}
} else {
List<Command> commands = provider.getAllCommands(itemName);
if (commands != null && commands.size() > 0) {
firstMatchingProvider = provider;
break;
}
}
}
return firstMatchingProvider;
}
开发者ID:Neulinet,项目名称:Zoo,代码行数:30,代码来源:AbstractSocketChannelBinding.java
示例7: getItemNames
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Collection<String> getItemNames(String host, int port) {
List<String> items = new ArrayList<String>();
for (String itemName : bindingConfigs.keySet()) {
IRtransBindingConfig aConfig = (IRtransBindingConfig) bindingConfigs.get(itemName);
for(Command aCommand : aConfig.keySet()) {
IRtransBindingConfigElement anElement = (IRtransBindingConfigElement) aConfig.get(aCommand);
if(anElement.getHost().equals(host) && anElement.getPort()==Integer.toString(port)) {
if(!items.contains(itemName)) {
items.add(itemName);
}
}
}
}
return items;
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:22,代码来源:IRtransGenericBindingProvider.java
示例8: get
import org.openhab.core.types.Command; //导入依赖的package包/类
public Channel get(String item, Command command, Direction direction, String host, String port) {
synchronized(this) {
Iterator<C> it = iterator();
while(it.hasNext()) {
C aChannel = it.next();
if(item.equals(aChannel.item) && command.equals(aChannel.command) && direction.equals(aChannel.direction)) {
if(aChannel.host.equals(host) && aChannel.port.equals(port)) {
return aChannel;
}
}
}
return null;
}
}
开发者ID:Neulinet,项目名称:Zoo,代码行数:17,代码来源:AbstractDatagramChannelBinding.java
示例9: mapCommandToItemType
import org.openhab.core.types.Command; //导入依赖的package包/类
private Class<? extends Item> mapCommandToItemType(Command command) {
if (command instanceof IncreaseDecreaseType) {
return DimmerItem.class;
} else if (command instanceof PercentType) {
return DimmerItem.class;
} else if (command instanceof DecimalType) {
return NumberItem.class;
} else if (command instanceof OnOffType) {
return SwitchItem.class;
} else if (command instanceof StringType) {
return StringItem.class;
} else {
logger.warn(
"No explicit mapping found for command type '{}' - return StringItem.class instead",
command.getClass().getSimpleName());
return StringItem.class;
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:19,代码来源:PulseaudioBinding.java
示例10: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* @{inheritDoc}
*/
@Override
protected void internalReceiveCommand(String itemName, Command command) {
logger.trace("Received command for item '{}' with command '{}'",itemName, command);
for (FreeswitchBindingProvider provider : providers) {
FreeswitchBindingConfig config = provider.getFreeswitchBindingConfig(itemName);
switch(config.getType()){
case CMD_API:{
if (!(command instanceof StringType)){
logger.warn("could not process command '{}' for item '{}': command is not a StringType", command, itemName);
return;
}
String str = ((StringType) command).toString().toLowerCase();
String response = executeApiCommand(str);
eventPublisher.postUpdate(itemName, new StringType(response));
}
break;
default:
break;
}
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:27,代码来源:FreeswitchBinding.java
示例11: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* @{inheritDoc}
*/
@Override
protected void internalReceiveCommand(String itemName, Command command) {
logger.debug("internalReceiveCommand() is called!");
for (WemoBindingProvider provider : providers) {
try {
String udn = provider.getUDN(itemName);
logger.trace("item '{}' has UDN '{}'",itemName, udn);
logger.trace("Command '{}' is about to be send to item '{}'",command, itemName );
sendCommand(itemName, command);
} catch (Exception e) {
logger.error("Failed to send {} command", command, e);
}
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:21,代码来源:WemoBinding.java
示例12: parseIRDBMessage
import org.openhab.core.types.Command; //导入依赖的package包/类
protected void parseIRDBMessage(String itemName,String message, Command ohCommand){
Pattern IRDB_PATTERN = Pattern.compile("RCV_COM (.*),(.*),(.*),(.*)");
Matcher matcher = IRDB_PATTERN.matcher(message);
if(matcher.matches()) {
IrCommand theCommand = new IrCommand();
theCommand.remote = matcher.group(1);
theCommand.command = matcher.group(2);
parseDecodedCommand(itemName,theCommand,ohCommand);
} else {
logger.error("{} does not match the IRDB IRtrans message format ({})",message,matcher.pattern());
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:18,代码来源:IRtransBinding.java
示例13: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* @{inheritDoc
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void internalReceiveCommand(String itemName, Command command) {
if (configAdmin != null) {
for (ConfigAdminBindingProvider provider : this.providers) {
ConfigAdminBindingConfig bindingConfig = provider.getBindingConfig(itemName);
Configuration config = getConfiguration(bindingConfig);
if (config != null) {
Dictionary props = config.getProperties();
props.put(bindingConfig.configParameter, command.toString());
try {
config.update(props);
} catch (IOException ioe) {
logger.error("updating Configuration '{}' with '{}' failed", bindingConfig.normalizedPid,
command.toString());
}
logger.debug("successfully updated configuration (pid={}, value={})", bindingConfig.normalizedPid,
command.toString());
} else {
logger.info("There is no configuration found for pid '{}'", bindingConfig.normalizedPid);
}
}
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:28,代码来源:ConfigAdminBinding.java
示例14: receiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void receiveCommand(Item item, Command command, ZWaveNode node,
ZWaveBinarySwitchCommandClass commandClass, int endpointId, Map<String,String> arguments) {
ZWaveCommandConverter<?,?> converter = this.getCommandConverter(command.getClass());
if (converter == null) {
logger.warn("NODE {}: No converter found for item = {}, endpoint = {}, ignoring command.", node.getNodeId(), item.getName(), endpointId);
return;
}
SerialMessage serialMessage = node.encapsulate(commandClass.setValueMessage((Integer)converter.convertFromCommandToValue(item, command)), commandClass, endpointId);
if (serialMessage == null) {
logger.warn("NODE {}: Generating message failed for command class = {}, endpoint = {}", node.getNodeId(), commandClass.getCommandClass().getLabel(), endpointId);
return;
}
this.getController().sendData(serialMessage);
if (command instanceof State) {
this.getEventPublisher().postUpdate(item.getName(), (State)command);
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:27,代码来源:ZWaveBinarySwitchConverter.java
示例15: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* @{inheritDoc}
*/
@Override
protected void internalReceiveCommand(String itemName, Command command) {
// the code being executed when a command was sent on the openHAB
// event bus goes here. This method is only called if one of the
// BindingProviders provide a binding for the given 'itemName'.
if (logger.isDebugEnabled()) {
logger.debug("internalReceiveCommand({},{}) is called!", itemName, command);
}
SimaticBindingConfig config = items.get(itemName);
if (config != null) {
SimaticGenericDevice device = devices.get(config.device);
if (device != null) {
try {
device.sendData(itemName, command, config);
} catch (Exception ex) {
logger.error("internalReceiveCommand(): line:" + ex.getStackTrace()[0].getLineNumber() + "|method:"
+ ex.getStackTrace()[0].getMethodName());
}
} else {
logger.warn("No device for item: {}", itemName);
}
} else {
logger.warn("No config for item: {}", itemName);
}
}
开发者ID:docbender,项目名称:openHAB-Simatic,代码行数:32,代码来源:SimaticBinding.java
示例16: parseOutBindingConfig
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* Parses a http-out configuration by using the regular expression
* <code>(.*?):([A-Z]*):(.*)</code>. Where the groups should contain the
* following content:
* <ul>
* <li>1 - command</li>
* <li>2 - http method</li>
* <li>3 - url</li>
* </ul>
* @param item
*
* @param bindingConfig the config string to parse
* @param config
* @return the filled {@link HttpBindingConfig}
*
* @throws BindingConfigParseException if the regular expression doesn't match
* the given <code>bindingConfig</code>
*/
protected HttpBindingConfig parseOutBindingConfig(Item item, String bindingConfig, HttpBindingConfig config) throws BindingConfigParseException {
Matcher matcher = OUT_BINDING_PATTERN.matcher(bindingConfig);
if (!matcher.matches()) {
throw new BindingConfigParseException("bindingConfig '" + bindingConfig + "' doesn't contain a valid out-binding-configuration. A valid configuration is matched by the RegExp '(.*?):?([A-Z]*):(.*)'");
}
matcher.reset();
HttpBindingConfigElement configElement;
while (matcher.find()) {
configElement = new HttpBindingConfigElement();
Command command = createCommandFromString(item, matcher.group(1));
configElement.httpMethod = matcher.group(2);
String lastPart = matcher.group(3).replaceAll("\\\\\"", "");
if(lastPart.trim().endsWith("}") && lastPart.contains("{")){
int beginIdx = lastPart.lastIndexOf("{");
int endIdx = lastPart.lastIndexOf("}");
configElement.url = lastPart.substring(0,beginIdx);
configElement.headers = parseHttpHeaders(lastPart.substring(beginIdx+1,endIdx));
} else{
configElement.url = lastPart;
}
config.put(command, configElement);
}
return config;
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:49,代码来源:HttpGenericBindingProvider.java
示例17: sendCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
@Override
public void sendCommand(String itemName, Command command) {
try {
Item item = itemRegistry.getItem(itemName);
org.eclipse.smarthome.core.types.Command eshCommand = TypeParser.parseCommand(item.getAcceptedCommandTypes(), command.toString());
eventPublisher.sendCommand(itemName, eshCommand);
} catch (ItemNotFoundException e) {
logger.warn("Could not process command event '{}' as item '{}' is unknown", command.toString(), itemName);
}
}
开发者ID:Neulinet,项目名称:Zoo,代码行数:11,代码来源:EventPublisherDelegate.java
示例18: receiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* Sends the WoL packet when there is a {@link WolBindingConfig} for
* <code>itemName</code> and <code>command</code> is of type
* {@link OnOffType}.ON
*/
@Override
public void receiveCommand(String itemName, Command command) {
if (itemMap.keySet().contains(itemName)) {
if (OnOffType.ON.equals(command)) {
sendWolPacket(itemMap.get(itemName));
}
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:14,代码来源:WolBinding.java
示例19: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
@Override
protected void internalReceiveCommand(String itemName, Command command) {
// the code being executed when a command was sent on the openHAB
// event bus goes here. This method is only called if one of the
// BindingProviders provide a binding for the given 'itemName'.
logger.debug("internalReceiveCommand() is called!");
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:8,代码来源:HMSBinding.java
示例20: internalReceiveCommand
import org.openhab.core.types.Command; //导入依赖的package包/类
/**
* Inherited from AbstractBinding. This method is invoked by the framework whenever
* a command is coming from openhab, i.e. a switch is flipped via the GUI or other
* controls. The binding translates this openhab command into a message to the modem.
* {@inheritDoc}
*/
@Override
public void internalReceiveCommand(String itemName, Command command) {
logger.info("Item: {} got command {}", itemName, command);
if(!(isProperlyConfigured() && m_isActive)) {
logger.debug("not ready to handle commands yet, returning.");
return;
}
boolean commandHandled = false;
for (InsteonPLMBindingProvider provider : providers) {
if (provider.providesBindingFor(itemName)) {
commandHandled = true;
InsteonPLMBindingConfig c = provider.getInsteonPLMBindingConfig(itemName);
if (c == null) {
logger.warn("could not find config for item {}", itemName);
} else {
sendCommand(c, command);
}
}
}
if (!commandHandled)
logger.warn("No converter found for item = {}, command = {}, ignoring.",
itemName, command.toString());
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:33,代码来源:InsteonPLMActiveBinding.java
注:本文中的org.openhab.core.types.Command类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论