Skip to content

Commit

Permalink
evse.cpp: improve debug logging on IsCurrentAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
dingo35 committed May 22, 2024
1 parent 2e7becc commit 1787721
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions SmartEVSE-3/src/evse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,15 +853,15 @@ char IsCurrentAvailable(void) {
// Only when StartCurrent configured or Node MinCurrent detected or Node inactive
if (Mode == MODE_SOLAR) { // no active EVSE yet?
if (ActiveEVSE == 0 && Isum >= ((signed int)StartCurrent *-10)) {
_LOG_D("No current available checkpoint A. ActiveEVSE=%i, TotalCurrent=%.1fA, StartCurrent=%iA, Isum=%.1fA, ImportCurrent=%iA.\n", ActiveEVSE, (float) TotalCurrent/10, StartCurrent, (float)Isum/10, ImportCurrent);
_LOG_D("No current available StartCurrent line %d. ActiveEVSE=%i, TotalCurrent=%.1fA, StartCurrent=%iA, Isum=%.1fA, ImportCurrent=%iA.\n", __LINE__, ActiveEVSE, (float) TotalCurrent/10, StartCurrent, (float)Isum/10, ImportCurrent);
return 0;
}
else if ((ActiveEVSE * MinCurrent * 10) > TotalCurrent) { // check if we can split the available current between all active EVSE's
_LOG_D("No current available checkpoint B. ActiveEVSE=%i, TotalCurrent=%.1fA, StartCurrent=%iA, Isum=%.1fA, ImportCurrent=%iA.\n", ActiveEVSE, (float) TotalCurrent/10, StartCurrent, (float)Isum/10, ImportCurrent);
_LOG_D("No current available TotalCurrent line %d. ActiveEVSE=%i, TotalCurrent=%.1fA, StartCurrent=%iA, Isum=%.1fA, ImportCurrent=%iA.\n", __LINE__, ActiveEVSE, (float) TotalCurrent/10, StartCurrent, (float)Isum/10, ImportCurrent);
return 0;
}
else if (ActiveEVSE > 0 && Isum > ((signed int)ImportCurrent * 10) + TotalCurrent - (ActiveEVSE * MinCurrent * 10)) {
_LOG_D("No current available checkpoint C. ActiveEVSE=%i, TotalCurrent=%.1fA, StartCurrent=%iA, Isum=%.1fA, ImportCurrent=%iA.\n", ActiveEVSE, (float) TotalCurrent/10, StartCurrent, (float)Isum/10, ImportCurrent);
_LOG_D("No current available Isum line %d. ActiveEVSE=%i, TotalCurrent=%.1fA, StartCurrent=%iA, Isum=%.1fA, ImportCurrent=%iA.\n", __LINE__, ActiveEVSE, (float) TotalCurrent/10, StartCurrent, (float)Isum/10, ImportCurrent);
return 0;
}
}
Expand All @@ -874,16 +874,19 @@ char IsCurrentAvailable(void) {

// Check if the lowest charge current(6A) x ActiveEV's + baseload would be higher then the MaxMains.
if ((ActiveEVSE * (MinCurrent * 10) + Baseload) > (MaxMains * 10)) {
_LOG_D("No current available MaxMains line %d. ActiveEVSE=%i, Baseload=%.1fA, MinCurrent=%iA, MaxMains=%iA.\n", __LINE__, ActiveEVSE, (float) Baseload/10, MinCurrent, MaxMains);
return 0; // Not enough current available!, return with error
}
if ((ActiveEVSE * (MinCurrent * 10) + Baseload_EV) > (MaxCircuit * 10)) {
_LOG_D("No current available MaxCircuit line %d. ActiveEVSE=%i, Baseload_EV=%.1fA, MinCurrent=%iA, MaxCircuit=%iA.\n", __LINE__, ActiveEVSE, (float) Baseload_EV/10, MinCurrent, MaxCircuit);
return 0; // Not enough current available!, return with error
}
//assume the current should be available on all 3 phases
bool must_be_single_phase_charging = (EnableC2 == ALWAYS_OFF || (Mode == MODE_SOLAR && EnableC2 == SOLAR_OFF) ||
(Mode == MODE_SOLAR && EnableC2 == AUTO && Switching_To_Single_Phase == AFTER_SWITCH));
int Phases = must_be_single_phase_charging ? 1 : 3;
if ((Phases * ActiveEVSE * (MinCurrent * 10) + Isum) > (MaxSumMains * 10)) {
_LOG_D("No current available MaxSumMains line %d. ActiveEVSE=%i, MinCurrent=%iA, Isum=%.1fA, MaxSumMains=%iA.\n", __LINE__, ActiveEVSE, MinCurrent, (float)Isum/10, MaxSumMains);
return 0; // Not enough current available!, return with error
}

Expand Down

0 comments on commit 1787721

Please sign in to comment.