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


Java HmDevice.getChannels方法代码示例

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


在下文中一共展示了HmDevice.getChannels方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: initialize

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
@Override
public void initialize(HmDevice device) {
    for (HmChannel channel : device.getChannels()) {
        if (channel.hasPressDatapoint()) {
            HmDatapoint dp = addDatapoint(device, channel.getNumber(), getName(), HmValueType.STRING, null, false);
            dp.setTrigger(true);
            dp.setOptions(new String[] { "SHORT", "LONG", "LONG_RELEASE", "CONT" });
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:PressVirtualDatapointHandler.java

示例9: initialize

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
@Override
public void initialize(HmDevice device) {
    if (isDisplay(device)) {
        for (HmChannel channel : device.getChannels()) {
            if (channel.hasDatapoint(new HmDatapointInfo(HmParamsetType.VALUES, channel, DATAPOINT_NAME_SUBMIT))) {
                for (int i = 1; i <= getLineCount(device); i++) {
                    addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_LINE + i, HmValueType.STRING,
                            null, false);

                    addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_ICON + i,
                            Icon.class);

                    if (!isEpDisplay(device)) {
                        addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_COLOR + i,
                                Color.class);
                    }
                }
                if (isEpDisplay(device)) {
                    addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_BEEPER,
                            Beeper.class);
                    HmDatapoint bc = addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_BEEPCOUNT,
                            HmValueType.INTEGER, 1, false);
                    bc.setMinValue(0);
                    bc.setMaxValue(15);
                    HmDatapoint bd = addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_BEEPINTERVAL,
                            HmValueType.INTEGER, 1, false);
                    bd.setMinValue(10);
                    bd.setMaxValue(160);
                    bd.setStep(10);
                    addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_LED, Led.class);
                }
                addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_SUBMIT, HmValueType.BOOL, false,
                        false);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:38,代码来源:DisplayTextVirtualDatapoint.java

示例10: triggerDeviceValuesReload

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
@Override
public void triggerDeviceValuesReload(HmDevice device) {
    logger.debug("Triggering values reload for device '{}'", device.getAddress());
    for (HmChannel channel : device.getChannels()) {
        channel.setInitialized(false);
    }
    gatewayAdapter.reloadDeviceValues(device);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:9,代码来源:AbstractHomematicGateway.java

示例11: updateDynamicChannelList

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
/**
 * Update the given thing channel list to reflect the device's current datapoint set
 *
 * @return true if the list was modified, false if it was not modified
 */
private boolean updateDynamicChannelList(HmDevice device, List<Channel> thingChannels) {
    boolean changed = false;
    for (HmChannel channel : device.getChannels()) {
        if (!channel.isReconfigurable()) {
            continue;
        }
        final String expectedFunction = channel
                .getDatapoint(HmParamsetType.MASTER, HomematicConstants.DATAPOINT_NAME_CHANNEL_FUNCTION)
                .getOptionValue();
        final String propertyName = String.format(PROPERTY_DYNAMIC_FUNCTION_FORMAT, channel.getNumber());

        // remove thing channels that were configured for a different function
        Iterator<Channel> channelIter = thingChannels.iterator();
        while (channelIter.hasNext()) {
            Map<String, String> properties = channelIter.next().getProperties();
            String function = properties.get(propertyName);
            if (function != null && !function.equals(expectedFunction)) {
                channelIter.remove();
                changed = true;
            }
        }
        for (HmDatapoint dp : channel.getDatapoints()) {
            if (HomematicTypeGeneratorImpl.isIgnoredDatapoint(dp)
                    || dp.getParamsetType() != HmParamsetType.VALUES) {
                continue;
            }
            ChannelUID channelUID = UidUtils.generateChannelUID(dp, getThing().getUID());
            if (containsChannel(thingChannels, channelUID)) {
                // Channel is already present -> channel configuration likely hasn't changed
                continue;
            }

            Map<String, String> channelProps = new HashMap<>();
            channelProps.put(propertyName, expectedFunction);

            Channel thingChannel = ChannelBuilder.create(channelUID, MetadataUtils.getItemType(dp))
                    .withProperties(channelProps).withLabel(MetadataUtils.getLabel(dp))
                    .withDescription(MetadataUtils.getDatapointDescription(dp))
                    .withType(UidUtils.generateChannelTypeUID(dp)).build();
            thingChannels.add(thingChannel);
            changed = true;
        }
    }

    return changed;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:52,代码来源:HomematicThingHandler.java

示例12: loadAllDeviceMetadata

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
@Override
public void loadAllDeviceMetadata() throws IOException {
    cancelLoadAllMetadata = false;
    // load all device descriptions
    List<HmDevice> deviceDescriptions = getDeviceDescriptions();

    // loading datapoints for all channels
    Set<String> loadedDevices = new HashSet<String>();
    Map<String, Collection<HmDatapoint>> datapointsByChannelIdCache = new HashMap<String, Collection<HmDatapoint>>();
    for (HmDevice device : deviceDescriptions) {
        if (!cancelLoadAllMetadata) {
            try {
                logger.trace("Loading metadata for device '{}' of type '{}'", device.getAddress(),
                        device.getType());
                if (device.isGatewayExtras()) {
                    loadChannelValues(device.getChannel(HmChannel.CHANNEL_NUMBER_VARIABLE));
                    loadChannelValues(device.getChannel(HmChannel.CHANNEL_NUMBER_SCRIPT));
                } else {
                    for (HmChannel channel : device.getChannels()) {
                        logger.trace("  Loading channel {}", channel);
                        // speed up metadata generation a little bit for equal channels in the gateway devices
                        if ((DEVICE_TYPE_VIRTUAL.equals(device.getType())
                                || DEVICE_TYPE_VIRTUAL_WIRED.equals(device.getType())) && channel.getNumber() > 1) {
                            HmChannel previousChannel = device.getChannel(channel.getNumber() - 1);
                            cloneAllDatapointsIntoChannel(channel, previousChannel.getDatapoints());
                        } else {
                            String channelId = String.format("%s:%s:%s", channel.getDevice().getType(),
                                    channel.getDevice().getFirmware(), channel.getNumber());
                            Collection<HmDatapoint> cachedDatapoints = datapointsByChannelIdCache.get(channelId);
                            if (cachedDatapoints != null) {
                                // clone all datapoints
                                cloneAllDatapointsIntoChannel(channel, cachedDatapoints);
                            } else {
                                logger.trace("    Loading datapoints into channel {}", channel);
                                addChannelDatapoints(channel, HmParamsetType.MASTER);
                                addChannelDatapoints(channel, HmParamsetType.VALUES);

                                // Make sure to only cache non-reconfigurable channels. For reconfigurable channels,
                                // the data point set might change depending on the selected mode.
                                if (!channel.isReconfigurable()) {
                                    datapointsByChannelIdCache.put(channelId, channel.getDatapoints());
                                }
                            }
                        }
                    }
                }
                prepareDevice(device);
                loadedDevices.add(device.getAddress());
                gatewayAdapter.onDeviceLoaded(device);
            } catch (IOException ex) {
                logger.warn("Can't load device with address '{}' from gateway '{}': {}", device.getAddress(), id,
                        ex.getMessage());
            }
        }
    }
    if (!cancelLoadAllMetadata) {
        devices.keySet().retainAll(loadedDevices);
    }
    initialized = true;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:61,代码来源:AbstractHomematicGateway.java

示例13: generate

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
@Override
public void generate(HmDevice device) {
    if (thingTypeProvider != null) {
        ThingTypeUID thingTypeUID = UidUtils.generateThingTypeUID(device);
        ThingType tt = thingTypeProvider.getThingType(thingTypeUID, Locale.getDefault());
        if (tt == null || device.isGatewayExtras()) {
            logger.debug("Generating ThingType for device '{}' with {} datapoints", device.getType(),
                    device.getDatapointCount());

            List<ChannelGroupType> groupTypes = new ArrayList<ChannelGroupType>();
            for (HmChannel channel : device.getChannels()) {
                List<ChannelDefinition> channelDefinitions = new ArrayList<ChannelDefinition>();
                // Omit thing channel definitions for reconfigurable channels;
                // those will be populated dynamically during thing initialization
                if (!channel.isReconfigurable()) {
                    // generate channel
                    for (HmDatapoint dp : channel.getDatapoints()) {
                        if (!isIgnoredDatapoint(dp) && dp.getParamsetType() == HmParamsetType.VALUES) {
                            ChannelTypeUID channelTypeUID = UidUtils.generateChannelTypeUID(dp);
                            ChannelType channelType = channelTypeProvider.getChannelType(channelTypeUID,
                                    Locale.getDefault());
                            if (channelType == null) {
                                channelType = createChannelType(dp, channelTypeUID);
                                channelTypeProvider.addChannelType(channelType);
                            }

                            ChannelDefinition channelDef = new ChannelDefinition(dp.getName(),
                                    channelType.getUID());
                            channelDefinitions.add(channelDef);
                        }
                    }
                }

                // generate group
                ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(channel);
                ChannelGroupType groupType = channelTypeProvider.getChannelGroupType(groupTypeUID,
                        Locale.getDefault());
                if (groupType == null || device.isGatewayExtras()) {
                    String groupLabel = String.format("%s",
                            WordUtils.capitalizeFully(StringUtils.replace(channel.getType(), "_", " ")));
                    groupType = new ChannelGroupType(groupTypeUID, false, groupLabel, null, null,
                            channelDefinitions);
                    channelTypeProvider.addChannelGroupType(groupType);
                    groupTypes.add(groupType);
                }

            }
            tt = createThingType(device, groupTypes);
            thingTypeProvider.addThingType(tt);
        }
        addFirmware(device);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:54,代码来源:HomematicTypeGeneratorImpl.java

示例14: generateConfigDescription

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
private void generateConfigDescription(HmDevice device, URI configDescriptionURI) {
    List<ConfigDescriptionParameter> parms = new ArrayList<ConfigDescriptionParameter>();
    List<ConfigDescriptionParameterGroup> groups = new ArrayList<ConfigDescriptionParameterGroup>();

    for (HmChannel channel : device.getChannels()) {
        String groupName = "HMG_" + channel.getNumber();
        String groupLabel = MetadataUtils.getDescription("CHANNEL_NAME") + " " + channel.getNumber();
        groups.add(new ConfigDescriptionParameterGroup(groupName, null, false, groupLabel, null));

        for (HmDatapoint dp : channel.getDatapoints()) {
            if (dp.getParamsetType() == HmParamsetType.MASTER) {
                ConfigDescriptionParameterBuilder builder = ConfigDescriptionParameterBuilder.create(
                        MetadataUtils.getParameterName(dp), MetadataUtils.getConfigDescriptionParameterType(dp));

                builder.withLabel(MetadataUtils.getLabel(dp));
                builder.withDefault(ObjectUtils.toString(dp.getDefaultValue()));
                builder.withDescription(MetadataUtils.getDatapointDescription(dp));

                if (dp.isEnumType()) {
                    builder.withLimitToOptions(dp.isEnumType());
                    List<ParameterOption> options = MetadataUtils.generateOptions(dp,
                            new OptionsBuilder<ParameterOption>() {
                                @Override
                                public ParameterOption createOption(String value, String description) {
                                    return new ParameterOption(value, description);
                                }
                            });
                    builder.withOptions(options);
                }

                if (dp.isNumberType()) {
                    builder.withMinimum(MetadataUtils.createBigDecimal(dp.getMinValue()));
                    builder.withMaximum(MetadataUtils.createBigDecimal(dp.getMaxValue()));
                    builder.withStepSize(MetadataUtils.createBigDecimal(dp.isFloatType() ? new Float(0.1) : 1L));
                    builder.withUnitLabel(MetadataUtils.getUnit(dp));
                }

                builder.withGroupName(groupName);
                parms.add(builder.build());
            }
        }
    }
    if (!parms.isEmpty()) {
        configDescriptionProvider.addConfigDescription(new ConfigDescription(configDescriptionURI, parms, groups));
    }

}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:48,代码来源:HomematicTypeGeneratorImpl.java


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