use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket in project solarthing by wildmountainfarms.
the class RoverPacketListUpdater method receive.
@Override
public void receive(List<Packet> packets) {
RoverStatusPacket packet = RoverStatusPackets.createFromReadTable(number, read);
SpecialPowerControl_E02D specialPower2 = packet.getSpecialPowerControlE02D();
LOGGER.debug(SolarThingConstants.NO_CONSOLE, "Debugging special power control values: (Will debug all packets later)\n" + packet.getSpecialPowerControlE021().getFormattedInfo().replaceAll("\n", "\n\t") + (specialPower2 == null ? "" : "\n" + specialPower2.getFormattedInfo().replaceAll("\n", "\n\t")));
packets.add(packet);
if (connectionHandler != null) {
connectionHandler.handleRequests(request -> NetCatUtil.handle(write, packet, request));
}
}
use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket in project solarthing by wildmountainfarms.
the class RoverEventUpdaterListReceiver method receive.
@Override
public void receive(List<Packet> packets) {
for (Packet packet : packets) {
if (packet instanceof RoverStatusPacket) {
RoverStatusPacket rover = (RoverStatusPacket) packet;
RoverStatusPacket previous = previousPacketMap.get(rover.getIdentifier());
previousPacketMap.put(rover.getIdentifier(), rover);
useData(rover, previous);
}
}
}
use of me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket in project solarthing by wildmountainfarms.
the class RoverEventUpdaterListReceiver method useData.
private void useData(@NotNull RoverStatusPacket rover, @Nullable RoverStatusPacket previous) {
final Integer lastChargingStateValue;
final Integer lastErrorModeValue;
if (previous == null) {
lastChargingStateValue = null;
lastErrorModeValue = null;
} else {
lastChargingStateValue = previous.getChargingStateValue();
lastErrorModeValue = previous.getErrorModeValue();
}
int currentChargingStateValue = rover.getChargingStateValue();
int currentErrorModeValue = rover.getErrorModeValue();
List<Packet> packets = new ArrayList<>();
if (lastChargingStateValue == null || lastChargingStateValue != currentChargingStateValue) {
packets.add(new ImmutableRoverChargingStateChangePacket(rover.getIdentifier(), currentChargingStateValue, lastChargingStateValue));
}
if (lastErrorModeValue == null || lastErrorModeValue != currentErrorModeValue) {
packets.add(new ImmutableRoverErrorModeChangePacket(rover.getIdentifier(), currentErrorModeValue, lastErrorModeValue));
}
if (!packets.isEmpty()) {
eventReceiver.receive(packets);
}
}
Aggregations