Examples of DecimalType


Examples of org.openhab.core.library.types.DecimalType

    assertEquals(new DateMidnight(2012, 1, 1).toDate(), historicItem.getTimestamp());
  }

  @Test
  public void testAverageSince() {
    item.setState(new DecimalType(3025));
    DecimalType average = PersistenceExtensions.averageSince(item, new DateMidnight(2003, 1, 1), "test");
    assertEquals("2100", average.toString());
  }
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(20));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(20));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [20]", label);
  }
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(20));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(20));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [ 20]", label);
  }
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(20));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(20));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [ 14]", label);
  }
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(10f/3f));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(10f/3f));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [3" + sep + "333]", label);
  }
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

    Widget w = mock(Widget.class);
    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(new DecimalType(10f/3f));
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(10f/3f));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [3" + sep + "3 %]", label);
  }
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

    Item item = mock(Item.class);
    when(w.getLabel()).thenReturn(testLabel);
    when(w.getItem()).thenReturn("Item");
    when(registry.getItem("Item")).thenReturn(item);
    when(item.getState()).thenReturn(OnOffType.ON);
    when(item.getStateAs(DecimalType.class)).thenReturn(new DecimalType(5));
    String label = uiRegistry.getLabel(w);
    assertEquals("Label [5]", label);
  }
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

    List<HistoricItem> ret = new ArrayList<HistoricItem>();
    for(JpaPersistentItem i : jpaQueryResult) {
     
      State state;
      if (item instanceof NumberItem) {
        state = new DecimalType(Double.valueOf(i.getValue()));
      } else if (item instanceof DimmerItem) {
        state = new PercentType(Integer.valueOf(i.getValue()));
      } else if (item instanceof SwitchItem) {
        state = OnOffType.valueOf(i.getValue());
      } else if (item instanceof ContactItem) {
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

      }
      try {
        Sample sample = db.createSample();
              sample.setTime(now);
             
              DecimalType state = (DecimalType) item.getStateAs(DecimalType.class);
              if (state!=null) {
                    double value = state.toBigDecimal().doubleValue();
                    sample.setValue(DATASOURCE_STATE, value);
                    sample.update();
                    logger.debug("Stored '{}' with state '{}' in rrd4j database", name, item.getState());
              }
      } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.openhab.core.library.types.DecimalType

      } catch (ItemNotFoundException e) {
        logger.debug("Could not find item '{}' in registry", itemName);
      }
    }
    // just return a DecimalType as a fallback
    return new DecimalType(value);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.