mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Allow calibration of all ports on a hub at once in addition to individually.
This commit is contained in:
@@ -85,7 +85,7 @@ public class CurrentMonitor {
|
||||
vRms /= samples.size();
|
||||
double oldVrms = _curCalibration * Math.sqrt(vRms);
|
||||
if (oldVrms < 20) {
|
||||
LOG.info("Could not get a valid voltage read, please check that your AC/AC transformer is connected");
|
||||
LOG.error("Could not get a valid voltage read, please check that your AC/AC transformer is connected");
|
||||
return 0.0;
|
||||
}
|
||||
double newCal = (_voltage/oldVrms) * _curCalibration;
|
||||
@@ -235,7 +235,7 @@ public class CurrentMonitor {
|
||||
vRms /= validSamples.size();
|
||||
vRms = hub.getVoltageCalibrationFactor() * Math.sqrt(vRms);
|
||||
int lowSampleRatio = (lowSamples * 100) / samples.getSampleCnt();
|
||||
double realPower = Math.abs((hub.getVoltageCalibrationFactor() * samples.getBreaker().getFinalCalibrationFactor() * pSum) / samples.getSampleCnt());
|
||||
double realPower = Math.abs((hub.getVoltageCalibrationFactor() * hub.getPortCalibrationFactor() * samples.getBreaker().getFinalCalibrationFactor() * pSum) / samples.getSampleCnt());
|
||||
if ((lowSampleRatio > 75) && realPower < 13.0)
|
||||
realPower = 0.0;
|
||||
if (samples.getBreaker().getPolarity() == BreakerPolarity.SOLAR)
|
||||
|
||||
@@ -160,10 +160,8 @@ public class MonitorApp {
|
||||
}
|
||||
});
|
||||
monitor.submit(bluetoothConfig);
|
||||
if (NullUtils.isNotEmpty(config.getAuthCode())) {
|
||||
if (NullUtils.isNotEmpty(config.getAuthCode()))
|
||||
authCode = config.getAuthCode();
|
||||
//TODO: check auth code validity
|
||||
}
|
||||
else {
|
||||
HttpGet auth = new HttpGet(host + "auth");
|
||||
HttpPool.addBasicAuthHeader(auth, config.getUsername(), config.getPassword());
|
||||
@@ -187,7 +185,7 @@ public class MonitorApp {
|
||||
hub.setVoltageCalibrationFactor(newCal);
|
||||
config.setNeedsCalibration(false);
|
||||
ResourceLoader.writeFile(WORKING_DIR + "config.json", DaoSerializer.toJson(config));
|
||||
post(DaoSerializer.toZipBson(breakerConfig), "currentmonitor/config");
|
||||
post(DaoSerializer.toZipBson(breakerConfig), "config");
|
||||
}
|
||||
}
|
||||
List<Breaker> breakers = breakerConfig.getBreakersForHub(config.getHub());
|
||||
@@ -341,6 +339,7 @@ public class MonitorApp {
|
||||
if (CollectionUtils.length(jar) == DaoSerializer.getInteger(meta, "size") && NullUtils.isEqual(DigestUtils.md5Hex(jar), DaoSerializer.getString(meta, "checksum"))) {
|
||||
LOG.info("Update downloaded, writing jar and restarting...");
|
||||
ResourceLoader.writeFile(WORKING_DIR + "lantern-currentmonitor.jar", jar);
|
||||
ConcurrencyUtils.sleep(5000);
|
||||
try {
|
||||
Runtime.getRuntime().exec("service currentmonitor restart");
|
||||
} catch (IOException _e) {
|
||||
|
||||
Reference in New Issue
Block a user