Fixed so that UPS data is konverted to kwh instead of only being watts

This commit is contained in:
Ziver Koc 2016-06-04 14:58:09 +02:00
parent 6c11751720
commit c2c5935284
6 changed files with 7 additions and 301 deletions

View file

@ -80,7 +80,6 @@ public class SensorDataAggregatorDaemon implements HalDaemon {
* Aggregate data from the raw DB table to the aggregated table
* @param sensor The sensor for to aggregate data
* @param ageLimitInMs Only aggregate up to this age
* @param toPeriodSizeInMs The period length in ms to aggregate to
*/
private void aggregateRawData(Sensor sensor, AggregationPeriodLength aggrPeriodLength, long ageLimitInMs, int expectedSampleCount, long aggregationStartTime){
long sensorId = sensor.getId();

View file

@ -14,7 +14,7 @@ public class NutUpsDevice implements PowerConsumptionSensorData{
@Configurator.Configurable("UPS id")
private String deviceId;
private long timestamp;
private int consumption;
private double consumption;
public NutUpsDevice(){}
@ -22,7 +22,7 @@ public class NutUpsDevice implements PowerConsumptionSensorData{
protected NutUpsDevice(NutUPSClient.UPSDevice ups){
this.deviceId = ups.getId();
this.timestamp = System.currentTimeMillis();
this.consumption = ups.getPowerUsage();
this.consumption = ups.getPowerUsage() * 1/60.0; // convert watt min to watt hour
}
@ -50,7 +50,7 @@ public class NutUpsDevice implements PowerConsumptionSensorData{
@Override
public AggregationMethod getAggregationMethod() {
return AggregationMethod.AVERAGE;
return AggregationMethod.SUM;
}
@Override
public Class<? extends HalSensorController> getSensorController() {

View file

@ -3,6 +3,8 @@ package se.hal.struct;
import se.hal.intf.HalSensorData;
/**
* Should return Watt Hour as data
*
* Created by Ziver on 2015-12-03.
*/
public interface PowerConsumptionSensorData extends HalSensorData {

View file

@ -11,7 +11,7 @@ import java.util.List;
public class HistoryDataListSqlResult implements SQLResultHandler<List<HistoryDataListSqlResult.HistoryData>> {
public static class HistoryData{
public long timestamp;
public double data;
public float data;
}
@Override
@ -20,7 +20,7 @@ public class HistoryDataListSqlResult implements SQLResultHandler<List<HistoryDa
while(result.next()){
HistoryData data = new HistoryData();
data.timestamp = result.getLong("timestamp");
data.data = result.getLong("data");
data.data = result.getFloat("data");
list.add(data);
}
return list;