use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket in project solarthing by wildmountainfarms.
the class RoverAnalyticsHandler method send.
private void send(PacketCollection packetCollection) {
for (Packet packet : packetCollection.getPackets()) {
if (packet instanceof RoverStatusPacket) {
RoverStatusPacket rover = (RoverStatusPacket) packet;
String data = "(" + rover.getNumber() + ") " + rover.getProductModel() + "," + rover.getRatedChargingCurrentValue();
if (!rover.supportsMesLoad()) {
data += ",no MES Load";
}
analyticsManager.sendRoverStatus(data, timer.getUptimeHours());
}
}
}
use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket in project solarthing by wildmountainfarms.
the class DummyRoverModbusSlave method createModbusSlave.
@Override
public ModbusSlave createModbusSlave() {
final FileInputStream fileInputStream;
try {
fileInputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
throw new RuntimeException("The dummy file was not found!", e);
}
final RoverStatusPacket roverStatusPacket;
try {
roverStatusPacket = MAPPER.readValue(fileInputStream, RoverStatusPacket.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
return new LocalRoverModbusSlave(roverStatusPacket);
}
use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket 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;
}
use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket in project solarthing by wildmountainfarms.
the class RoverBoostVoltageActionNode method createAction.
@Override
public Action createAction(ActionEnvironment actionEnvironment) {
RoverMatcher.Provider provider = roverMatcher.createProvider(actionEnvironment.getInjectEnvironment());
provider.validateData();
return new SimpleAction(false) {
@Override
protected void onUpdate() {
super.onUpdate();
RoverStatusPacket roverStatusPacket = provider.get();
if (roverStatusPacket == null) {
LOGGER.warn("Couldn't find rover status packet!");
return;
}
setDone((roverStatusPacket.getBoostChargingVoltageRaw() == boostVoltageRaw) != not);
}
};
}
use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket in project solarthing by wildmountainfarms.
the class PowerUtil method getPowerData.
public static Data getPowerData(PacketGroup packetGroup, GeneratingType generatingType) {
requireNonNull(packetGroup);
requireNonNull(generatingType);
Integer generatingW = null;
Integer usingW = null;
for (Packet packet : packetGroup.getPackets()) {
if (packet instanceof MXStatusPacket) {
if (generatingW == null) {
generatingW = 0;
}
if (generatingType == GeneratingType.PV_ONLY) {
generatingW += ((MXStatusPacket) packet).getPVWattage();
} else if (generatingType == GeneratingType.TOTAL_CHARGING) {
generatingW += ((MXStatusPacket) packet).getChargingPower().intValue();
} else
throw new AssertionError("Unknown generatingType: " + generatingType);
} else if (packet instanceof FXStatusPacket) {
if (usingW == null) {
usingW = 0;
}
usingW += ((FXStatusPacket) packet).getPowerUsageWattage();
} else if (packet instanceof RoverStatusPacket) {
if (generatingW == null) {
generatingW = 0;
}
if (usingW == null) {
usingW = 0;
}
if (generatingType == GeneratingType.PV_ONLY) {
generatingW += ((RoverStatusPacket) packet).getPVWattage().intValue();
} else if (generatingType == GeneratingType.TOTAL_CHARGING) {
generatingW += ((RoverStatusPacket) packet).getChargingPower();
} else
throw new AssertionError("Unknown generatingType: " + generatingType);
usingW += ((RoverStatusPacket) packet).getLoadPower();
} else if (packet instanceof TracerStatusPacket) {
if (generatingW == null) {
generatingW = 0;
}
if (usingW == null) {
usingW = 0;
}
if (generatingType == GeneratingType.PV_ONLY) {
generatingW += ((TracerStatusPacket) packet).getPVWattage().intValue();
} else if (generatingType == GeneratingType.TOTAL_CHARGING) {
generatingW += ((TracerStatusPacket) packet).getChargingPower().intValue();
} else
throw new AssertionError("Unknown generatingType: " + generatingType);
usingW += (int) ((TracerStatusPacket) packet).getLoadPower();
}
}
return new Data(generatingW, usingW);
}
Aggregations