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


Java HmDevice类代码示例

本文整理汇总了Java中org.openhab.binding.homematic.internal.model.HmDevice的典型用法代码示例。如果您正苦于以下问题:Java HmDevice类的具体用法?Java HmDevice怎么用?Java HmDevice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HmDevice类属于org.openhab.binding.homematic.internal.model包,在下文中一共展示了HmDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: iterateAllDatapoints

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void iterateAllDatapoints(HmValueItemIteratorCallback callback) throws HomematicClientException {
	Object[] result = rpcClient.getAllValues(getDefaultInterface());

	try {
		for (int i = 0; i < result.length; i++) {
			@SuppressWarnings("unchecked")
			Map<String, ?> entryMap = (Map<String, ?>) result[i];
			HmDevice device = parseDevice(entryMap);
			addBatteryInfo(device);
			logger.trace("{}", device);

			for (HmChannel channel : device.getChannels()) {
				for (HmDatapoint dp : channel.getDatapoints()) {
					logger.trace("  {}", dp.toDumpString());
					DatapointConfig bindingConfig = new DatapointConfig(device.getAddress(), channel.getNumber(),
							dp.getName());
					callback.iterate(bindingConfig, dp);
				}
			}
		}
	} catch (Exception ex) {
		throw new HomematicClientException(ex.getMessage(), ex);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:29,代码来源:HomegearClient.java

示例2: parseDevice

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的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;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:20,代码来源:HomegearClient.java

示例3: addBatteryInfo

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * Adds the battery info datapoint to the specified device if the device has
 * batteries.
 */
protected void addBatteryInfo(HmDevice device) throws HomematicClientException {
	HmBattery battery = HmBatteryTypeProvider.getBatteryType(device.getType());
	if (battery != null) {
		for (HmChannel channel : device.getChannels()) {
			if ("0".equals(channel.getNumber())) {
				try {
					logger.debug("Adding battery type to device {}: {}", device.getType(), battery.getInfo());
					HmDatapoint dp = new HmDatapoint();
					FieldUtils.writeField(dp, "name", "BATTERY_TYPE", true);
					FieldUtils.writeField(dp, "writeable", Boolean.FALSE, true);
					FieldUtils.writeField(dp, "valueType", 20, true);
					dp.setValue(battery.getInfo());
					channel.addDatapoint(dp);
				} catch (IllegalAccessException ex) {
					throw new HomematicClientException(ex.getMessage(), ex);
				}
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:25,代码来源:BaseHomematicClient.java

示例4: updateStatus

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * Updates the thing status based on device status.
 */
private void updateStatus(HmDevice device) throws BridgeHandlerNotAvailableException, IOException {
    loadHomematicChannelValues(device.getChannel(0));

    ThingStatus oldStatus = thing.getStatus();
    ThingStatus newStatus = ThingStatus.ONLINE;
    ThingStatusDetail newDetail = ThingStatusDetail.NONE;

    if (device.isFirmwareUpdating()) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.FIRMWARE_UPDATING;
    } else if (device.isUnreach()) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.COMMUNICATION_ERROR;
    } else if (device.isConfigPending() || device.isUpdatePending()) {
        newDetail = ThingStatusDetail.CONFIGURATION_PENDING;
    }

    if (thing.getStatus() != newStatus || thing.getStatusInfo().getStatusDetail() != newDetail) {
        updateStatus(newStatus, newDetail);
    }
    if (oldStatus == ThingStatus.OFFLINE && newStatus == ThingStatus.ONLINE) {
        initialize();
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:28,代码来源:HomematicThingHandler.java

示例5: parse

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
@Override
public HmDatapointInfo parse(Object[] message) throws IOException {
    String address;
    Integer channel = 0;
    String addressWithChannel = toString(message[1]);
    if ("".equals(addressWithChannel)) {
        address = HmDevice.ADDRESS_GATEWAY_EXTRAS;
        channel = HmChannel.CHANNEL_NUMBER_VARIABLE;
    } else {
        String[] configParts = StringUtils.trimToEmpty(addressWithChannel).split(":");
        address = getAddress(configParts[0]);
        if (configParts.length > 1) {
            channel = NumberUtils.createInteger(configParts[1]);
        }
    }

    String name = toString(message[2]);
    value = message[3];

    return new HmDatapointInfo(address, HmParamsetType.VALUES, channel, name);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:22,代码来源:EventParser.java

示例6: initialize

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
@Override
public void initialize(HmDevice device) {
    for (HmChannel channel : device.getChannels()) {
        HmDatapointInfo dpInfoOnTime = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_ON_TIME);
        if (channel.hasDatapoint(dpInfoOnTime)) {
            HmDatapointInfo dpInfoLevel = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_LEVEL);
            HmDatapointInfo dpInfoState = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_STATE);
            if (channel.hasDatapoint(dpInfoLevel) || channel.hasDatapoint(dpInfoState)) {
                HmDatapoint dpOnTime = channel.getDatapoint(dpInfoOnTime);
                HmDatapoint dpOnTimeAutomatic = dpOnTime.clone();
                dpOnTimeAutomatic.setName(getName());
                dpOnTimeAutomatic.setDescription(getName());
                addDatapoint(channel, dpOnTimeAutomatic);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:18,代码来源:OnTimeAutomaticVirtualDatapointHandler.java

示例7: newDevices

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
@Override
public void newDevices(List<String> adresses) {
    if (initialized) {
        for (String address : adresses) {
            try {
                logger.debug("New device '{}' detected on gateway with id '{}'", address, id);
                List<HmDevice> deviceDescriptions = getDeviceDescriptions();
                for (HmDevice device : deviceDescriptions) {
                    if (device.getAddress().equals(address)) {
                        for (HmChannel channel : device.getChannels()) {
                            addChannelDatapoints(channel, HmParamsetType.MASTER);
                            addChannelDatapoints(channel, HmParamsetType.VALUES);
                        }
                        prepareDevice(device);
                        gatewayAdapter.onNewDevice(device);
                    }
                }
            } catch (Exception ex) {
                logger.error("{}", ex.getMessage(), ex);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:24,代码来源:AbstractHomematicGateway.java

示例8: prepareDevice

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * Adds virtual datapoints to the device.
 */
private void prepareDevice(HmDevice device) {
    for (VirtualDatapointHandler vdph : virtualDatapointHandlers) {
        vdph.initialize(device);

    }
    devices.put(device.getAddress(), device);
    logger.debug("Loaded device '{}' ({}) with {} datapoints", device.getAddress(), device.getType(),
            device.getDatapointCount());

    if (logger.isTraceEnabled()) {
        logger.trace("{}", device);
        for (HmChannel channel : device.getChannels()) {
            logger.trace("  {}", channel);
            for (HmDatapoint dp : channel.getDatapoints()) {
                logger.trace("    {}", dp);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:23,代码来源:AbstractHomematicGateway.java

示例9: getDeviceName

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * Returns the device name for the given device type.
 */
public static String getDeviceName(HmDevice device) {
    if (device.isGatewayExtras()) {
        return getDescription(HmDevice.TYPE_GATEWAY_EXTRAS);
    }

    String deviceDescription = null;
    boolean isTeam = device.getType().endsWith("-Team");
    String type = isTeam ? StringUtils.remove(device.getType(), "-Team") : device.getType();
    deviceDescription = getDescription(type);

    if (deviceDescription != null && isTeam) {
        deviceDescription += " Team";
    }

    return deviceDescription == null ? "No Description" : deviceDescription;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:20,代码来源:MetadataUtils.java

示例10: iterateAllDatapoints

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void iterateAllDatapoints(HmValueItemIteratorCallback callback) throws HomematicClientException {
    Object[] result = rpcClient.getAllValues(getDefaultInterface());

    try {
        for (int i = 0; i < result.length; i++) {
            @SuppressWarnings("unchecked")
            Map<String, ?> entryMap = (Map<String, ?>) result[i];
            HmDevice device = parseDevice(entryMap);
            addBatteryInfo(device);
            logger.trace("{}", device);

            for (HmChannel channel : device.getChannels()) {
                for (HmDatapoint dp : channel.getDatapoints()) {
                    logger.trace("  {}", dp.toDumpString());
                    DatapointConfig bindingConfig = new DatapointConfig(device.getAddress(), channel.getNumber(),
                            dp.getName());
                    callback.iterate(bindingConfig, dp);
                }
            }
        }
    } catch (Exception ex) {
        throw new HomematicClientException(ex.getMessage(), ex);
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:29,代码来源:HomegearClient.java

示例11: parseDevice

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的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;
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:20,代码来源:HomegearClient.java

示例12: addBatteryInfo

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * Adds the battery info datapoint to the specified device if the device has
 * batteries.
 */
protected void addBatteryInfo(HmDevice device) throws HomematicClientException {
    HmBattery battery = HmBatteryTypeProvider.getBatteryType(device.getType());
    if (battery != null) {
        for (HmChannel channel : device.getChannels()) {
            if ("0".equals(channel.getNumber())) {
                try {
                    logger.debug("Adding battery type to device {}: {}", device.getType(), battery.getInfo());
                    HmDatapoint dp = new HmDatapoint();
                    FieldUtils.writeField(dp, "name", "BATTERY_TYPE", true);
                    FieldUtils.writeField(dp, "writeable", Boolean.FALSE, true);
                    FieldUtils.writeField(dp, "valueType", 20, true);
                    dp.setValue(battery.getInfo());
                    channel.addDatapoint(dp);
                } catch (IllegalAccessException ex) {
                    throw new HomematicClientException(ex.getMessage(), ex);
                }
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:25,代码来源:BaseHomematicClient.java

示例13: parseChannel

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * Parses the channel informations into the binding model.
 */
@SuppressWarnings("unchecked")
private HmChannel parseChannel(HmDevice device, Map<String, ?> channelData) throws IllegalAccessException {
	HmChannel channel = new HmChannel();
	FieldUtils.writeField(channel, "device", device, true);
	FieldUtils.writeField(channel, "number", String.valueOf(channelData.get("INDEX")), true);

	Map<String, ?> paramsList = (Map<String, ?>) channelData.get("PARAMSET");
	for (String name : paramsList.keySet()) {
		channel.addDatapoint(parseDatapoint(channel, name, (Map<String, ?>) paramsList.get(name)));
	}

	return channel;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:17,代码来源:HomegearClient.java

示例14: getDatapoint

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
private HmDatapoint getDatapoint(String name, Object value, Number min, Number max, String channelNumber,
		String deviceType) throws Exception {
	HmDatapoint dp = new HmDatapoint();

	FieldUtils.writeField(dp, "name", name, true);
	FieldUtils.writeField(dp, "minValue", min, true);
	FieldUtils.writeField(dp, "maxValue", max, true);

	Object convertedValue = new TypeGuessAdapter().unmarshal(value == null ? null : value.toString());
	if (convertedValue instanceof Boolean) {
		FieldUtils.writeField(dp, "valueType", 2, true);
	} else if (convertedValue instanceof Integer) {
		FieldUtils.writeField(dp, "valueType", 8, true);
	} else if (convertedValue instanceof Double) {
		FieldUtils.writeField(dp, "valueType", 4, true);
	} else {
		FieldUtils.writeField(dp, "valueType", -1, true);
	}

	dp.setValue(convertedValue);

	HmChannel channel = new HmChannel();
	FieldUtils.writeField(dp, "channel", channel, true);
	FieldUtils.writeField(channel, "number", channelNumber, true);

	HmDevice device = new HmDevice();
	FieldUtils.writeField(device, "type", StringUtils.defaultString(deviceType, ""), true);

	FieldUtils.writeField(channel, "device", device, true);
	return dp;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:32,代码来源:ConverterTest.java

示例15: updateThing

import org.openhab.binding.homematic.internal.model.HmDevice; //导入依赖的package包/类
/**
 * Updates the thing for the given Homematic device.
 */
private void updateThing(HmDevice device) {
    Thing hmThing = getThingByUID(UidUtils.generateThingUID(device, getThing()));
    if (hmThing != null && hmThing.getHandler() != null) {
        HomematicThingHandler thingHandler = (HomematicThingHandler) hmThing.getHandler();
        thingHandler.thingUpdated(hmThing);
        for (Channel channel : hmThing.getChannels()) {
            thingHandler.handleRefresh(channel.getUID());
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:14,代码来源:HomematicBridgeHandler.java


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