當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。