Bugfixes
This commit is contained in:
parent
7109abeea2
commit
17e50573d6
6 changed files with 36 additions and 17 deletions
|
|
@ -113,11 +113,13 @@
|
||||||
// Set dynamic data
|
// Set dynamic data
|
||||||
modal.find("select[name=type]").val(button.data("type"));
|
modal.find("select[name=type]").val(button.data("type"));
|
||||||
modal.find("select[name=type]").change(); // Update dynamic inputs
|
modal.find("select[name=type]").change(); // Update dynamic inputs
|
||||||
$.each(button.attr(), function(name, value) {
|
$.each(button.attr(), function(fieldName, value) {
|
||||||
if(name.startsWith("data-")) {
|
if(fieldName.startsWith("data-")) {
|
||||||
name = name.substring(5);
|
fieldName = fieldName.substring(5);
|
||||||
console.log(name, value);
|
// case insensitive search
|
||||||
modal.find("input[name="+name+"]").val(value);
|
modal.find("input").filter(function() {
|
||||||
|
return this.name.toLowerCase() == fieldName;
|
||||||
|
}).val(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ $(function(){
|
||||||
};
|
};
|
||||||
})($.fn.attr);
|
})($.fn.attr);
|
||||||
|
|
||||||
|
// converts all timestamps to human readable time and date
|
||||||
$.fn.relTimestamp = function() {
|
$.fn.relTimestamp = function() {
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
var timestamp = parseInt($(this).text());
|
var timestamp = parseInt($(this).text());
|
||||||
|
|
|
||||||
|
|
@ -215,11 +215,14 @@
|
||||||
// set dynamic form data
|
// set dynamic form data
|
||||||
modal.find("select[name=type]").val(button.data("type"));
|
modal.find("select[name=type]").val(button.data("type"));
|
||||||
modal.find("select[name=type]").change(); // Update dynamic inputs
|
modal.find("select[name=type]").change(); // Update dynamic inputs
|
||||||
$.each(button.attr(), function(name, value) {
|
$.each(button.attr(), function(fieldName, value) {
|
||||||
if(name.startsWith("data-")) {
|
if(fieldName.startsWith("data-")) {
|
||||||
name = name.substring(5);
|
fieldName = fieldName.substring(5);
|
||||||
console.log(name, value);
|
console.log(fieldName, value);
|
||||||
modal.find("input[name="+name+"]").val(value);
|
// case insensitive search
|
||||||
|
modal.find("input").filter(function() {
|
||||||
|
return this.name.toLowerCase() == fieldName;
|
||||||
|
}).val(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,8 @@ public class ControllerManager implements HalSensorReportListener,
|
||||||
db.exec(stmt);
|
db.exec(stmt);
|
||||||
}
|
}
|
||||||
else { // unknown sensor
|
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);
|
sensor = findSensor(sensorData, detectedSensors);
|
||||||
if(sensor == null) {
|
if(sensor == null) {
|
||||||
sensor = new Sensor();
|
sensor = new Sensor();
|
||||||
|
|
@ -200,7 +201,8 @@ public class ControllerManager implements HalSensorReportListener,
|
||||||
db.exec(stmt);
|
db.exec(stmt);
|
||||||
}
|
}
|
||||||
else { // unknown sensor
|
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);
|
event = findEvent(eventData, detectedEvents);
|
||||||
if(event == null) {
|
if(event == null) {
|
||||||
event = new Event();
|
event = new Event();
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,20 @@ import se.hal.intf.HalAutoScannableController;
|
||||||
import se.hal.intf.HalSensorController;
|
import se.hal.intf.HalSensorController;
|
||||||
import se.hal.intf.HalSensorData;
|
import se.hal.intf.HalSensorData;
|
||||||
import se.hal.intf.HalSensorReportListener;
|
import se.hal.intf.HalSensorReportListener;
|
||||||
|
import zutil.log.LogUtil;
|
||||||
import zutil.osal.app.linux.NutUPSClient;
|
import zutil.osal.app.linux.NutUPSClient;
|
||||||
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Ziver on 2016-05-25.
|
* Created by Ziver on 2016-05-25.
|
||||||
*/
|
*/
|
||||||
public class NutUpsController implements HalSensorController, HalAutoScannableController, Runnable{
|
public class NutUpsController implements HalSensorController, HalAutoScannableController, Runnable{
|
||||||
|
public static Logger logger = LogUtil.getLogger();
|
||||||
private static final int SYNC_INTERVAL = 60 * 1000;
|
private static final int SYNC_INTERVAL = 60 * 1000;
|
||||||
|
|
||||||
private NutUPSClient client;
|
private NutUPSClient client;
|
||||||
|
|
@ -49,10 +53,14 @@ public class NutUpsController implements HalSensorController, HalAutoScannableCo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(client != null && listener != null){
|
try {
|
||||||
for (NutUPSClient.UPSDevice ups : client.getUPSList()){
|
if (client != null && listener != null) {
|
||||||
listener.reportReceived(new NutUpsDevice(ups));
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "id: "+deviceId +
|
||||||
|
", consumption: "+consumption;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AggregationMethod getAggregationMethod() {
|
public AggregationMethod getAggregationMethod() {
|
||||||
return AggregationMethod.SUM;
|
return AggregationMethod.AVERAGE;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends HalSensorController> getSensorController() {
|
public Class<? extends HalSensorController> getSensorController() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue