use of me.retrodaredevil.solarthing.solar.tracer.mode.ChargingStatus in project solarthing by wildmountainfarms.
the class RequireFullOutputActionNode method isFullOutput.
private boolean isFullOutput(FragmentedPacketGroup latestPacketGroup) {
for (Map.Entry<Integer, List<String>> entry : requiredIdentifierMap.entrySet()) {
int desiredFragmentId = entry.getKey();
if (!latestPacketGroup.hasFragmentId(desiredFragmentId)) {
continue;
}
for (String desiredIdentifierRepresentation : entry.getValue()) {
for (Packet packet : latestPacketGroup.getPackets()) {
int fragmentId = latestPacketGroup.getFragmentId(packet);
if (fragmentId != desiredFragmentId) {
continue;
}
if (packet instanceof Identifiable) {
Identifier identifier = ((Identifiable) packet).getIdentifier();
if (desiredIdentifierRepresentation.equals(identifier.getRepresentation())) {
if (packet instanceof MXStatusPacket) {
MXStatusPacket mx = (MXStatusPacket) packet;
ChargerMode mode = mx.getChargingMode();
// Some old MX firmwares consistently report being in float mode after a full absorb cycle even after the daily reset.
// This configuration option allows us to treat float as full output for a given MX
boolean canIgnoreFloatMode = ignoreReportedMXFloatMap.getOrDefault(fragmentId, Collections.emptyList()).contains(desiredIdentifierRepresentation);
if (mode != ChargerMode.SILENT && mode != ChargerMode.BULK && (!canIgnoreFloatMode || mode != ChargerMode.FLOAT)) {
if (log) {
LOGGER.info(identifier.getRepresentation() + " on fragment " + fragmentId + " is in mode " + mode.getModeName());
}
return false;
}
} else if (packet instanceof RoverStatusPacket) {
RoverStatusPacket rover = (RoverStatusPacket) packet;
ChargingState state = rover.getChargingMode();
if (state != ChargingState.ACTIVATED && state != ChargingState.DEACTIVATED && state != ChargingState.MPPT) {
if (log) {
LOGGER.info(identifier.getRepresentation() + " on fragment " + fragmentId + " is in mode " + state.getModeName());
}
return false;
}
} else if (packet instanceof TracerStatusPacket) {
TracerStatusPacket tracer = (TracerStatusPacket) packet;
ChargingStatus status = tracer.getChargingMode();
// we currently cannot tell if while in BOOST or EQUALIZE if the controller is actually in Bulk, so float is the only mode we know that isn't at full output
if (status == ChargingStatus.FLOAT) {
if (log) {
LOGGER.info(identifier.getRepresentation() + " on fragment " + fragmentId + " is in mode " + status.getModeName());
}
return false;
}
}
}
}
}
}
}
return true;
}
Aggregations