Skip to content

Commit

Permalink
resolving merge conflict
Browse files Browse the repository at this point in the history
adding missing statement from merge

fixing a bug introduced in merge
  • Loading branch information
MalteSchm committed Apr 13, 2023
1 parent fc5089e commit 9efe076
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ int32_t PowerLimiterClass::calcPowerLimit(std::shared_ptr<InverterAbstract> inve
int32_t newPowerLimit = round(PowerMeter.getPowerTotal());

// Safety check, return on too old power meter values
if ((millis() - PowerMeter.getLastPowerMeterUpdate()) > (30 * 1000)) {
// If the power meter values are older than 30 seconds,
if (millis() - PowerMeter.getLastPowerMeterUpdate() > (30 * 1000)
&& (millis() - inverter->Statistics()->getLastUpdate()) > (config.Dtu_PollInterval * 3 * 1000)) {
// If the power meter values are older than 30 seconds,
// and the Inverter Stats are older then 3x the poll interval
// set the limit to config.PowerLimiter_LowerPowerLimit for safety reasons.
MessageOutput.println("[PowerLimiterClass::loop] Power Meter values too old. Using lower limit");
return config.PowerLimiter_LowerPowerLimit;
Expand All @@ -193,8 +195,9 @@ int32_t PowerLimiterClass::calcPowerLimit(std::shared_ptr<InverterAbstract> inve
// If the inverter the behind the power meter (part of measurement),
// the produced power of this inverter has also to be taken into account.
// We don't use FLD_PAC from the statistics, because that
// data might be too old and unrelieable.
newPowerLimit += _lastRequestedPowerLimit;
// data might be too old and unreliable.
float acPower = inverter->Statistics()->getChannelFieldValue(TYPE_AC, (ChannelNum_t) config.PowerLimiter_InverterChannelId, FLD_PAC);
newPowerLimit += static_cast<int>(acPower);
}

float efficency = inverter->Statistics()->getChannelFieldValue(TYPE_AC, (ChannelNum_t) config.PowerLimiter_InverterChannelId, FLD_EFF);
Expand All @@ -217,7 +220,7 @@ int32_t PowerLimiterClass::calcPowerLimit(std::shared_ptr<InverterAbstract> inve

int32_t upperPowerLimit = config.PowerLimiter_UpperPowerLimit;
if (consumeSolarPowerOnly && (upperPowerLimit > adjustedVictronChargePower)) {
// Battery voltage too low, use Victron solar power (corrected by efficency factor) only
// Battery voltage too low, use Victron solar power (corrected by efficiency factor) only
upperPowerLimit = adjustedVictronChargePower;
}

Expand Down

0 comments on commit 9efe076

Please sign in to comment.