// Path: app/src/main/java/de/vier_bier/habpanelviewer/openhab/FutureState.java
// public class FutureState extends ItemState implements Delayed {
//     private final int delayInMillis;
//     private long origin = System.currentTimeMillis();
// 
//     public FutureState(String item, int interval, String state) {
//         super(item, state);
// 
//         delayInMillis = interval * 1000;
// 
//         resetTime();
//     }
// 
//     public void resetTime() {
//         origin = System.currentTimeMillis();
//     }
// 
//     @Override
//     public long getDelay(@NonNull TimeUnit timeUnit) {
//         return timeUnit.convert(delayInMillis - (System.currentTimeMillis() - origin), TimeUnit.MILLISECONDS);
//     }
// 
//     @Override
//     public int compareTo(@NonNull Delayed delayed) {
//         if (delayed == this) {
//             return 0;
//         }
// 
//         return Long.compare(getDelay(TimeUnit.MILLISECONDS), delayed.getDelay(TimeUnit.MILLISECONDS));
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return obj instanceof FutureState && mItemName.equals(((FutureState) obj).mItemName);
//     }
// }


import java.util.HashMap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import de.vier_bier.habpanelviewer.openhab.FutureState;
package de.vier_bier.habpanelviewer.openhab.average;



/**
 * Thread that does cyclic propagation of state averages or timed state updates
 */
public class AveragePropagator extends Thread {
    private final IStatePropagator mStatePropagator;
    private final AtomicBoolean mRunning = new AtomicBoolean(true);

    private final BlockingQueue<Average> mAvgQueue = new DelayQueue<>();
    private final HashMap<String, Average> mAverages = new HashMap<>();

// Path: app/src/main/java/de/vier_bier/habpanelviewer/openhab/FutureState.java
// public class FutureState extends ItemState implements Delayed {
//     private final int delayInMillis;
//     private long origin = System.currentTimeMillis();
// 
//     public FutureState(String item, int interval, String state) {
//         super(item, state);
// 
//         delayInMillis = interval * 1000;
// 
//         resetTime();
//     }
// 
//     public void resetTime() {
//         origin = System.currentTimeMillis();
//     }
// 
//     @Override
//     public long getDelay(@NonNull TimeUnit timeUnit) {
//         return timeUnit.convert(delayInMillis - (System.currentTimeMillis() - origin), TimeUnit.MILLISECONDS);
//     }
// 
//     @Override
//     public int compareTo(@NonNull Delayed delayed) {
//         if (delayed == this) {
//             return 0;
//         }
// 
//         return Long.compare(getDelay(TimeUnit.MILLISECONDS), delayed.getDelay(TimeUnit.MILLISECONDS));
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return obj instanceof FutureState && mItemName.equals(((FutureState) obj).mItemName);
//     }
// }


// Path: app/src/main/java/de/vier_bier/habpanelviewer/openhab/average/AveragePropagator.java
import java.util.HashMap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import de.vier_bier.habpanelviewer.openhab.FutureState;

package de.vier_bier.habpanelviewer.openhab.average;



/**
 * Thread that does cyclic propagation of state averages or timed state updates
 */
public class AveragePropagator extends Thread {
    private final IStatePropagator mStatePropagator;
    private final AtomicBoolean mRunning = new AtomicBoolean(true);

    private final BlockingQueue<Average> mAvgQueue = new DelayQueue<>();
    private final HashMap<String, Average> mAverages = new HashMap<>();

    private final BlockingQueue<FutureState> mFutureStateQueue = new DelayQueue<>();