Support using one CT to monitor a double breaker by only monitoring one pole and doubling its power.

This commit is contained in:
MarkBryanMilligan 2021-02-26 10:56:05 -06:00
parent afe5faf536
commit a75231dc43
5 changed files with 23 additions and 4 deletions

View File

@ -99,7 +99,8 @@ public class CurrentMonitor {
public void monitorPower(BreakerHub _hub, List<Breaker> _breakers, int _intervalMs, PowerListener _listener) { public void monitorPower(BreakerHub _hub, List<Breaker> _breakers, int _intervalMs, PowerListener _listener) {
stopMonitoring(); stopMonitoring();
listener = _listener; listener = _listener;
sampler = new Sampler(_hub, _breakers, _intervalMs, 2); List<Breaker> validBreakers = CollectionUtils.filter(_breakers, _b->_b.getPort() > 0 && _b.getPort() < 16);
sampler = new Sampler(_hub, validBreakers, _intervalMs, 2);
LOG.info("Starting to monitor ports {}", CollectionUtils.transformToCommaSeparated(_breakers, _b->String.valueOf(_b.getPort()))); LOG.info("Starting to monitor ports {}", CollectionUtils.transformToCommaSeparated(_breakers, _b->String.valueOf(_b.getPort())));
executor.submit(sampler); executor.submit(sampler);
} }
@ -241,6 +242,8 @@ public class CurrentMonitor {
realPower = 0.0; realPower = 0.0;
if (samples.getBreaker().getPolarity() == BreakerPolarity.SOLAR) if (samples.getBreaker().getPolarity() == BreakerPolarity.SOLAR)
realPower = -realPower; realPower = -realPower;
if (samples.getBreaker().isDoublePower())
realPower *= 2.0;
if (debug) { if (debug) {
synchronized (CurrentMonitor.this) { synchronized (CurrentMonitor.this) {
LOG.info("===========================Start Port {}", samples.getBreaker().getPort()); LOG.info("===========================Start Port {}", samples.getBreaker().getPort());

View File

@ -110,7 +110,7 @@ public class MongoCurrentMonitorDao implements CurrentMonitorDao {
@Override @Override
public List<BreakerPower> getBreakerPowerForAccount(int _accountId) { public List<BreakerPower> getBreakerPowerForAccount(int _accountId) {
return proxy.query(BreakerPower.class, new DaoQuery("account_id", _accountId)); return proxy.query(BreakerPower.class, new DaoQuery("account_id", _accountId).andGt("read_time", DateUtils.minutesFromNow(-1).getTime()));
} }
@Override @Override

View File

@ -21,6 +21,7 @@ public class Breaker {
private double calibrationFactor; private double calibrationFactor;
private double lowPassFilter; private double lowPassFilter;
private BreakerPolarity polarity; private BreakerPolarity polarity;
private boolean doublePower;
private BreakerType type; private BreakerType type;
private transient String key; private transient String key;
@ -151,6 +152,14 @@ public class Breaker {
polarity = _polarity; polarity = _polarity;
} }
public boolean isDoublePower() {
return doublePower;
}
public void setDoublePower(boolean _doublePower) {
doublePower = _doublePower;
}
public double getCalibrationFactor() { public double getCalibrationFactor() {
return calibrationFactor == 0.0?1.0:calibrationFactor; return calibrationFactor == 0.0?1.0:calibrationFactor;
} }

View File

@ -9,7 +9,8 @@ public enum BreakerType {
EMPTY("Empty"), EMPTY("Empty"),
SINGLE_POLE("Single Pole"), SINGLE_POLE("Single Pole"),
SINGLE_POLE_TANDEM("Single Pole Tandem (Two Breakers in One)"), SINGLE_POLE_TANDEM("Single Pole Tandem (Two Breakers in One)"),
DOUBLE_POLE_TOP("Double Pole (240V)"), DOUBLE_POLE_TOP("Double Pole (240V) Two CTs"),
DOUBLE_POLE_TOP_ONE_CT("Double Pole (240V) One CT Doubled"),
DOUBLE_POLE_BOTTOM("Double Pole (240V)"); DOUBLE_POLE_BOTTOM("Double Pole (240V)");
private final String display; private final String display;
@ -23,7 +24,7 @@ public enum BreakerType {
} }
public static List<BreakerType> selectable() { public static List<BreakerType> selectable() {
return CollectionUtils.asArrayList(EMPTY, SINGLE_POLE, SINGLE_POLE_TANDEM, DOUBLE_POLE_TOP); return CollectionUtils.asArrayList(EMPTY, SINGLE_POLE, SINGLE_POLE_TANDEM, DOUBLE_POLE_TOP, DOUBLE_POLE_TOP_ONE_CT);
} }
public static BreakerType fromDisplay(String _display) { public static BreakerType fromDisplay(String _display) {
@ -33,4 +34,8 @@ public enum BreakerType {
} }
return null; return null;
} }
public static boolean isDoublePoleTop(BreakerType _type) {
return NullUtils.isOneOf(_type, DOUBLE_POLE_TOP, DOUBLE_POLE_TOP_ONE_CT);
}
} }

View File

@ -38,6 +38,7 @@ public class BreakerSerializer extends AbstractDaoSerializer<Breaker>
d.put("calibration_factor", _o.getCalibrationFactor()); d.put("calibration_factor", _o.getCalibrationFactor());
d.put("low_pass_filter", _o.getLowPassFilter()); d.put("low_pass_filter", _o.getLowPassFilter());
d.put("polarity", DaoSerializer.toEnumName(_o.getPolarity())); d.put("polarity", DaoSerializer.toEnumName(_o.getPolarity()));
d.put("double_power", _o.isDoublePower());
d.put("type", DaoSerializer.toEnumName(_o.getType())); d.put("type", DaoSerializer.toEnumName(_o.getType()));
return d; return d;
} }
@ -57,6 +58,7 @@ public class BreakerSerializer extends AbstractDaoSerializer<Breaker>
o.setCalibrationFactor(DaoSerializer.getDouble(_d, "calibration_factor")); o.setCalibrationFactor(DaoSerializer.getDouble(_d, "calibration_factor"));
o.setLowPassFilter(DaoSerializer.getDouble(_d, "low_pass_filter")); o.setLowPassFilter(DaoSerializer.getDouble(_d, "low_pass_filter"));
o.setPolarity(DaoSerializer.getEnum(_d, "polarity", BreakerPolarity.class)); o.setPolarity(DaoSerializer.getEnum(_d, "polarity", BreakerPolarity.class));
o.setDoublePower(DaoSerializer.getBoolean(_d, "double_power"));
o.setType(DaoSerializer.getEnum(_d, "type", BreakerType.class)); o.setType(DaoSerializer.getEnum(_d, "type", BreakerType.class));
return o; return o;
} }