use of me.retrodaredevil.solarthing.solar.common.PVCurrentAndVoltage 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();
}
Aggregations