Skip to content

Commit e7d130c

Browse files
authored
modules: EVSE/EvseManager: correctly set phases for PP ampacity selection if a A_63_3ph_70_1ph cable is plugged (EVerest#1791)
Signed-off-by: Jannis Albert <albertjannis@gmail.com>
1 parent 16bd96b commit e7d130c

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

modules/EVSE/EvseManager/EvseManager.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,22 @@ void EvseManager::init() {
281281

282282
signalNrOfPhasesAvailable(ac_nr_phases_active);
283283

284-
bsp->set_three_phases(c.max_phase_count_import);
284+
const auto get_max_phases = [](int max_phase_count) -> AcPhases {
285+
switch (max_phase_count) {
286+
case 1:
287+
return AcPhases::SinglePhase;
288+
case 2:
289+
return AcPhases::TwoPhases;
290+
case 3:
291+
return AcPhases::ThreePhases;
292+
293+
default:
294+
EVLOG_warning << "Invalid max_phase_count of " << max_phase_count << ". Falling back to single phase";
295+
}
296+
return AcPhases::SinglePhase;
297+
};
298+
299+
bsp->set_max_phases(get_max_phases(c.max_phase_count_import));
285300
charger->set_connector_type(c.connector_type);
286301
p_evse->publish_hw_capabilities(c);
287302
if (config.charge_mode == "AC" and hlc_enabled) {

modules/EVSE/EvseManager/IECStateMachine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,10 @@ void IECStateMachine::set_pp_ampacity(types::board_support_common::ProximityPilo
441441
pp_ampacity = 32.;
442442
break;
443443
case types::board_support_common::Ampacity::A_63_3ph_70_1ph:
444-
if (three_phases) {
445-
pp_ampacity = 63.;
446-
} else {
444+
if (max_phases == AcPhases::SinglePhase) {
447445
pp_ampacity = 70.;
446+
} else {
447+
pp_ampacity = 63.;
448448
}
449449
break;
450450
default:

modules/EVSE/EvseManager/IECStateMachine.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ enum class RawCPState {
6666
F
6767
};
6868

69+
// Number of active phases for AC charging
70+
enum class AcPhases {
71+
SinglePhase,
72+
TwoPhases,
73+
ThreePhases
74+
};
75+
6976
class IECStateMachine {
7077
public:
7178
// We need the r_bsp reference to be able to talk to the bsp driver module
@@ -87,8 +94,8 @@ class IECStateMachine {
8794
void set_cp_state_X1();
8895
void set_cp_state_F();
8996

90-
void set_three_phases(bool t) {
91-
three_phases = t;
97+
void set_max_phases(AcPhases phases) {
98+
max_phases = phases;
9299
}
93100

94101
void enable(bool en);
@@ -123,7 +130,7 @@ class IECStateMachine {
123130
bool last_power_on_allowed{false};
124131
std::atomic<double> pp_ampacity{0.0};
125132
std::atomic<double> last_amps{-1};
126-
std::atomic_bool three_phases{true};
133+
std::atomic<AcPhases> max_phases{AcPhases::ThreePhases};
127134

128135
bool car_plugged_in{false};
129136

0 commit comments

Comments
 (0)