Skip to content

Commit

Permalink
add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBoehm committed Jun 18, 2024
1 parent d51d9ae commit 560b519
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,14 +724,22 @@ static int32_t scalePowerLimit(std::shared_ptr<InverterAbstract> inverter, int32
// overscalling allows us to compensate for shaded panels by increasing the
// total power limit, if the inverter is solar powered.
if (allowOverscaling && isInverterSolarPowered) {
auto inverterInputDC = inverter->Statistics()->getChannelFieldValue(TYPE_INV, CH0, FLD_PDC);
auto inverterOutputAC = inverter->Statistics()->getChannelFieldValue(TYPE_AC, CH0, FLD_PAC);
float inverterEfficiencyFactor = getInverterEfficiency(inverter);

// 98% of the expected power is good enough
auto expectedAcPowerPerChannel = (currentLimitWatts / dcTotalChnls) * 0.98;

// TODO(AndreasBoehm): REMOVE debug log
MessageOutput.printf("[DPL::scalePowerLimit::debug] checking for shading, "
"inverterInputDC %f W, inverterOutputAC %f W, inverterEfficiencyFactor %f, "
"expectedAcPowerPerChannel %f W, currentLimitWatts %d W, newLimit %d W\r\n",
inverterInputDC, inverterOutputAC, inverterEfficiencyFactor,
expectedAcPowerPerChannel, currentLimitWatts, newLimit);

size_t dcShadedChnls = 0;
auto shadedChannelACPowerSum = 0;
auto shadedChannelACPowerSum = 0.0;

for (auto& c : dcChnls) {
auto channelPowerDC = inverter->Statistics()->getChannelFieldValue(TYPE_DC, c, FLD_PDC);
Expand All @@ -740,9 +748,20 @@ static int32_t scalePowerLimit(std::shared_ptr<InverterAbstract> inverter, int32
if (channelPowerAC < expectedAcPowerPerChannel) {
dcShadedChnls++;
shadedChannelACPowerSum += channelPowerAC;

// TODO(AndreasBoehm): REMOVE debug log
MessageOutput.printf("[DPL::scalePowerLimit::debug] channel %d is producing less than expected, "
"channelPowerAC %f W, channelPowerDC %f W\r\n",
c, channelPowerAC, channelPowerDC);
}
}

// TODO(AndreasBoehm): REMOVE debug log
MessageOutput.printf("[DPL::scalePowerLimit] %d/%d channels are producing less than expected, "
"shadedChannelACPowerSum %f W\r\n",
dcShadedChnls, dcTotalChnls,
shadedChannelACPowerSum);

// no shading or the shaded channels provide more power than what
// we currently need.
if (dcShadedChnls == 0 || shadedChannelACPowerSum >= newLimit) { return newLimit; }
Expand Down

0 comments on commit 560b519

Please sign in to comment.