Examples of HistoricItem


Examples of org.openhab.core.persistence.HistoricItem

   * @param serviceName the name of the {@link PersistenceService} to use
   * @return the evolution rate in percent (positive and negative) between now and then,
   *       null if not calculable
   */
  static public DecimalType evolutionRate(Item item, AbstractInstant timestamp, String serviceName) {
    HistoricItem itemThen = historicState(item, timestamp);
    DecimalType valueThen = (DecimalType) itemThen.getState();
    DecimalType valueNow = (DecimalType) item.getStateAs(DecimalType.class);
    DecimalType result = null;
    if (( valueThen != null) && ( valueNow != null)) {
      result = new DecimalType(100 * (valueNow.doubleValue() - valueThen.doubleValue()) / valueThen.doubleValue());
    };
View Full Code Here

Examples of org.openhab.core.persistence.HistoricItem

      Iterable<HistoricItem> items = qService.query(filter);
      while (items != null) {
        Iterator<HistoricItem> itemIterator = items.iterator();
        int itemCount = 0;
        while (itemIterator.hasNext()) {
          HistoricItem historicItem = itemIterator.next();
          itemCount++;
          if (!skipEqual || (skipEqual && !historicItem.getState().equals(item.getState()))) {
            return historicItem;
          }
        }
        if (itemCount == filter.getPageSize()) {
          filter.setPageNumber(++startPage);
View Full Code Here

Examples of org.openhab.core.persistence.HistoricItem

    filter.setItemName(item.getName());
    filter.setPageSize(1);
    filter.setOrdering(Ordering.DESCENDING);
    result = service.query(filter);
    if(result.iterator().hasNext()) {
      HistoricItem historicItem = result.iterator().next();

      state = historicItem.getState();
      xData.add(timeBegin);
      yData.add(convertData(state));
    }

    // Now, get all the data between the start and end time
    filter.setBeginDate(timeBegin);
    filter.setEndDate(timeEnd);
    filter.setPageSize(Integer.MAX_VALUE);
    filter.setOrdering(Ordering.ASCENDING);
   
    // Get the data from the persistence store
    result = service.query(filter);
    Iterator<HistoricItem> it = result.iterator();

    // Iterate through the data
    while (it.hasNext()) {
      HistoricItem historicItem = it.next();
     
      // For 'binary' states, we need to replicate the data
      // to avoid diagonal lines
      if(state instanceof OnOffType || state instanceof OpenClosedType) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(historicItem.getTimestamp());
        cal.add(Calendar.MILLISECOND, -1);
        xData.add(cal.getTime());
        yData.add(convertData(state));
      }

      state = historicItem.getState();
      xData.add(historicItem.getTimestamp());
      yData.add(convertData(state));
    }

    // Lastly, add the final state at the endtime
    if (state != null) {
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.