Type type = base.type(); String manufacturer = base.manufacturer(); String hwVersion = base.hwVersion(); String swVersion = base.swVersion(); String serialNumber = base.serialNumber(); ChassisId chassisId = base.chassisId(); DefaultAnnotations annotations = DefaultAnnotations.builder().build(); annotations = merge(annotations, base.annotations()); annotations = merge(annotations, e.getValue().getDeviceDesc().annotations());
Device.Type type = descr.type(); if (cfg.type() != null && cfg.type() != type) { type = cfg.type(); String manufacturer = descr.manufacturer(); if (cfg.manufacturer() != null && !cfg.manufacturer().equals(manufacturer)) { manufacturer = cfg.manufacturer(); String hwVersion = descr.hwVersion(); if (cfg.hwVersion() != null && !cfg.hwVersion().equals(hwVersion)) { hwVersion = cfg.hwVersion(); String swVersion = descr.swVersion(); if (cfg.swVersion() != null && !cfg.swVersion().equals(swVersion)) { swVersion = cfg.swVersion(); String serial = descr.serialNumber(); if (cfg.serial() != null && !cfg.serial().equals(serial)) { serial = cfg.serial(); SparseAnnotations sa = combine(cfg, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion, serial, descr.chassisId(), descr.isDefaultAvailable(), sa);
/** * Puts DeviceDescription, merging annotations as necessary. * * @param newDesc new DeviceDescription * @return previous DeviceDescription */ public synchronized DeviceDescription putDeviceDesc(DeviceDescription newDesc) { DeviceDescription oldOne = deviceDesc.get(); DeviceDescription newOne = newDesc; if (oldOne != null) { SparseAnnotations merged = union(oldOne.annotations(), newDesc.annotations()); newOne = new DefaultDeviceDescription(newOne, merged); } return deviceDesc.getAndSet(newOne); }
if (deviceDescription.isDefaultAvailable()) { log.info("Device {} connected", deviceId); } else {
boolean descriptionChanged = lastDescription == null || (!Objects.equals(thisDescription, lastDescription) || !Objects.equals(thisDescription.annotations(), lastDescription.annotations())); if (descriptionChanged || !deviceService.isAvailable(did)) { resetDeviceState(did);
@Override public DeviceDescription combine(DeviceId deviceId, DeviceDescription descr, Optional<Config> prevConfig) { DeviceAnnotationConfig cfg = lookupConfig(deviceId); if (cfg == null) { return descr; } Map<String, String> annotations = cfg.annotations(); Builder builder = DefaultAnnotations.builder(); builder.putAll(descr.annotations()); if (prevConfig.isPresent()) { DeviceAnnotationConfig prevDeviceAnnotationConfig = (DeviceAnnotationConfig) prevConfig.get(); for (String key : prevDeviceAnnotationConfig.annotations().keySet()) { if (!annotations.containsKey(key)) { builder.remove(key); } } } builder.putAll(annotations); return DefaultDeviceDescription.copyReplacingAnnotation(descr, builder.build()); }