Skip to content

Commit

Permalink
refactor: change condition to explicit boolean comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Akram authored and Akram committed Sep 10, 2024
1 parent 277885c commit 4ae6987
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions lib/APPReinforcementLearning/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,56 +125,56 @@ void App::loop()
payload = {SMPChannelPayload::Status::DONE};
}

isDataSent = m_smpServer.sendData(m_serialMuxProtChannelIdStatus, &payload, sizeof(payload));
if (false == m_smpServer.sendData(m_serialMuxProtChannelIdStatus, &payload, sizeof(payload)))
{
/* Failed to send Status data to the Supervisor. Go to error state. */
ErrorState::getInstance().setErrorMsg("SD_SF");
m_systemStateMachine.setState(&ErrorState::getInstance());
}
else
{
m_statusTimer.restart();
}

m_statusTimer.restart();

}

if (false == isDataSent)
{
/* Failed to send Status data to the Supervisor. Go to error state. */
ErrorState::getInstance().setErrorMsg("SD_SF");
m_systemStateMachine.setState(&ErrorState::getInstance());
}
else
/* Send periodically line sensor data. */
if (true == m_sendLineSensorsDataInterval.isTimeout() &&
(&DrivingState::getInstance() == m_systemStateMachine.getState()))
{
/* Send periodically line sensor data. */
if (true == m_sendLineSensorsDataInterval.isTimeout() &&
(&DrivingState::getInstance() == m_systemStateMachine.getState()))
{
isDataSent = sendLineSensorsData();

m_sendLineSensorsDataInterval.restart();
}
if (false == isDataSent)
if (false == sendLineSensorsData())
{
/* Failed to send Sensor data to the Supervisor. Go to error state. */
ErrorState::getInstance().setErrorMsg("SEND_SF");
m_systemStateMachine.setState(&ErrorState::getInstance());
}
else
{
/* Send Mode selected to The Supervisor. */
if (&ReadyState::getInstance() == m_systemStateMachine.getState() && (false == m_modeSelectionSent))
{
uint8_t mode_options = ReadyState::getInstance().getSelectedMode();
m_sendLineSensorsDataInterval.restart();
}
}

if (0U < mode_options)
{
SMPChannelPayload::Mode payload =
(1 == mode_options) ? SMPChannelPayload::Mode::DRIVING_MODE : SMPChannelPayload::Mode::TRAINING_MODE;
/* Send Mode selected to The Supervisor. */
if (&ReadyState::getInstance() == m_systemStateMachine.getState() && (false == m_modeSelectionSent))
{
uint8_t mode_options = ReadyState::getInstance().getSelectedMode();

isDataSent = m_smpServer.sendData(m_serialMuxProtChannelIdMode, &payload, sizeof(payload));
if (0U < mode_options)
{
SMPChannelPayload::Mode payload =
(1 == mode_options) ? SMPChannelPayload::Mode::DRIVING_MODE : SMPChannelPayload::Mode::TRAINING_MODE;

m_modeSelectionSent = true;
}
}
if (false == isDataSent)
if(false == m_smpServer.sendData(m_serialMuxProtChannelIdMode, &payload, sizeof(payload)))
{
/* Failed to send Mode data to the Supervisor. Go to error state. */
ErrorState::getInstance().setErrorMsg("MD_SF");
m_systemStateMachine.setState(&ErrorState::getInstance());
}
else
{
m_modeSelectionSent = true;
}
}
}

Expand Down

0 comments on commit 4ae6987

Please sign in to comment.