From 9a4dd79389a48a6e848cfe61c1c64020ed62b9e1 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Mon, 5 Feb 2024 16:41:12 +0100 Subject: [PATCH] :sparkles: (StateMachine): Revert cancelled transition to DeepSleeping state Revert partially commit b9b43ac98e128663e7b849beaf15a2261a03e694 in PR #1323 --- libs/RobotKit/include/StateMachine.h | 4 +-- libs/RobotKit/tests/StateMachine_test.cpp | 36 +++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libs/RobotKit/include/StateMachine.h b/libs/RobotKit/include/StateMachine.h index b6eda9921f..10c03c75bc 100644 --- a/libs/RobotKit/include/StateMachine.h +++ b/libs/RobotKit/include/StateMachine.h @@ -232,7 +232,7 @@ struct StateMachine { , sm::state::sleeping + event [sm::guard::is_charging {}] = sm::state::charging , sm::state::sleeping + event = sm::state::emergency_stopped , sm::state::sleeping + event = sm::state::autonomous_activities - //, sm::state::sleeping + event = sm::state::deep_sleeping + , sm::state::sleeping + event = sm::state::deep_sleeping , sm::state::deep_sleeping + boost::sml::on_entry<_> / sm::action::suspend_hardware_for_deep_sleep {} @@ -248,7 +248,7 @@ struct StateMachine { , sm::state::charging + event = sm::state::charging , sm::state::charging + event = sm::state::emergency_stopped , sm::state::charging + event = sm::state::charging - //, sm::state::charging + event = sm::state::deep_sleeping + , sm::state::charging + event = 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 {} diff --git a/libs/RobotKit/tests/StateMachine_test.cpp b/libs/RobotKit/tests/StateMachine_test.cpp index c0f483df27..b682d67334 100644 --- a/libs/RobotKit/tests/StateMachine_test.cpp +++ b/libs/RobotKit/tests/StateMachine_test.cpp @@ -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) { @@ -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) {