Skip to content

Commit

Permalink
Update rvc example to handel new pause compatible states (project-chi…
Browse files Browse the repository at this point in the history
…p#30963)

* Updated the RVC example app to appropriatly handel the RvcOpState Pasue and Resume commands for the new pause and resume compatible states.

* Updated the RVC example app's state machine diagram.

* Restyled by clang-format

* Added some clarifying comments to the RvcDevice pause and resume commands handle methods. Renamed variable for clarity. Removed unnecessary temp hold of pause state.

* Restyled by clang-format

* Changed the naming to note the state that was paused rather than the state that we will resume to as we cannot know the state that the device will resume to when the pause command is handled.

* Clarified comments following reviews.

* Modified the resume callback logic to be more concise.

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: chrismapp <[email protected]>
  • Loading branch information
3 people authored and thivya-amazon committed Dec 18, 2023
1 parent 3dad619 commit dbdc264
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
Binary file modified examples/rvc-app/RVC_app_state_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/rvc-app/RVC_app_state_diagram_drawio.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="confluence.dyson.global.corp" modified="2023-09-06T08:28:06.131Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" etag="EQPGnPqeX5BjbhXApP4w" version="13.5.8" type="atlas"><mxAtlasLibraries/><diagram id="8Tl753pVDSM3c8Mwypsi" name="Page-1">7V3bd6K6Gv9rutbZD7qAcH1Uazud6W3ZzpnT87IXQlRaFAdotfPX7wQTrkFRA7qrMw+VJISQ7/b7vnwJF6A3XV775nxy59nQvZAEe3kBLi8kSdIEEf3BJZ+rEqCQgrHv2KuiVMGT8weSQoGUvjs2DDINQ89zQ2eeLbS82QxaYabM9H1vkW028tzsU+fmmDxRSAqeLNOFhWa/HDucrEp1SUvKv0FnPKFP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A=</diagram></mxfile>
<mxfile host="confluence.dyson.global.corp" modified="2023-12-12T16:52:23.893Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36" etag="cysFIm_igNHBgI2WXTH3" version="13.5.8" type="atlas"><mxAtlasLibraries/><diagram id="8Tl753pVDSM3c8Mwypsi" name="Page-1">7V1bd6I6G/41XevbF7og4XhZrc7uTNvpsjOzp9/NXgiodFAs0NrOr98JJAghKGpQpzpzUUkgHN7zkzdvLmB3+vYptOaT28Bx/QsgOW8X8OoCAGCaEP3BLe9pi6qAtGEcek7aJC8bHrzfLmmUSOuL57hR4cQ4CPzYmxcb7WA2c+240GaFYbAonjYK/OJd59aY3FFaNjzYlu+WTvvHc+JJ2moAfdn+t+uNJ/TOsmamPVOLnkwGjiaWEyxyTbB3AbthEMTpr+lb1/Xxx6PfJb2uX9GbPVjozuI6F7zri+7TpDv95b4p3c7g8ful9W+LPOyr5b+QFyYPG7/TLxAGLzPHxYNIF7CzmHix+zC3bNy7QDRHbZN46qMjGf0sPxR5zlc3jN23XBN5yE9uMHXj8B2dQns1hXwxwjJA0kjDYkkB1SBtk9zXB6baVgntCd3H2fjLT4N+kK/D/1Kdbh98XsSD585vGP/46bxPXuctyPlSmo9u3Inm1qzwybTnF0zUjh34QXgBL1FnOB7+Dz0wurVE//yVfC7EkbO4NbKmnv+enjpx/Vc39mwr1x8lcoF7ZWP+lu9Ib4p7ZkE4tfxc34J8GdypSFLa47tx7IYt9My2NxuXr0REiluW741naZ+NCOmGuT4PMcOMjCrRZ0l64tCaRSM0Fh115qa9iyB0infMLhxa9q9xwmEt5msBVU0/VP4H+WaOF819i3wvb+Z79E4jP7Bi5vaUGujXGP8dvNpf5w+xFbvorHvrJXIpIRFfpLRMTyxJgusg1UAOgzCeBONgZvm9ZWunKCvLc26CYE4k5AkR4J3oOeslDorygz5t+P4zf/CIB2sDlR5fvZHR06N3evTmxT+TU1Vy9EhHQb+XF+E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E/gb3ZAe3k7F2Qvxmxe0EjWPpGv+tIi2RmnLhuhq+H/NZxwLGNhLwzREJs43UezDUOlTOYxKy7bb7gmtiW1FY2WIt4Rn4KlwE9m9kkRhCWxN8LrcfPj1X+ymjPmxbcQMoG3inhHMYG3r6ojzJQMzx9ssjY3lw7VWWu7lebuDQZfByc372YsQeXlLC1vOWRDZbm5JG4qD563sKafRwM3L5370fBBmZ2F5fmKPPinMV+Req8HmgbLDgQuOOC+J6cAwU5OhPAqkKue+pxDnNoQ7NX2Xt1ZzHdtGT4+74q9C1hdBjFo+uVe9sT+x/jUuna7xtD5PH18/R2Obh++rcCqT1EcskU4x5dTv1FKvTtzUAgSLJZeHGrpe5g1kv4IKe2YnmH7VhR5Nm0mp9UOHFdWOxW+MhJvD6ztMYXfAG1NA8sMzGLkp0rLlTGbZkyYBrM6QKtZ8mmL+LDTH/Zc+2Y0uI+f7LvbSFrEz4edptoakuE8lRDR//oSt4JRa2jhyRVp6kYRMikRXxGc2CxrGZCFnIirsUzHTrcPPi/iwXPnN4x//HTeJ6/zbZJiy1vZStlutlK2oW19o7Xc5HYrg7UGA0662e1v/wyAeM2GuFJuT1wpty3uVvgyd+KbX/+msCvN9N56iVyHnpkwilSuqr5mk5pDI7s5/0DfqKDiNkXutvcG5LreAN1aYBPAWTW2cgc2hYmBwq7mM4gfss+6LlxdKN6Qn3zNtfIucAavnvB+a66BaqO3c5L3UmkmirEu2Y95XfGybAfI1+2Qm1JyUk0lJ2++bFmW9GLkIaaOFuSNuYdtqxpbprKL8aebbR/7vnS7mvzcEuf1ZWz2YPM3rypXkobWjoBAtkKANfE6u2d87eUQDcgS1/Y3VavmXNKNwjTsUgNNA/ViXxF+AJfm1Zln59j3HPvmc71zdWFXl4Ldvx2rFM1NauRppphkI1mmWUtsmU/hK9dKd6L6ZOswcoN7rLNj660SOgwDzHXL05FSn+AMVHzGfw==</diagram></mxfile>
2 changes: 2 additions & 0 deletions examples/rvc-app/rvc-common/include/rvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class RvcDevice
bool mDocked = false;
bool mCharging = false;

uint8_t mStateBeforePause = 0;

public:
/**
* This class is responsible for initialising all the RVC clusters and manging the interactions between them as required by
Expand Down
47 changes: 33 additions & 14 deletions examples/rvc-app/rvc-common/src/rvc-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,47 @@ void RvcDevice::HandleRvcCleanChangeToMode(uint8_t newMode, ModeBase::Commands::

void RvcDevice::HandleOpStatePauseCallback(Clusters::OperationalState::GenericOperationalError & err)
{
// This method is only called if the device is in a Pause-compatible state, i.e. `Running` or `SeekingCharger`.
mStateBeforePause = mOperationalStateInstance.GetCurrentOperationalState();
auto error = mOperationalStateInstance.SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused));
if (error == CHIP_NO_ERROR)
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kNoError));
}
else
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation));
}
err.Set((error == CHIP_NO_ERROR) ? to_underlying(OperationalState::ErrorStateEnum::kNoError)
: to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation));
}

void RvcDevice::HandleOpStateResumeCallback(Clusters::OperationalState::GenericOperationalError & err)
{
auto error = mOperationalStateInstance.SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning));
if (error == CHIP_NO_ERROR)
uint8_t targetState = to_underlying(OperationalState::OperationalStateEnum::kRunning);

switch (mOperationalStateInstance.GetCurrentOperationalState())
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kNoError));
case to_underlying(RvcOperationalState::OperationalStateEnum::kCharging):
case to_underlying(RvcOperationalState::OperationalStateEnum::kDocked): {
if (mRunModeInstance.GetCurrentMode() != RvcRunMode::ModeCleaning &&
mRunModeInstance.GetCurrentMode() != RvcRunMode::ModeMapping)
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState));
return;
}
}
else
{
err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation));
break;
case to_underlying(OperationalState::OperationalStateEnum::kPaused): {
if (mStateBeforePause == to_underlying(RvcOperationalState::OperationalStateEnum::kSeekingCharger))
{
targetState = to_underlying(RvcOperationalState::OperationalStateEnum::kSeekingCharger);
}
}
break;
default:
// This method is only called if the device is in a resume-compatible state, i.e. `Charging`, `Docked` or
// `Paused`. Therefor, we do not expect to ever enter this branch.
err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState));
return;
}

auto error = mOperationalStateInstance.SetOperationalState(targetState);

err.Set((error == CHIP_NO_ERROR) ? to_underlying(OperationalState::ErrorStateEnum::kNoError)
: to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation));
}

void RvcDevice::HandleChargedMessage()
Expand Down

0 comments on commit dbdc264

Please sign in to comment.