Skip to content

Commit

Permalink
adding curly brackets in case switch
Browse files Browse the repository at this point in the history
  • Loading branch information
perrrre committed Feb 12, 2025
1 parent e299465 commit 5a28e64
Showing 1 changed file with 52 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,76 +140,79 @@ void InternalCombustionEngineControl::Run()
}

switch (_state) {
case State::Stopped:
controlEngineStop();
case State::Stopped: {
controlEngineStop();

if (user_request == UserOnOffRequest::On && !maximumRetriesReached() && isPermittedToStart(now)) {
if (user_request == UserOnOffRequest::On && !maximumRetriesReached() && isPermittedToStart(now)) {

_state = State::Starting;
_state_start_time = now;
PX4_INFO("ICE: Starting");
_state = State::Starting;
_state_start_time = now;
PX4_INFO("ICE: Starting");
}
}

break;

case State::Starting:
controlEngineStartup(now);

if (user_request == UserOnOffRequest::Off) {
_state = State::Stopped;
_starting_retry_cycle = 0;
PX4_INFO("ICE: Abort");
case State::Starting: {
controlEngineStartup(now);

} else if (isEngineRunning(now)) {
_state = State::Running;
PX4_INFO("ICE: Starting finished");
if (user_request == UserOnOffRequest::Off) {
_state = State::Stopped;
_starting_retry_cycle = 0;
PX4_INFO("ICE: Abort");

} else if (maximumRetriesReached()) {
_state = State::Fault;
PX4_WARN("ICE: Fault");
} else if (isEngineRunning(now)) {
_state = State::Running;
PX4_INFO("ICE: Starting finished");

} else if (!isPermittedToStart(now)) {
_state = State::Stopped;
PX4_INFO("ICE: Pause Before Restart");
}
} else if (maximumRetriesReached()) {
_state = State::Fault;
PX4_WARN("ICE: Fault");

} else if (!isPermittedToStart(now)) {
_state = State::Stopped;
PX4_INFO("ICE: Pause Before Restart");
}

}
break;

case State::Running:
controlEngineRunning(throttle_in);

if (user_request == UserOnOffRequest::Off) {
_state = State::Stopped;
_starting_retry_cycle = 0;
PX4_INFO("ICE: Abort");

} else if (!isEngineRunning(now) && _param_ice_running_fault_detection.get()) {
// without RPM feedback we assume the engine is running after the
// starting procedure but only switch state if fault detection is enabled
_state = State::Fault;
_start_rest_time = now;
PX4_WARN("ICE: Running Fault detected");
case State::Running: {
controlEngineRunning(throttle_in);

if (user_request == UserOnOffRequest::Off) {
_state = State::Stopped;
_starting_retry_cycle = 0;
PX4_INFO("ICE: Abort");

} else if (!isEngineRunning(now) && _param_ice_running_fault_detection.get()) {
// without RPM feedback we assume the engine is running after the
// starting procedure but only switch state if fault detection is enabled
_state = State::Fault;
_start_rest_time = now;
PX4_WARN("ICE: Running Fault detected");
}
}

break;

case State::Fault:
case State::Fault: {

// do nothing
if (user_request == UserOnOffRequest::Off) {
_state = State::Stopped;
_starting_retry_cycle = 0;
PX4_INFO("ICE: Abort");
// do nothing
if (user_request == UserOnOffRequest::Off) {
_state = State::Stopped;
_starting_retry_cycle = 0;
PX4_INFO("ICE: Abort");

} else if (!maximumRetriesReached()) {
_state = State::Stopped;
PX4_INFO("ICE: Pause Before Restart");
} else if (!maximumRetriesReached()) {
_state = State::Stopped;
PX4_INFO("ICE: Pause Before Restart");

} else {
controlEngineFault();
} else {
controlEngineFault();
}
}


break;
}

Expand Down

0 comments on commit 5a28e64

Please sign in to comment.