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();
}
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);
}
Aggregations