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