Allow calibration of all ports on a hub at once in addition to individually.

This commit is contained in:
Mark Milligan
2021-01-24 12:41:46 -06:00
parent 6c6f750691
commit fa606cce84
6 changed files with 24 additions and 12 deletions

View File

@@ -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)

View File

@@ -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) {