@Override public void removeDevice(String dSID) { Device intDevice = strucMan.getDeviceByDSID(dSID); if (intDevice != null) { strucMan.deleteDevice(intDevice); trashDevices.add(new TrashDevice(intDevice)); } }
private void checkDeviceConfig(Device newDevice, Device internalDevice) { if (newDevice == null || internalDevice == null) { return; } // check device availability has changed and inform the deviceStatusListener about the change. // NOTE: // The device is not availability for the digitalSTROM-Server, it has not been deleted and are // therefore set to // OFFLINE. // To delete an alternate algorithm is responsible. if (newDevice.isPresent() != internalDevice.isPresent()) { internalDevice.setIsPresent(newDevice.isPresent()); } if (newDevice.getMeterDSID() != null && !newDevice.getMeterDSID().equals(internalDevice.getMeterDSID())) { internalDevice.setMeterDSID(newDevice.getMeterDSID().getValue()); } if (newDevice.getFunctionalColorGroup() != null && !newDevice.getFunctionalColorGroup().equals(internalDevice.getFunctionalColorGroup())) { internalDevice.setFunctionalColorGroup(newDevice.getFunctionalColorGroup()); } if (newDevice.getName() != null && !newDevice.getName().equals(internalDevice.getName())) { internalDevice.setName(newDevice.getName()); } if (newDevice.getOutputMode() != null && !newDevice.getOutputMode().equals(internalDevice.getOutputMode())) { internalDevice.setOutputMode(newDevice.getOutputMode()); } strucMan.updateDevice(newDevice); }
@Override public void registerDeviceListener(DeviceStatusListener deviceListener) { if (deviceListener != null) { String id = deviceListener.getDeviceStatusListenerID(); logger.debug("register DeviceListener with id: " + id); if (id.equals(DeviceStatusListener.DEVICE_DISCOVERY)) { this.deviceDiscovery = deviceListener; for (Device device : strucMan.getDeviceMap().values()) { deviceDiscovery.onDeviceAdded(device); } } else { Device intDevice = strucMan.getDeviceByDSID(deviceListener.getDeviceStatusListenerID()); if (intDevice != null) { intDevice.registerDeviceStateListener(deviceListener); } else { deviceListener.onDeviceRemoved(null); } } } }
@Override public void unregisterDeviceListener(DeviceStatusListener deviceListener) { if (deviceListener != null) { String id = deviceListener.getDeviceStatusListenerID(); if (id.equals(DeviceStatusListener.DEVICE_DISCOVERY)) { this.deviceDiscovery = null; } else { Device intDevice = strucMan.getDeviceByDSID(deviceListener.getDeviceStatusListenerID()); if (intDevice != null) { intDevice.unregisterDeviceStateListener(); } } } }