Package tuwien.auto.calimero

Examples of tuwien.auto.calimero.GroupAddress


  
   * @param e the {@link ProcessEvent} to handle.
   */
  private void readFromKNX(ProcessEvent e) {
    try {
      GroupAddress destination = e.getDestination();
      byte[] asdu = e.getASDU();
      if (asdu.length==0) {
        return;
      }
      for (String itemName : getItemNames(destination)) {
        Iterable<Datapoint> datapoints = getDatapoints(itemName, destination);
        if (datapoints != null) {
          for (Datapoint datapoint : datapoints) {
            Type type = getType(datapoint, asdu);         
            if (type!=null) {
              // we need to make sure that we won't send out this event to
              // the knx bus again, when receiving it on the openHAB bus
              ignoreEventList.add(itemName + type.toString());
              logger.trace("Added event (item='{}', type='{}') to the ignore event list", itemName, type.toString());
             
              if (type instanceof Command && isCommandGA(destination)) {
                eventPublisher.postCommand(itemName, (Command) type);
              } else if (type instanceof State) {
                eventPublisher.postUpdate(itemName, (State) type);
              } else {
                throw new IllegalClassException("Cannot process datapoint of type " + type.toString());
              }               

              logger.trace("Processed event (item='{}', type='{}', destination='{}')", itemName, type.toString(), destination.toString());
              return;
            }
            else {
              final char[] hexCode = "0123456789ABCDEF".toCharArray();
                  StringBuilder sb = new StringBuilder(2+asdu.length * 2);
                  sb.append("0x");
                  for (byte b : asdu) {
                      sb.append(hexCode[(b >> 4) & 0xF]);
                      sb.append(hexCode[(b & 0xF)]);
                  }

              logger.debug("Ignoring KNX bus data: couldn't transform to an openHAB type (not supported). Destination='{}', datapoint='{}', data='{}'",
                  new Object[] {destination.toString(), datapoint.toString(), sb.toString() });
              return;
            }
          }
        }
      }
      logger.debug("Received telegram for unknown group address {}", destination.toString());
    } catch(RuntimeException re) {
      logger.error("Error while receiving event from KNX bus: " + re.toString());
    }
  }
View Full Code Here


          }
       
          String ga = (segments.length == 1) ? segments[0].trim() : segments[1].trim();
         
          // create group address and datapoint
          GroupAddress groupAddress = new GroupAddress(ga);
          Datapoint dp;
          if (j != 0 || item.getAcceptedCommandTypes().size() == 0) {
            dp = new StateDP(groupAddress, item.getName(), 0, dptID);
          } else {
            dp = new CommandDP(groupAddress, item.getName(), 0, dptID);
View Full Code Here

    assertNotNull(bindingConfigs.get(0).readableDataPoint);
    assertNull(bindingConfigs.get(1).readableDataPoint);
    assertNull(bindingConfigs.get(2).readableDataPoint);
    assertNull(bindingConfigs.get(3).readableDataPoint);
   
    assertTrue(bindingConfigs.get(0).allDataPoints.contains(new GroupAddress("4/2/10")));
    assertTrue(bindingConfigs.get(0).allDataPoints.contains(new GroupAddress("0/2/10")));
    assertTrue(bindingConfigs.get(1).allDataPoints.contains(new GroupAddress("4/2/11")));
    assertTrue(bindingConfigs.get(1).allDataPoints.contains(new GroupAddress("0/2/11")));
    assertTrue(bindingConfigs.get(2).allDataPoints.contains(new GroupAddress("4/2/12")));
    assertTrue(bindingConfigs.get(3).allDataPoints.contains(new GroupAddress("4/2/13")));
   
    assertEquals(true, bindingConfigs.get(0).mainDataPoint instanceof CommandDP);
    assertEquals(true, bindingConfigs.get(1).mainDataPoint instanceof CommandDP);
    assertEquals(true, bindingConfigs.get(2).mainDataPoint instanceof StateDP);
    assertEquals(true, bindingConfigs.get(3).mainDataPoint instanceof CommandDP);
View Full Code Here

   
    provider.processBindingConfiguration("text", item1,
        "<4/2/10+0/2/10, 5.005:4/2/11+0/2/11, +4/2/12, 4/2/13");

    // method under Test
    assertEquals(true, provider.isCommandGA(new GroupAddress("4/2/10")));
    assertEquals(true, provider.isCommandGA(new GroupAddress("4/2/11")));
    assertEquals(true, provider.isCommandGA(new GroupAddress("4/2/13")));

    assertEquals(false, provider.isCommandGA(new GroupAddress("0/2/10")));
    assertEquals(false, provider.isCommandGA(new GroupAddress("0/2/11")));
    assertEquals(false, provider.isCommandGA(new GroupAddress("4/2/12")));
  }
View Full Code Here

   * @return a new CommandDP
   * @throws KNXFormatException
   */
  private Datapoint createDP(String dpt) throws KNXFormatException {
    int mainNumber=Integer.parseInt(dpt.substring(0, dpt.indexOf('.')));
    return new CommandDP(new GroupAddress("1/2/3"), "test", mainNumber, dpt);
  }
View Full Code Here

TOP

Related Classes of tuwien.auto.calimero.GroupAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.