Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: not all SessionEventEnum mapped to SessionInfo::State #593

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 50 additions & 26 deletions modules/API/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,43 +80,67 @@ void SessionInfo::update_state(const types::evse_manager::SessionEventEnum event
std::lock_guard<std::mutex> lock(this->session_info_mutex);
using Event = types::evse_manager::SessionEventEnum;

if (event == Event::Enabled) {
// using switch since some code analysis tools can detect missing cases
// (when new events are added)
switch (event) {
case Event::Enabled:
this->state = State::Unplugged;
} else if (event == Event::Disabled) {
break;
case Event::Disabled:
this->state = State::Disabled;
} else if (event == Event::SessionStarted) {
this->state = State::Preparing;
} else if (event == Event::ReservationStart) {
this->state = State::Reserved;
} else if (event == Event::ReservationEnd) {
this->state = State::Unplugged;
} else if (event == Event::AuthRequired) {
break;
case Event::AuthRequired:
this->state = State::AuthRequired;
} else if (event == Event::WaitingForEnergy) {
this->state = State::WaitingForEnergy;
} else if (event == Event::TransactionStarted) {
break;
case Event::PrepareCharging:
case Event::SessionStarted:
case Event::TransactionStarted:
this->state = State::Preparing;
} else if (event == Event::ChargingPausedEV) {
break;
case Event::ChargingResumed:
case Event::ChargingStarted:
this->state = State::Charging;
break;
case Event::ChargingPausedEV:
this->state = State::ChargingPausedEV;
} else if (event == Event::ChargingPausedEVSE) {
break;
case Event::ChargingPausedEVSE:
this->state = State::ChargingPausedEVSE;
} else if (event == Event::ChargingStarted) {
this->state = State::Charging;
} else if (event == Event::ChargingResumed) {
this->state = State::Charging;
} else if (event == Event::TransactionFinished) {
break;
case Event::WaitingForEnergy:
this->state = State::WaitingForEnergy;
break;
case Event::ChargingFinished:
case Event::StoppingCharging:
case Event::TransactionFinished:
this->state = State::Finished;
} else if (event == Event::SessionFinished) {
break;
case Event::ReservationStart:
this->state = State::Reserved;
break;
case Event::ReservationEnd:
case Event::SessionFinished:
this->state = State::Unplugged;
} else if (event == Event::PermanentFault) {
this->active_permanent_faults.push_back(error);
} else if (event == Event::Error) {
break;
case Event::Error:
this->active_errors.push_back(error);
} else if (event == Event::PermanentFaultCleared or event == Event::ErrorCleared) {
remove_error_from_list(this->active_permanent_faults, error.type);
} else if (event == Event::AllErrorsCleared) {
break;
case Event::AllErrorsCleared:
this->active_permanent_faults.clear();
this->active_errors.clear();
break;
case Event::PermanentFault:
this->active_permanent_faults.push_back(error);
break;
case Event::ErrorCleared:
case Event::PermanentFaultCleared:
remove_error_from_list(this->active_permanent_faults, error.type);
break;
case Event::ReplugStarted:
case Event::ReplugFinished:
case Event::PluginTimeout:
default:
break;
}
}

Expand Down
Loading