Skip to content

Commit

Permalink
🔀️ Merge branch 'yann/feature/sm/add-transition-deepsleeping-state-to…
Browse files Browse the repository at this point in the history
…-terminate-state/ble-events' into develop
  • Loading branch information
ladislas committed Jul 9, 2024
2 parents 9845606 + b086532 commit f8bd18c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/RobotKit/include/StateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ struct StateMachine {
, sm::state::deep_sleeping + event<sm::event::charge_did_start> = X
, sm::state::deep_sleeping + event<sm::event::charge_did_stop> = X

, sm::state::deep_sleeping + event<sm::event::ble_connection> = X
, sm::state::deep_sleeping + event<sm::event::ble_disconnection> = X

, sm::state::charging + boost::sml::on_entry<_> / (sm::action::start_deep_sleep_timeout {}, sm::action::start_charging_behavior {} )
, sm::state::charging + boost::sml::on_exit<_> / (sm::action::stop_deep_sleep_timeout {}, sm::action::stop_charging_behavior {} )

Expand Down
22 changes: 22 additions & 0 deletions libs/RobotKit/tests/StateMachine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,28 @@ TEST_F(StateMachineTest, stateDeepSleepingEventChargeDidStop)
EXPECT_TRUE(sm.is(X));
}

TEST_F(StateMachineTest, stateDeepSleepingEventBleConnection)
{
sm.set_current_states(lksm::state::deep_sleeping);

EXPECT_CALL(mock_rc, wakeUp);

sm.process_event(lksm::event::ble_connection {});

EXPECT_TRUE(sm.is(X));
}

TEST_F(StateMachineTest, stateDeepSleepingEventBleDisconnection)
{
sm.set_current_states(lksm::state::deep_sleeping);

EXPECT_CALL(mock_rc, wakeUp);

sm.process_event(lksm::event::ble_disconnection {});

EXPECT_TRUE(sm.is(X));
}

TEST_F(StateMachineTest, stateIdleEventChargeDidStart)
{
sm.set_current_states(lksm::state::idle);
Expand Down

0 comments on commit f8bd18c

Please sign in to comment.