public void deactivate(ComponentContext componentContext) { logger.trace("KNXBinding: deactivating"); KNXConnection.removeConnectionListener(this); for (KNXBindingProvider provider : providers) { provider.removeBindingChangeListener(this); } providers.clear(); mKNXBusReaderScheduler.stop(); KNXConnection.disconnect(); }
/* (non-Javadoc) * @see org.openhab.binding.knx.internal.connection.KNXConnectionListener#connectionEstablished() */ @Override public void connectionEstablished() { logger.trace("connectionEstablished() msg received. Initializing readable DPs."); mKNXConnectionEstablished = true; for (KNXBindingProvider knxProvider : providers) { for (Datapoint datapoint : knxProvider.getReadableDatapoints()) { mKNXBusReaderScheduler.readOnce(datapoint); int autoRefreshTimeInSecs = knxProvider.getAutoRefreshTime(datapoint); if (autoRefreshTimeInSecs > 0) { if (!mKNXBusReaderScheduler.scheduleRead(datapoint, autoRefreshTimeInSecs)) { logger.warn( "Couldn't add to KNX bus reader scheduler (connectionEstablished, datapoint='{}')", datapoint); } } } } }
/* (non-Javadoc) * @see org.openhab.core.binding.AbstractBinding#allBindingsChanged(org.openhab.core.binding.BindingProvider) */ @Override public void allBindingsChanged(BindingProvider provider) { logger.trace("allBindingsChanged() msg received."); if (mKNXConnectionEstablished) { logger.debug("Initializing readable DPs."); if (provider instanceof KNXBindingProvider) { KNXBindingProvider knxProvider = (KNXBindingProvider) provider; mKNXBusReaderScheduler.clear(); for (Datapoint datapoint : knxProvider.getReadableDatapoints()) { mKNXBusReaderScheduler.readOnce(datapoint); int autoRefreshTimeInSecs = knxProvider.getAutoRefreshTime(datapoint); if (autoRefreshTimeInSecs > 0) { if (!mKNXBusReaderScheduler.scheduleRead( datapoint, knxProvider.getAutoRefreshTime(datapoint))) { logger.warn( "Couldn't add to KNX bus reader scheduler (allBindingsChanged, datapoint='{}')", datapoint); } } } } } }
/* (non-Javadoc) * @see org.openhab.core.binding.AbstractBinding#bindingChanged(org.openhab.core.binding.BindingProvider, java.lang.String) */ @Override public void bindingChanged(BindingProvider provider, String itemName) { logger.trace("bindingChanged() for item {} msg received.", itemName); if (mKNXConnectionEstablished) { if (provider instanceof KNXBindingProvider) { KNXBindingProvider knxProvider = (KNXBindingProvider) provider; for (Datapoint datapoint : knxProvider.getReadableDatapoints()) { if (datapoint.getName().equals(itemName)) { logger.debug("Initializing read of item {}.", itemName); if (!mKNXBusReaderScheduler.scheduleRead( datapoint, knxProvider.getAutoRefreshTime(datapoint))) { logger.warn( "Couldn't add to KNX bus reader scheduler (bindingChanged, datapoint='{}')", datapoint); } break; } } } } }
public void activate(ComponentContext componentContext) { logger.debug("Calimero library version {}", Settings.getLibraryVersion()); logger.trace("KNXBinding: activating"); KNXConnection.addConnectionListener(this); mKNXBusReaderScheduler.start(); }
/* (non-Javadoc) * @see org.openhab.binding.knx.internal.connection.KNXConnectionListener#connectionLost() */ @Override public void connectionLost() { logger.trace("connectionLost() msg received."); mKNXConnectionEstablished = false; mKNXBusReaderScheduler.clear(); }