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


Java HmDevice.getChannel方法代码示例

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


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

示例1: initialize

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
@Override
public void initialize(HmDevice device) {
    if (isApplicable(device)) {
        HmChannel channelOne = device.getChannel(1);
        if (channelOne != null) {
            HmDatapointInfo dpStateInfo = HmDatapointInfo.createValuesInfo(channelOne, DATAPOINT_NAME_STATE);
            HmDatapoint dpState = channelOne.getDatapoint(dpStateInfo);
            if (dpState != null) {
                addDatapoint(device, 1, getName(), HmValueType.BOOL, convertState(dpState.getValue()), true);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:14,代码来源:StateContactVirtualDatapointHandler.java

示例2: addDatapoint

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
/**
 * Creates a new datapoint with the given parameters and adds it to the channel.
 */
protected HmDatapoint addDatapoint(HmDevice device, Integer channelNumber, String datapointName,
        HmValueType valueType, Object value, boolean readOnly) {
    HmChannel channel = device.getChannel(channelNumber);
    HmDatapoint dp = new HmDatapoint(datapointName, datapointName, valueType, value, readOnly,
            HmParamsetType.VALUES);
    return addDatapoint(channel, dp);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:11,代码来源:AbstractVirtualDatapointHandler.java

示例3: getDatapoint

import org.openhab.binding.homematic.internal.model.HmDevice; //导入方法依赖的package包/类
@Override
public HmDatapoint getDatapoint(HmDatapointInfo dpInfo) throws HomematicClientException {
    HmDevice device = getDevice(dpInfo.getAddress());
    HmChannel channel = device.getChannel(dpInfo.getChannel());
    if (channel == null) {
        throw new HomematicClientException(String.format("Channel %s in device '%s' not found on gateway '%s'",
                dpInfo.getChannel(), dpInfo.getAddress(), id));
    }
    HmDatapoint dp = channel.getDatapoint(dpInfo);
    if (dp == null) {
        throw new HomematicClientException(String.format("Datapoint '%s' not found on gateway '%s'", dpInfo, id));
    }
    return dp;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:15,代码来源:AbstractHomematicGateway.java

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


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