use of me.retrodaredevil.solarthing.solar.tracer.event.ImmutableTracerChargingEquipmentStatusChangePacket in project solarthing by wildmountainfarms.
the class TracerEventUpdaterListReceiver method useData.
private void useData(@NotNull TracerStatusPacket tracer, @Nullable TracerStatusPacket previous) {
final Integer lastChargingEquipmentStatusValue;
if (previous == null) {
lastChargingEquipmentStatusValue = null;
} else {
lastChargingEquipmentStatusValue = previous.getChargingEquipmentStatus();
}
int currentChargingEquipmentStatusValue = tracer.getChargingEquipmentStatus();
List<Packet> packets = new ArrayList<>();
if (lastChargingEquipmentStatusValue == null || lastChargingEquipmentStatusValue != currentChargingEquipmentStatusValue) {
packets.add(new ImmutableTracerChargingEquipmentStatusChangePacket(tracer.getIdentifier(), currentChargingEquipmentStatusValue, lastChargingEquipmentStatusValue));
}
if (!packets.isEmpty()) {
eventReceiver.receive(packets);
}
}
use of me.retrodaredevil.solarthing.solar.tracer.event.ImmutableTracerChargingEquipmentStatusChangePacket in project solarthing by wildmountainfarms.
the class TracerTest method testTracerEvents.
@Test
void testTracerEvents() throws JsonProcessingException {
// 1 is off
// 15 is something that is not off idk what tho
PacketTestUtil.testJson(new ImmutableTracerChargingEquipmentStatusChangePacket(TracerIdentifier.getFromNumber(0), 1, 15), SolarEventPacket.class);
PacketTestUtil.testJson(new ImmutableTracerChargingEquipmentStatusChangePacket(TracerIdentifier.getFromNumber(1), 15, null), SolarEventPacket.class);
}
Aggregations