示例#1
0
 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();
 }
示例#2
0
  /* (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);
          }
        }
      }
    }
  }
示例#3
0
  /* (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);
            }
          }
        }
      }
    }
  }
示例#4
0
 /* (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;
         }
       }
     }
   }
 }
示例#5
0
 public void activate(ComponentContext componentContext) {
   logger.debug("Calimero library version {}", Settings.getLibraryVersion());
   logger.trace("KNXBinding: activating");
   KNXConnection.addConnectionListener(this);
   mKNXBusReaderScheduler.start();
 }
示例#6
0
 /* (non-Javadoc)
  * @see org.openhab.binding.knx.internal.connection.KNXConnectionListener#connectionLost()
  */
 @Override
 public void connectionLost() {
   logger.trace("connectionLost() msg received.");
   mKNXConnectionEstablished = false;
   mKNXBusReaderScheduler.clear();
 }