本文整理汇总了Java中org.openhab.binding.homematic.internal.model.HmInterface类的典型用法代码示例。如果您正苦于以下问题:Java HmInterface类的具体用法?Java HmInterface怎么用?Java HmInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HmInterface类属于org.openhab.binding.homematic.internal.model包,在下文中一共展示了HmInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDatapointValue
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
@Override
public void setDatapointValue(HmDatapoint dp, String datapointName, Object value) throws HomematicClientException {
HmInterface hmInterface = dp.getChannel().getDevice().getHmInterface();
if (hmInterface == HmInterface.VIRTUALDEVICES) {
String groupName = HmInterface.VIRTUALDEVICES + "." + dp.getChannel().getAddress() + "." + datapointName;
if (dp.isIntegerValue() && value instanceof Double) {
value = ((Number) value).intValue();
}
String strValue = ObjectUtils.toString(value);
if (dp.isStringValue()) {
strValue = "\"" + strValue + "\"";
}
HmResult result = sendScriptByName("setVirtualGroup", HmResult.class, new String[] { "group_name",
"group_state" }, new String[] { groupName, strValue });
if (!result.isValid()) {
throw new HomematicClientException("Unable to set CCU group " + groupName);
}
} else {
super.setDatapointValue(dp, datapointName, value);
}
}
示例2: getRssiInfo
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Map<String, HmRssiInfo> getRssiInfo(HmInterface hmInterface) throws HomematicClientException {
BinRpcRequest request = new BinRpcRequest("rssiInfo");
Map<String, HmRssiInfo> rssiList = new HashMap<String, HmRssiInfo>();
Object[] result = sendMessage(hmInterface, request);
if (result != null && result.length > 0 && result[0] instanceof Map) {
Map<String, ?> devices = (Map<String, ?>) result[0];
for (String sourceDevice : devices.keySet()) {
Map<String, Object[]> targetDevices = (Map<String, Object[]>) devices.get(sourceDevice);
for (String targetDevice : targetDevices.keySet()) {
if (targetDevice.equals(context.getServerId().getAddress())) {
Integer rssiDevice = (Integer) targetDevices.get(targetDevice)[0];
Integer rssiPeer = (Integer) targetDevices.get(targetDevice)[1];
HmRssiInfo rssiInfo = new HmRssiInfo(sourceDevice, rssiDevice, rssiPeer);
rssiList.put(rssiInfo.getAddress(), rssiInfo);
}
}
}
}
return rssiList;
}
示例3: parseDevice
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* Parses the device informations into the binding model.
*/
@SuppressWarnings("unchecked")
private HmDevice parseDevice(Map<String, ?> deviceData) throws IllegalAccessException {
HmDevice device = new HmDevice();
FieldUtils.writeField(device, "address", deviceData.get("ADDRESS"), true);
FieldUtils.writeField(device, "type", deviceData.get("TYPE"), true);
FieldUtils.writeField(device, "hmInterface", HmInterface.HOMEGEAR, true);
Object[] channelList = (Object[]) deviceData.get("CHANNELS");
for (int i = 0; i < channelList.length; i++) {
Map<String, ?> channelData = (Map<String, ?>) channelList[i];
device.addChannel(parseChannel(device, channelData));
}
return device;
}
示例4: setChannelDatapointValues
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* Sets all datapoint values for the given channel.
*/
public void setChannelDatapointValues(HmChannel channel, HmParamsetType paramsetType) throws IOException {
RpcRequest<T> request = createRpcRequest("getParamset");
request.addArg(getRpcAddress(channel.getDevice().getAddress()) + ":" + channel.getNumber());
request.addArg(paramsetType.toString());
if (channel.getDevice().getHmInterface() == HmInterface.CUXD && paramsetType == HmParamsetType.VALUES) {
setChannelDatapointValues(channel);
} else {
try {
new GetParamsetParser(channel, paramsetType).parse(sendMessage(config.getRpcPort(channel), request));
} catch (UnknownRpcFailureException ex) {
if (paramsetType == HmParamsetType.VALUES) {
logger.debug(
"RpcResponse unknown RPC failure (-1 Failure), fetching values with another API method for device: {}, channel: {}, paramset: {}",
channel.getDevice().getAddress(), channel.getNumber(), paramsetType);
setChannelDatapointValues(channel);
} else {
throw ex;
}
}
}
}
示例5: stopServers
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* Stops the Homematic RPC server.
*/
private void stopServers() {
for (HmInterface hmInterface : availableInterfaces.keySet()) {
try {
getRpcClient(hmInterface).release(hmInterface);
} catch (IOException ex) {
// recoverable exception, therefore only debug
logger.debug("Unable to release the connection to the gateway with id '{}': {}", id, ex.getMessage(),
ex);
}
}
for (TransferMode mode : rpcServers.keySet()) {
rpcServers.get(mode).shutdown();
}
rpcServers.clear();
}
示例6: setDatapointValue
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
@Override
public void setDatapointValue(HmDatapoint dp, String datapointName, Object value) throws HomematicClientException {
HmInterface hmInterface = dp.getChannel().getDevice().getHmInterface();
if (hmInterface == HmInterface.VIRTUALDEVICES) {
String groupName = HmInterface.VIRTUALDEVICES + "." + dp.getChannel().getAddress() + "." + datapointName;
if (dp.isIntegerValue() && value instanceof Double) {
value = ((Number) value).intValue();
}
String strValue = ObjectUtils.toString(value);
if (dp.isStringValue()) {
strValue = "\"" + strValue + "\"";
}
HmResult result = sendScriptByName("setVirtualGroup", HmResult.class,
new String[] { "group_name", "group_state" }, new String[] { groupName, strValue });
if (!result.isValid()) {
throw new HomematicClientException("Unable to set CCU group " + groupName);
}
} else {
super.setDatapointValue(dp, datapointName, value);
}
}
示例7: getRssiInfo
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Map<String, HmRssiInfo> getRssiInfo(HmInterface hmInterface) throws HomematicClientException {
BinRpcRequest request = new BinRpcRequest("rssiInfo");
Map<String, HmRssiInfo> rssiList = new HashMap<String, HmRssiInfo>();
Object[] result = sendMessage(hmInterface, request);
if (result != null && result.length > 0 && result[0] instanceof Map) {
Map<String, ?> devices = (Map<String, ?>) result[0];
for (String sourceDevice : devices.keySet()) {
Map<String, Object[]> targetDevices = (Map<String, Object[]>) devices.get(sourceDevice);
for (String targetDevice : targetDevices.keySet()) {
if (targetDevice.equals(context.getServerId().getAddress())) {
Integer rssiDevice = (Integer) targetDevices.get(targetDevice)[0];
Integer rssiPeer = (Integer) targetDevices.get(targetDevice)[1];
HmRssiInfo rssiInfo = new HmRssiInfo(sourceDevice, rssiDevice, rssiPeer);
rssiList.put(rssiInfo.getAddress(), rssiInfo);
}
}
}
}
return rssiList;
}
示例8: parseDevice
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* Parses the device informations into the binding model.
*/
@SuppressWarnings("unchecked")
private HmDevice parseDevice(Map<String, ?> deviceData) throws IllegalAccessException {
HmDevice device = new HmDevice();
FieldUtils.writeField(device, "address", deviceData.get("ADDRESS"), true);
FieldUtils.writeField(device, "type", deviceData.get("TYPE"), true);
FieldUtils.writeField(device, "hmInterface", HmInterface.HOMEGEAR, true);
Object[] channelList = (Object[]) deviceData.get("CHANNELS");
for (int i = 0; i < channelList.length; i++) {
Map<String, ?> channelData = (Map<String, ?>) channelList[i];
device.addChannel(parseChannel(device, channelData));
}
return device;
}
示例9: registerCallback
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void registerCallback() throws HomematicClientException {
rpcClient.init(getDefaultInterface());
rpcClient.init(HmInterface.WIRED);
rpcClient.init(HmInterface.CUXD);
}
示例10: releaseCallback
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void releaseCallback() throws HomematicClientException {
rpcClient.release(getDefaultInterface());
rpcClient.release(HmInterface.WIRED);
rpcClient.release(HmInterface.CUXD);
}
示例11: init
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void init(HmInterface hmInterface) throws HomematicClientException {
BinRpcRequest request = new BinRpcRequest("init");
request.addArg(context.getConfig().getBinRpcCallbackUrl());
request.addArg(hmInterface.toString());
sendMessage(hmInterface, request);
}
示例12: release
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void release(HmInterface hmInterface) throws HomematicClientException {
BinRpcRequest request = new BinRpcRequest("init");
request.addArg(context.getConfig().getBinRpcCallbackUrl());
sendMessage(hmInterface, request);
}
示例13: getAllSystemVariables
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Map<String, ?> getAllSystemVariables(HmInterface hmInterface) throws HomematicClientException {
BinRpcRequest request = new BinRpcRequest("getAllSystemVariables");
return (Map<String, ?>) sendMessage(hmInterface, request)[0];
}
示例14: getDeviceDescription
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Map<String, String> getDeviceDescription(HmInterface hmInterface, String address)
throws HomematicClientException {
BinRpcRequest request = new BinRpcRequest("getDeviceDescription");
request.addArg(address);
Object[] result = sendMessage(hmInterface, request);
if (result != null && result.length > 0 && result[0] instanceof Map) {
return (Map<String, String>) result[0];
}
return null;
}
示例15: getServerId
import org.openhab.binding.homematic.internal.model.HmInterface; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ServerId getServerId(HmInterface hmInterface) throws HomematicClientException {
Map<String, String> deviceDescription = getDeviceDescription(hmInterface, "BidCoS-RF");
ServerId serverId = new ServerId(deviceDescription.get("TYPE"));
serverId.setVersion(deviceDescription.get("FIRMWARE"));
serverId.setAddress(deviceDescription.get("INTERFACE"));
return serverId;
}