Search in sources :

Example 1 with DailyFXPacket

use of me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket in project solarthing by wildmountainfarms.

the class FXDailyData method isNewDay.

@Override
default boolean isNewDay(DailyData previousDailyData) {
    if (!(previousDailyData instanceof FXDailyData)) {
        throw new IllegalArgumentException("previousDailyData is not a FXDailyData! It's: " + previousDailyData.getClass().getName());
    }
    DailyFXPacket previous = (DailyFXPacket) previousDailyData;
    /*
		In the early versions of DailyFXPacket, startDateMillis was not serialized. In new versions, they are always serialized.
		This is why we have to perform a null check and deal with either one being null. (One could be a packet from a previous version)

		However, this happened for like less than a week such a long time ago, that I'm thinking about ditching support for those packets.
		As of 2020.05.09, there's not really a way to ditch support for packets gracefully. Maybe there will be in the future.
		 */
    Long dateMillis = getStartDateMillis();
    Long previousMillis = previous.getStartDateMillis();
    if (dateMillis != null && previousMillis != null) {
        return dateMillis > previousMillis;
    }
    return getInverterKWH() < previous.getInverterKWH() || getChargerKWH() < previous.getChargerKWH() || getBuyKWH() < previous.getBuyKWH() || getSellKWH() < previous.getSellKWH();
}
Also used : DailyFXPacket(me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket)

Aggregations

DailyFXPacket (me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket)1