本文整理汇总了Java中org.openhab.binding.tcp.Direction类的典型用法代码示例。如果您正苦于以下问题:Java Direction类的具体用法?Java Direction怎么用?Java Direction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Direction类属于org.openhab.binding.tcp包,在下文中一共展示了Direction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseBuffer
import org.openhab.binding.tcp.Direction; //导入依赖的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);
} 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);
}
}
示例2: parseBuffer
import org.openhab.binding.tcp.Direction; //导入依赖的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);
}
}
示例3: parseBuffer
import org.openhab.binding.tcp.Direction; //导入依赖的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);
}
}
示例4: ProtocolBindingConfigElement
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
public ProtocolBindingConfigElement(String host, String port, Direction direction, String networkCommand,List<Class<? extends State>> acceptedTypes) {
this.host = host;
this.port = port;
this.direction = direction;
this.networkCommand = networkCommand;
this.acceptedTypes = acceptedTypes;
}
示例5: parseBuffer
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* Main method to parse ASCII string received from the IR Transceiver.
*
* @param qualifiedItems
* the qualified items, e.g. only those items that have the host:port combination
* in its binding configuration string will "receive" the ASCII string from the
* IRTrans device with host:port
* @param byteBuffer
* the byte buffer
*/
@Override
protected void parseBuffer(String itemName, Command aCommand, Direction theDirection,ByteBuffer byteBuffer){
String message = stripByteCount(byteBuffer);
if(message != null) {
// IRTrans devices return "RESULT OK" when it succeeds to emit an infrared sequence
if(message.contains("RESULT OK")){
parseOKMessage(itemName,message);
}
// IRTrans devices return a string starting with RCV_HEX each time it captures an
// infrared sequence from a remote control
if(message.contains("RCV_HEX")){
parseHexMessage(itemName,message, aCommand);
}
// IRTrans devices return a string starting with RCV_COM each time it captures an
// infrared sequence from a remote control that is stored in the device's internal dB
if(message.contains("RCV_COM")){
parseIRDBMessage(itemName,message, aCommand);
}
} else {
logger.warn("Received some non-compliant garbage ({})- Parsing is skipped",byteBuffer.toString());
}
}
示例6: parseBuffer
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* Main method to parse ASCII string received from the IR Transceiver.
*
* @param qualifiedItems
* the qualified items, e.g. only those items that have the host:port combination
* in its binding configuration string will "receive" the ASCII string from the
* IRTrans device with host:port
* @param byteBuffer
* the byte buffer
*/
@Override
protected void parseBuffer(String itemName, Command aCommand, Direction theDirection, ByteBuffer byteBuffer) {
String message = stripByteCount(byteBuffer);
if (message != null) {
// IRTrans devices return "RESULT OK" when it succeeds to emit an infrared sequence
if (message.contains("RESULT OK")) {
parseOKMessage(itemName, message);
}
// IRTrans devices return a string starting with RCV_HEX each time it captures an
// infrared sequence from a remote control
if (message.contains("RCV_HEX")) {
parseHexMessage(itemName, message, aCommand);
}
// IRTrans devices return a string starting with RCV_COM each time it captures an
// infrared sequence from a remote control that is stored in the device's internal dB
if (message.contains("RCV_COM")) {
parseIRDBMessage(itemName, message, aCommand);
}
} else {
logger.warn("Received some non-compliant garbage ({})- Parsing is skipped", byteBuffer.toString());
}
}
示例7: parseBuffer
import org.openhab.binding.tcp.Direction; //导入依赖的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);
logger.debug("parseBuffer constructed update: '{}'", theUpdate);
} catch (UnsupportedEncodingException e) {
logger.warn("Exception while attempting an unsupported encoding scheme");
}
ProtocolBindingProvider provider = findFirstMatchingBindingProvider(itemName);
if (provider == null) {
logger.warn("No provider could be found for the item '{}'", itemName);
return;
}
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("Cannot parse input {} to match command {} on item {}", theUpdate, aCommand, itemName);
}
}
示例8: ProtocolBindingConfigElement
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
public ProtocolBindingConfigElement(String host, String port, Direction direction, String networkCommand,
List<Class<? extends State>> acceptedTypes) {
this.host = host;
this.port = port;
this.direction = direction;
this.networkCommand = networkCommand;
this.acceptedTypes = acceptedTypes;
}
示例9: parseBindingConfig
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* Parses the configuration string and update the provided config
*
* @param config - the Configuration that needs to be updated with the parsing results
* @param item - the Item that this configuration is intented for
* @param bindingConfig - the configuration string that will be parsed
* @throws BindingConfigParseException
*/
private void parseBindingConfig(ProtocolBindingConfig config,Item item,
String bindingConfig) throws BindingConfigParseException {
String direction = null;
Direction directionType = null;
String commandAsString = null;
String host = null;
String port = null;
String protocolCommand = null;
if(bindingConfig != null){
Matcher actionMatcher = ACTION_CONFIG_PATTERN.matcher(bindingConfig);
Matcher statusMatcher = STATUS_CONFIG_PATTERN.matcher(bindingConfig);
if ((!actionMatcher.matches() && !statusMatcher.matches())) {
throw new BindingConfigParseException(getBindingType()+
" binding configuration must consist of four [config="+statusMatcher+"] or five parts [config="
+ actionMatcher + "]");
} else {
if(actionMatcher.matches()) {
direction = actionMatcher.group(1);
commandAsString = actionMatcher.group(2);
host = actionMatcher.group(3);
port = actionMatcher.group(4);
protocolCommand = actionMatcher.group(5);
} else if (statusMatcher.matches()) {
direction = statusMatcher.group(1);
commandAsString = null;
host = statusMatcher.group(2);
port = statusMatcher.group(3);
protocolCommand = statusMatcher.group(4);
}
if (direction.equals(">")){
directionType = Direction.OUT;
} else if (direction.equals("<")){
directionType = Direction.IN;
}
ProtocolBindingConfigElement newElement = new ProtocolBindingConfigElement(host,port,directionType,protocolCommand,item.getAcceptedDataTypes());
Command command = null;
if(commandAsString == null) {
// for those configuration strings that are not really linked to a openHAB command we
// create a dummy Command to be able to store the configuration information
// I have choosen to do that with NumberItems
NumberItem dummy = new NumberItem(Integer.toString(counter));
command = createCommandFromString(dummy,Integer.toString(counter));
counter++;
} else {
command = createCommandFromString(item, commandAsString);
}
config.put(command, newElement);
}
}
else
{
return;
}
}
示例10: getDirection
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Direction getDirection(String itemName, Command command) {
ProtocolBindingConfig config = (ProtocolBindingConfig) bindingConfigs.get(itemName);
return config != null && config.get(command) != null ? config.get(command).getDirection() : null;
}
示例11: getDirection
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Direction getDirection(String itemName, Command command) {
// the IRtrans binding will only establish outbound connections to the remote IRtrans device
return Direction.OUT;
}
示例12: getDirection
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Direction getDirection(String itemName, Command command) {
// the IRtrans binding will only establish outbound connections to the remote IRtrans device
return Direction.OUT;
}
示例13: getDirection
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
@Override
public Direction getDirection(String itemName, Command command);
示例14: parseBindingConfig
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* Parses the configuration string and update the provided config
*
* @param config - the Configuration that needs to be updated with the parsing results
* @param item - the Item that this configuration is intented for
* @param bindingConfig - the configuration string that will be parsed
* @throws BindingConfigParseException
*/
private void parseBindingConfig(ProtocolBindingConfig config, Item item, String bindingConfig)
throws BindingConfigParseException {
String direction = null;
Direction directionType = null;
String commandAsString = null;
String host = null;
String port = null;
String protocolCommand = null;
if (bindingConfig != null) {
Matcher actionMatcher = ACTION_CONFIG_PATTERN.matcher(bindingConfig);
Matcher statusMatcher = STATUS_CONFIG_PATTERN.matcher(bindingConfig);
if ((!actionMatcher.matches() && !statusMatcher.matches())) {
throw new BindingConfigParseException(
getBindingType() + " binding configuration must consist of four [config=" + statusMatcher
+ "] or five parts [config=" + actionMatcher + "]");
} else {
if (actionMatcher.matches()) {
direction = actionMatcher.group(1);
commandAsString = actionMatcher.group(2);
host = actionMatcher.group(3);
port = actionMatcher.group(4);
protocolCommand = actionMatcher.group(5) != null ? actionMatcher.group(5) : actionMatcher.group(6);
} else if (statusMatcher.matches()) {
direction = statusMatcher.group(1);
commandAsString = null;
host = statusMatcher.group(2);
port = statusMatcher.group(3);
protocolCommand = statusMatcher.group(4) != null ? statusMatcher.group(4) : statusMatcher.group(5);
}
if (direction.equals(">")) {
directionType = Direction.OUT;
} else if (direction.equals("<")) {
directionType = Direction.IN;
}
ProtocolBindingConfigElement newElement = new ProtocolBindingConfigElement(host, port, directionType,
protocolCommand, item.getAcceptedDataTypes());
Command command = null;
if (commandAsString == null) {
// for those configuration strings that are not really linked to a openHAB command we
// create a dummy Command to be able to store the configuration information
// I have choosen to do that with NumberItems
NumberItem dummy = new NumberItem(Integer.toString(counter));
command = createCommandFromString(dummy, Integer.toString(counter));
counter++;
} else {
command = createCommandFromString(item, commandAsString);
}
config.put(command, newElement);
}
} else {
return;
}
}
示例15: getDirection
import org.openhab.binding.tcp.Direction; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Direction getDirection(String itemName, Command command) {
ProtocolBindingConfig config = (ProtocolBindingConfig) bindingConfigs.get(itemName);
return config != null && config.get(command) != null ? config.get(command).getDirection() : null;
}