Skip to content

Commit

Permalink
✨ (StateMachine): Revert cancelled transition to DeepSleeping state
Browse files Browse the repository at this point in the history
Revert partially commit b9b43ac in PR #1323
  • Loading branch information
YannLocatelli committed Jul 9, 2024
1 parent a22fae5 commit 9a4dd79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions libs/RobotKit/include/StateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ struct StateMachine {
, sm::state::sleeping + event<sm::event::charge_did_start> [sm::guard::is_charging {}] = sm::state::charging
, sm::state::sleeping + event<sm::event::emergency_stop> = sm::state::emergency_stopped
, sm::state::sleeping + event<sm::event::autonomous_activities_mode_requested> = sm::state::autonomous_activities
//, sm::state::sleeping + event<sm::event::deep_sleep_timeout_did_end> = sm::state::deep_sleeping
, sm::state::sleeping + event<sm::event::deep_sleep_timeout_did_end> = sm::state::deep_sleeping

, sm::state::deep_sleeping + boost::sml::on_entry<_> / sm::action::suspend_hardware_for_deep_sleep {}

Expand All @@ -248,7 +248,7 @@ struct StateMachine {
, sm::state::charging + event<sm::event::command_received> = sm::state::charging
, sm::state::charging + event<sm::event::emergency_stop> = sm::state::emergency_stopped
, sm::state::charging + event<sm::event::autonomous_activities_mode_requested> = sm::state::charging
//, sm::state::charging + event<sm::event::deep_sleep_timeout_did_end> = sm::state::deep_sleeping
, sm::state::charging + event<sm::event::deep_sleep_timeout_did_end> = sm::state::deep_sleeping

, sm::state::file_exchange + boost::sml::on_entry<_> / sm::action::start_file_exchange {}
, sm::state::file_exchange + boost::sml::on_exit<_> / sm::action::stop_file_exchange {}
Expand Down
36 changes: 18 additions & 18 deletions libs/RobotKit/tests/StateMachine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,18 @@ TEST_F(StateMachineTest, stateSleepEventAutonomousActivityRequested)
EXPECT_TRUE(sm.is(lksm::state::autonomous_activities));
}

// TEST_F(StateMachineTest, stateSleepEventTimeout)
// {
// sm.set_current_states(lksm::state::sleeping);
TEST_F(StateMachineTest, stateSleepEventTimeout)
{
sm.set_current_states(lksm::state::sleeping);

// EXPECT_CALL(mock_rc, stopSleepingBehavior).Times(1);
// EXPECT_CALL(mock_rc, stopDeepSleepTimeout).Times(1);
// EXPECT_CALL(mock_rc, suspendHardwareForDeepSleep).Times(1);
EXPECT_CALL(mock_rc, stopSleepingBehavior).Times(1);
EXPECT_CALL(mock_rc, stopDeepSleepTimeout).Times(1);
EXPECT_CALL(mock_rc, suspendHardwareForDeepSleep).Times(1);

// sm.process_event(lksm::event::deep_sleep_timeout_did_end {});
sm.process_event(lksm::event::deep_sleep_timeout_did_end {});

// EXPECT_TRUE(sm.is(lksm::state::deep_sleeping));
// }
EXPECT_TRUE(sm.is(lksm::state::deep_sleeping));
}

TEST_F(StateMachineTest, stateIdleEventChargeDidStart)
{
Expand Down Expand Up @@ -359,18 +359,18 @@ TEST_F(StateMachineTest, stateChargingEventAutonomousActivityRequested)
EXPECT_TRUE(sm.is(lksm::state::charging));
}

// TEST_F(StateMachineTest, stateChargingEventTimeout)
// {
// sm.set_current_states(lksm::state::charging);
TEST_F(StateMachineTest, stateChargingEventTimeout)
{
sm.set_current_states(lksm::state::charging);

// EXPECT_CALL(mock_rc, stopChargingBehavior).Times(1);
// EXPECT_CALL(mock_rc, stopDeepSleepTimeout).Times(1);
// EXPECT_CALL(mock_rc, suspendHardwareForDeepSleep).Times(1);
EXPECT_CALL(mock_rc, stopChargingBehavior).Times(1);
EXPECT_CALL(mock_rc, stopDeepSleepTimeout).Times(1);
EXPECT_CALL(mock_rc, suspendHardwareForDeepSleep).Times(1);

// sm.process_event(lksm::event::deep_sleep_timeout_did_end {});
sm.process_event(lksm::event::deep_sleep_timeout_did_end {});

// EXPECT_TRUE(sm.is(lksm::state::deep_sleeping));
// }
EXPECT_TRUE(sm.is(lksm::state::deep_sleeping));
}

TEST_F(StateMachineTest, stateSleepingEventBleConnection)
{
Expand Down

0 comments on commit 9a4dd79

Please sign in to comment.