Search in sources :

Example 1 with AddStatusParametersBuilder

use of me.retrodaredevil.solarthing.pvoutput.data.AddStatusParametersBuilder in project solarthing by wildmountainfarms.

the class PVOutputHandler method getStatus.

public AddStatusParameters getStatus(long dayStartTimeMillis, List<FragmentedPacketGroup> packetGroupList) {
    FragmentedPacketGroup latestPacketGroup = packetGroupList.get(packetGroupList.size() - 1);
    LOGGER.debug("Continuing with the latest packet group. Day start: " + dayStartTimeMillis);
    AddStatusParametersBuilder addStatusParametersBuilder = createStatusBuilder(zoneId, latestPacketGroup.getDateMillis());
    setStatusPowerValues(addStatusParametersBuilder, latestPacketGroup);
    setStatusEnergyValues(addStatusParametersBuilder, packetGroupList, AccumulationConfig.createDefault(dayStartTimeMillis));
    for (Packet packet : latestPacketGroup.getPackets()) {
        if (packet instanceof PVCurrentAndVoltage) {
            int fragmentId = latestPacketGroup.getFragmentId(packet);
            PVCurrentAndVoltage pvCurrentAndVoltage = (PVCurrentAndVoltage) packet;
            IdentifierFragment identifierFragment = IdentifierFragment.create(fragmentId, pvCurrentAndVoltage.getIdentifier());
            if (voltageIdentifierFragmentMatcher.matches(identifierFragment)) {
                float voltage = pvCurrentAndVoltage.getPVVoltage().floatValue();
                addStatusParametersBuilder.setVoltage(voltage);
            }
        } else if (packet instanceof TemperaturePacket) {
            int fragmentId = latestPacketGroup.getFragmentId(packet);
            TemperaturePacket temperaturePacket = (TemperaturePacket) packet;
            IdentifierFragment identifierFragment = IdentifierFragment.create(fragmentId, temperaturePacket.getIdentifier());
            if (temperatureIdentifierFragmentMatcher.matches(identifierFragment)) {
                float temperatureCelsius = temperaturePacket.getTemperatureCelsius();
                if (!TemperaturePacket.POSSIBLE_BAD_VALUES.contains(temperatureCelsius)) {
                    addStatusParametersBuilder.setTemperatureCelsius(temperatureCelsius);
                } else {
                    LOGGER.info("Not setting temperature: " + temperatureCelsius + " because it could be a bad reading");
                }
            }
        }
    }
    return addStatusParametersBuilder.build();
}
Also used : FragmentedPacketGroup(me.retrodaredevil.solarthing.packets.collection.FragmentedPacketGroup) Packet(me.retrodaredevil.solarthing.packets.Packet) DailyFXPacket(me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket) TemperaturePacket(me.retrodaredevil.solarthing.misc.weather.TemperaturePacket) IdentifierFragment(me.retrodaredevil.solarthing.packets.identification.IdentifierFragment) PVCurrentAndVoltage(me.retrodaredevil.solarthing.solar.common.PVCurrentAndVoltage) AddStatusParametersBuilder(me.retrodaredevil.solarthing.pvoutput.data.AddStatusParametersBuilder) TemperaturePacket(me.retrodaredevil.solarthing.misc.weather.TemperaturePacket)

Example 2 with AddStatusParametersBuilder

use of me.retrodaredevil.solarthing.pvoutput.data.AddStatusParametersBuilder in project solarthing by wildmountainfarms.

the class PVOutputHandler method createStatusBuilder.

private static AddStatusParametersBuilder createStatusBuilder(ZoneId zoneId, long dateMillis) {
    LocalDateTime localDateTime = Instant.ofEpochMilli(dateMillis).atZone(zoneId).toLocalDateTime();
    SimpleDate date = SimpleDate.fromTemporal(localDateTime);
    SimpleTime time = SimpleTime.fromTemporal(localDateTime);
    return new AddStatusParametersBuilder(date, time);
}
Also used : LocalDateTime(java.time.LocalDateTime) SimpleTime(me.retrodaredevil.solarthing.pvoutput.SimpleTime) SimpleDate(me.retrodaredevil.solarthing.pvoutput.SimpleDate) AddStatusParametersBuilder(me.retrodaredevil.solarthing.pvoutput.data.AddStatusParametersBuilder)

Aggregations

AddStatusParametersBuilder (me.retrodaredevil.solarthing.pvoutput.data.AddStatusParametersBuilder)2 LocalDateTime (java.time.LocalDateTime)1 TemperaturePacket (me.retrodaredevil.solarthing.misc.weather.TemperaturePacket)1 Packet (me.retrodaredevil.solarthing.packets.Packet)1 FragmentedPacketGroup (me.retrodaredevil.solarthing.packets.collection.FragmentedPacketGroup)1 IdentifierFragment (me.retrodaredevil.solarthing.packets.identification.IdentifierFragment)1 SimpleDate (me.retrodaredevil.solarthing.pvoutput.SimpleDate)1 SimpleTime (me.retrodaredevil.solarthing.pvoutput.SimpleTime)1 PVCurrentAndVoltage (me.retrodaredevil.solarthing.solar.common.PVCurrentAndVoltage)1 DailyFXPacket (me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket)1