mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Update to version 1.0.7 for the SD Image.
This commit is contained in:
@@ -17,7 +17,6 @@ import com.lanternsoftware.datamodel.currentmonitor.HubConfigService;
|
||||
import com.lanternsoftware.datamodel.currentmonitor.HubPowerMinute;
|
||||
import com.lanternsoftware.datamodel.currentmonitor.NetworkStatus;
|
||||
import com.lanternsoftware.util.CollectionUtils;
|
||||
import com.lanternsoftware.util.DateUtils;
|
||||
import com.lanternsoftware.util.NullUtils;
|
||||
import com.lanternsoftware.util.ResourceLoader;
|
||||
import com.lanternsoftware.util.ZipUtils;
|
||||
@@ -63,7 +62,6 @@ public class MonitorApp {
|
||||
private static MonitorConfig config;
|
||||
private static BreakerConfig breakerConfig;
|
||||
private static String host;
|
||||
private static Date lastUpdateCheck = new Date();
|
||||
private static HttpPool pool;
|
||||
private static LEDFlasher flasher = null;
|
||||
private static final AtomicBoolean running = new AtomicBoolean(true);
|
||||
@@ -154,7 +152,7 @@ public class MonitorApp {
|
||||
}
|
||||
break;
|
||||
case Update:
|
||||
monitor.submit(new UpdateChecker(true));
|
||||
monitor.submit(new UpdateChecker());
|
||||
break;
|
||||
case ReloadConfig:
|
||||
HttpGet get = new HttpGet(host + "config");
|
||||
@@ -389,10 +387,6 @@ public class MonitorApp {
|
||||
}
|
||||
if (mqttPoster != null)
|
||||
monitor.submit(() -> mqttPoster.postPower(mqttReadings));
|
||||
if (DateUtils.diffInSeconds(new Date(), lastUpdateCheck) >= config.getUpdateInterval()) {
|
||||
lastUpdateCheck = new Date();
|
||||
monitor.submit(new UpdateChecker());
|
||||
}
|
||||
long now = new Date().getTime();
|
||||
long duration = (now - firstPost)%1000;
|
||||
if (now - lastPost < 1000) {
|
||||
@@ -453,19 +447,9 @@ public class MonitorApp {
|
||||
}
|
||||
|
||||
private static final class UpdateChecker implements Runnable {
|
||||
private final boolean force;
|
||||
|
||||
public UpdateChecker() {
|
||||
force = false;
|
||||
}
|
||||
|
||||
public UpdateChecker(boolean _force) {
|
||||
force = _force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (NullUtils.isNotEmpty(host) && (force || config.isAutoUpdate())) {
|
||||
if (NullUtils.isNotEmpty(host)) {
|
||||
DaoEntity meta = DaoSerializer.fromZipBson(pool.executeToByteArray(new HttpGet(host + "update/version")));
|
||||
String newVersion = DaoSerializer.getString(meta, "version");
|
||||
if (NullUtils.isNotEqual(newVersion, version)) {
|
||||
|
||||
@@ -16,9 +16,6 @@ public class MonitorConfig {
|
||||
private boolean debug;
|
||||
private int connectTimeout;
|
||||
private int socketTimeout;
|
||||
private int updateInterval;
|
||||
private boolean autoUpdate;
|
||||
private float autoCalibrationVoltage;
|
||||
private boolean needsCalibration;
|
||||
private String mqttBrokerUrl;
|
||||
private String mqttUserName;
|
||||
@@ -100,30 +97,6 @@ public class MonitorConfig {
|
||||
socketTimeout = _socketTimeout;
|
||||
}
|
||||
|
||||
public int getUpdateInterval() {
|
||||
return updateInterval == 0 ? 300 : updateInterval;
|
||||
}
|
||||
|
||||
public void setUpdateInterval(int _updateInterval) {
|
||||
updateInterval = _updateInterval;
|
||||
}
|
||||
|
||||
public boolean isAutoUpdate() {
|
||||
return autoUpdate;
|
||||
}
|
||||
|
||||
public void setAutoUpdate(boolean _autoUpdate) {
|
||||
autoUpdate = _autoUpdate;
|
||||
}
|
||||
|
||||
public float getAutoCalibrationVoltage() {
|
||||
return autoCalibrationVoltage;
|
||||
}
|
||||
|
||||
public void setAutoCalibrationVoltage(float _autoCalibrationVoltage) {
|
||||
autoCalibrationVoltage = _autoCalibrationVoltage;
|
||||
}
|
||||
|
||||
public boolean isNeedsCalibration() {
|
||||
return needsCalibration;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ public class MonitorConfigSerializer extends AbstractDaoSerializer<MonitorConfig
|
||||
d.put("debug", _o.isDebug());
|
||||
d.put("connect_timeout", _o.getConnectTimeout());
|
||||
d.put("socket_timeout", _o.getSocketTimeout());
|
||||
d.put("update_interval", _o.getUpdateInterval());
|
||||
d.put("auto_update", _o.isAutoUpdate());
|
||||
d.put("auto_calibration_voltage", _o.getAutoCalibrationVoltage());
|
||||
d.put("needs_calibration", _o.isNeedsCalibration());
|
||||
d.put("mqtt_broker_url", _o.getMqttBrokerUrl());
|
||||
d.put("mqtt_user_name", _o.getMqttUserName());
|
||||
@@ -60,9 +57,6 @@ public class MonitorConfigSerializer extends AbstractDaoSerializer<MonitorConfig
|
||||
o.setDebug(DaoSerializer.getBoolean(_d, "debug"));
|
||||
o.setConnectTimeout(DaoSerializer.getInteger(_d, "connect_timeout"));
|
||||
o.setSocketTimeout(DaoSerializer.getInteger(_d, "socket_timeout"));
|
||||
o.setUpdateInterval(DaoSerializer.getInteger(_d, "update_interval"));
|
||||
o.setAutoUpdate(DaoSerializer.getBoolean(_d, "auto_update"));
|
||||
o.setAutoCalibrationVoltage(DaoSerializer.getFloat(_d, "auto_calibration_voltage"));
|
||||
o.setNeedsCalibration(DaoSerializer.getBoolean(_d, "needs_calibration"));
|
||||
o.setMqttBrokerUrl(DaoSerializer.getString(_d, "mqtt_broker_url"));
|
||||
o.setMqttUserName(DaoSerializer.getString(_d, "mqtt_user_name"));
|
||||
|
||||
Reference in New Issue
Block a user