Package org.openhab.core.types

Examples of org.openhab.core.types.Type


        Set<String> qualifiedItems = provider.getItemNames(MAC, ctype);
        // Make sure we also capture those devices that were pre-defined with a friendly name in a .cfg or alike
        Set<String> qualifiedItemsFriendly = provider.getItemNames(stick.getDevice(MAC).getFriendlyName(), ctype);
        qualifiedItems.addAll(qualifiedItemsFriendly);

        Type type = null;
        try {
          type = createStateForType(ctype,value.toString());
        } catch (BindingConfigParseException e) {
          logger.error("Error parsing a value {} to a state variable of type {}",value.toString(),ctype.getTypeClass().toString());
        }

        for(String anItem : qualifiedItems) {
          if (type instanceof State) {
            eventPublisher.postUpdate(anItem, (State) type);
          } else {
            throw new IllegalClassException("Cannot process update of type " + type.toString());
          }
        }
      }
    }   
  }
View Full Code Here


      }
      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);
 
View Full Code Here

   *            the byte array of the raw data from the KNX bus
   * @return the openHAB command or state that corresponds to the data
   */
  private Type getType(Datapoint datapoint, byte[] asdu) {
    for (KNXTypeMapper typeMapper : typeMappers) {
      Type type = typeMapper.toType(datapoint, asdu);
      if (type != null)
        return type;
    }
    return null;
  }
View Full Code Here

        for (SonosCommandType sonosCommandType : supportedCommands) {

          // create a new State based on the type of Sonos Command and
          // the status value in the map
          Type newState = null;
          try {
            newState = createStateForType((Class<? extends State>) sonosCommandType.getTypeClass(), status
                .getValue().toString());
          } catch (BindingConfigParseException e) {
            logger.error(
View Full Code Here

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
        testToType(dpt, new byte[] { }, PercentType.class));

    Type type=testToType(dpt, new byte[] { 0x0 }, PercentType.class);
    testToDPTValue(dpt, type, "0");

    type=testToType(dpt, new byte[] { (byte) 0x80 }, PercentType.class);
    testToDPTValue(dpt, type, "50");
View Full Code Here

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
        testToType(dpt, new byte[] { }, DecimalType.class));

    Type type=testToType(dpt, new byte[] { 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");

    type=testToType(dpt, new byte[] { (byte) 0x7F }, DecimalType.class);
    testToDPTValue(dpt, type, "179");
View Full Code Here

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
        testToType(dpt, new byte[] { }, DecimalType.class));

    Type type=testToType(dpt, new byte[] { 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");

    type=testToType(dpt, new byte[] { 50 }, DecimalType.class);
    testToDPTValue(dpt, type, "50");
View Full Code Here

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
        testToType(dpt, new byte[] {  }, DecimalType.class));

    Type type=testToType(dpt, new byte[] { 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");

    type=testToType(dpt, new byte[] { (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "255");
View Full Code Here

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
        testToType(dpt, new byte[] {  }, DecimalType.class));

    Type type=testToType(dpt, new byte[] { 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");

    type=testToType(dpt, new byte[] { (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "255");
View Full Code Here

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
        testToType(dpt, new byte[] { }, DecimalType.class));

    Type type=testToType(dpt, new byte[] { 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");

    type=testToType(dpt, new byte[] { (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "255");
View Full Code Here

TOP

Related Classes of org.openhab.core.types.Type

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.