Search in sources :

Example 6 with RoverStatusPacket

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));
    }
}
Also used : RoverStatusPacket(me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket) SpecialPowerControl_E02D(me.retrodaredevil.solarthing.solar.renogy.rover.special.SpecialPowerControl_E02D)

Example 7 with RoverStatusPacket

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);
        }
    }
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) RoverStatusPacket(me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket) ImmutableRoverErrorModeChangePacket(me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverErrorModeChangePacket) ImmutableRoverChargingStateChangePacket(me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverChargingStateChangePacket) RoverStatusPacket(me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket)

Example 8 with RoverStatusPacket

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);
    }
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) RoverStatusPacket(me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket) ImmutableRoverErrorModeChangePacket(me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverErrorModeChangePacket) ImmutableRoverChargingStateChangePacket(me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverChargingStateChangePacket) ImmutableRoverErrorModeChangePacket(me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverErrorModeChangePacket) ImmutableRoverChargingStateChangePacket(me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverChargingStateChangePacket) ArrayList(java.util.ArrayList)

Aggregations

RoverStatusPacket (me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket)8 Packet (me.retrodaredevil.solarthing.packets.Packet)5 MXStatusPacket (me.retrodaredevil.solarthing.solar.outback.mx.MXStatusPacket)2 ImmutableRoverChargingStateChangePacket (me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverChargingStateChangePacket)2 ImmutableRoverErrorModeChangePacket (me.retrodaredevil.solarthing.solar.renogy.rover.event.ImmutableRoverErrorModeChangePacket)2 TracerStatusPacket (me.retrodaredevil.solarthing.solar.tracer.TracerStatusPacket)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 SimpleAction (me.retrodaredevil.action.SimpleAction)1 Identifiable (me.retrodaredevil.solarthing.packets.identification.Identifiable)1 Identifier (me.retrodaredevil.solarthing.packets.identification.Identifier)1 FXStatusPacket (me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket)1 ChargerMode (me.retrodaredevil.solarthing.solar.outback.mx.ChargerMode)1 ChargingState (me.retrodaredevil.solarthing.solar.renogy.rover.ChargingState)1 LocalRoverModbusSlave (me.retrodaredevil.solarthing.solar.renogy.rover.modbus.LocalRoverModbusSlave)1 SpecialPowerControl_E02D (me.retrodaredevil.solarthing.solar.renogy.rover.special.SpecialPowerControl_E02D)1