Bugfixes
This commit is contained in:
parent
7109abeea2
commit
17e50573d6
6 changed files with 36 additions and 17 deletions
|
|
@ -115,7 +115,8 @@ public class ControllerManager implements HalSensorReportListener,
|
|||
db.exec(stmt);
|
||||
}
|
||||
else { // unknown sensor
|
||||
logger.finest("Received report from unregistered sensor: "+ sensorData);
|
||||
logger.finest("Received report from unregistered sensor" +
|
||||
"("+sensorData.getClass().getSimpleName()+"): "+ sensorData);
|
||||
sensor = findSensor(sensorData, detectedSensors);
|
||||
if(sensor == null) {
|
||||
sensor = new Sensor();
|
||||
|
|
@ -200,7 +201,8 @@ public class ControllerManager implements HalSensorReportListener,
|
|||
db.exec(stmt);
|
||||
}
|
||||
else { // unknown sensor
|
||||
logger.info("Received report from unregistered event: "+ eventData);
|
||||
logger.info("Received report from unregistered event" +
|
||||
"("+eventData.getClass().getSimpleName()+"): "+ eventData);
|
||||
event = findEvent(eventData, detectedEvents);
|
||||
if(event == null) {
|
||||
event = new Event();
|
||||
|
|
|
|||
|
|
@ -5,16 +5,20 @@ import se.hal.intf.HalAutoScannableController;
|
|||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.intf.HalSensorReportListener;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.osal.app.linux.NutUPSClient;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2016-05-25.
|
||||
*/
|
||||
public class NutUpsController implements HalSensorController, HalAutoScannableController, Runnable{
|
||||
public static Logger logger = LogUtil.getLogger();
|
||||
private static final int SYNC_INTERVAL = 60 * 1000;
|
||||
|
||||
private NutUPSClient client;
|
||||
|
|
@ -49,10 +53,14 @@ public class NutUpsController implements HalSensorController, HalAutoScannableCo
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
if(client != null && listener != null){
|
||||
for (NutUPSClient.UPSDevice ups : client.getUPSList()){
|
||||
listener.reportReceived(new NutUpsDevice(ups));
|
||||
try {
|
||||
if (client != null && listener != null) {
|
||||
for (NutUPSClient.UPSDevice ups : client.getUPSList()) {
|
||||
listener.reportReceived(new NutUpsDevice(ups));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
logger.log(Level.SEVERE, "NutUps thread crashed", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,11 +43,14 @@ public class NutUpsDevice implements PowerConsumptionSensorData{
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public String toString(){
|
||||
return "id: "+deviceId +
|
||||
", consumption: "+consumption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregationMethod getAggregationMethod() {
|
||||
return AggregationMethod.SUM;
|
||||
return AggregationMethod.AVERAGE;
|
||||
}
|
||||
@Override
|
||||
public Class<? extends HalSensorController> getSensorController() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue