Beispiel #1
0
 /**
  * Returns the datapoints for a given item and group address. This method iterates over all
  * registered KNX binding providers to find the result.
  *
  * @param itemName the item name for the datapoint
  * @param groupAddress the group address associated to the datapoint
  * @return the datapoints which corresponds to the given item and group address
  */
 private Iterable<Datapoint> getDatapoints(String itemName, GroupAddress groupAddress) {
   for (KNXBindingProvider provider : providers) {
     Iterable<Datapoint> datapoints = provider.getDatapoints(itemName, groupAddress);
     if (datapoints != null) return datapoints;
   }
   return null;
 }
Beispiel #2
0
 /**
  * Determines whether the given <code>groupAddress</code> is the address which will be interpreted
  * as the command type. This method iterates over all registered KNX binding providers to find the
  * result.
  *
  * @param groupAddress the group address to check
  * @return true, if it is a command GA
  */
 private boolean isCommandGA(GroupAddress groupAddress) {
   for (KNXBindingProvider provider : providers) {
     if (!provider.isCommandGA(groupAddress)) {
       return false;
     }
   }
   return true;
 }
Beispiel #3
0
 /**
  * Returns all listening item names. This method iterates over all registered KNX binding
  * providers and aggregates the result.
  *
  * @param groupAddress the group address that the items are listening to
  * @return an array of all listening items
  */
 private String[] getItemNames(GroupAddress groupAddress) {
   List<String> itemNames = new ArrayList<String>();
   for (KNXBindingProvider provider : providers) {
     for (String itemName : provider.getListeningItemNames(groupAddress)) {
       itemNames.add(itemName);
     }
   }
   return itemNames.toArray(new String[itemNames.size()]);
 }
Beispiel #4
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();
 }
Beispiel #5
0
 /**
  * Returns the datapoints for a given item and type class. This method iterates over all
  * registered KNX binding providers to find the result.
  *
  * @param itemName the item name for the datapoints
  * @param typeClass the type class associated to the datapoints
  * @return the datapoints which corresponds to the given item and type class
  */
 private Iterable<Datapoint> getDatapoints(
     final String itemName, final Class<? extends Type> typeClass) {
   Set<Datapoint> datapoints = new HashSet<Datapoint>();
   for (KNXBindingProvider provider : providers) {
     for (Datapoint datapoint : provider.getDatapoints(itemName, typeClass)) {
       datapoints.add(datapoint);
     }
   }
   return datapoints;
 }
Beispiel #6
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);
          }
        }
      }
    }
  }
Beispiel #7
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;
         }
       }
     }
   }
 }
Beispiel #8
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);
            }
          }
        }
      }
    }
  }