Skip to content

Commit 0bd5786

Browse files
Update rvc op state in all clusters (#31763)
* Updated the all-clusters-app to change the operataional state from the rvc run mode change-to-mode command. Updated the CI pics file to match the capabilities of the all-clutsers-app. * Updated TC_RVCOPSTATE_2_1 to take the --endpoind flag and fix an execution issue. * Updated TC_RVCOPSTATE_2_3 to error if the --endpoind flag is not defined and fix an execution issue. * Updated TC_RVCOPSTATE_2_4 to error if the --endpoind flag is not defined and fixed some execution issues. * Restyled by whitespace * Restyled by clang-format * Restyled by autopep8 * Added the GoHome command PICS, RVCOPSTATE.S.C128.Rsp, to the PICS.yaml. * fixed typo. --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent c4b5df9 commit 0bd5786

File tree

6 files changed

+66
-70
lines changed

6 files changed

+66
-70
lines changed

examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
#include <app-common/zap-generated/attributes/Accessors.h>
1919
#include <rvc-modes.h>
20+
#include <rvc-operational-state-delegate-impl.h>
2021

2122
using namespace chip::app::Clusters;
2223
using namespace chip::app::Clusters::RvcRunMode;
@@ -40,14 +41,24 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
4041
{
4142
uint8_t currentMode = mInstance->GetCurrentMode();
4243

43-
// Our business logic states that we can only switch into the mapping state from the idle state.
44-
if (NewMode == RvcRunMode::ModeMapping && currentMode != RvcRunMode::ModeIdle)
44+
// Our business logic states that we can only switch into a running mode from the idle state.
45+
if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
4546
{
4647
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
47-
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to the mapping mode is only allowed from idle"));
48+
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to a running mode is only allowed from idle"));
4849
return;
4950
}
5051

52+
auto rvcOpStateInstance = RvcOperationalState::GetRvcOperationalStateInstance();
53+
if (NewMode == RvcRunMode::ModeIdle)
54+
{
55+
rvcOpStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped));
56+
}
57+
else
58+
{
59+
rvcOpStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning));
60+
}
61+
5162
response.status = to_underlying(ModeBase::StatusCode::kSuccess);
5263
}
5364

src/app/tests/suites/certification/PICS.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -9497,6 +9497,9 @@ PICS:
94979497
- label: "Does the device implement receiving the Resume command?"
94989498
id: RVCOPSTATE.S.C03.Rsp
94999499

9500+
- label: "Does the device implement receiving the GoHome command?"
9501+
id: RVCOPSTATE.S.C128.Rsp
9502+
95009503
#Commands generated
95019504
- label:
95029505
"Does the device implement generating the OperationalCommandResponse

src/app/tests/suites/certification/ci-pics-values

+17-15
Original file line numberDiff line numberDiff line change
@@ -2457,26 +2457,27 @@ RVCOPSTATE.S=1
24572457
RVCOPSTATE.C=1
24582458

24592459
#ManuallyControlled
2460+
# These are the PICS supported by the all-clusters-app
24602461

24612462
RVCOPSTATE.S.M.ST_STOPPED=1
24622463
RVCOPSTATE.S.M.ST_RUNNING=1
24632464
RVCOPSTATE.S.M.ST_PAUSED=1
2464-
RVCOPSTATE.S.M.ST_ERROR=1
2465-
RVCOPSTATE.S.M.ST_SEEKING_CHARGER=1
2466-
RVCOPSTATE.S.M.ST_CHARGING=1
2467-
RVCOPSTATE.S.M.ST_DOCKED=1
2465+
RVCOPSTATE.S.M.ST_ERROR=0
2466+
RVCOPSTATE.S.M.ST_SEEKING_CHARGER=0
2467+
RVCOPSTATE.S.M.ST_CHARGING=0
2468+
RVCOPSTATE.S.M.ST_DOCKED=0
24682469
RVCOPSTATE.S.M.ERR_NO_ERROR=1
2469-
RVCOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=1
2470-
RVCOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=1
2471-
RVCOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=1
2472-
RVCOPSTATE.S.M.ERR_FAILED_TO_FIND_CHARGING_DOCK=1
2473-
RVCOPSTATE.S.M.ERR_STUCK=1
2474-
RVCOPSTATE.S.M.ERR_DUST_BIN_MISSING=1
2475-
RVCOPSTATE.S.M.ERR_DUST_BIN_FULL=1
2476-
RVCOPSTATE.S.M.ERR_WATER_TANK_EMPTY=1
2477-
RVCOPSTATE.S.M.ERR_WATER_TANK_MISSING=1
2478-
RVCOPSTATE.S.M.ERR_WATER_TANK_LID_OPEN=1
2479-
RVCOPSTATE.S.M.ERR_MOP_CLEANING_PAD_MISSING=1
2470+
RVCOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=0
2471+
RVCOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=0
2472+
RVCOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=0
2473+
RVCOPSTATE.S.M.ERR_FAILED_TO_FIND_CHARGING_DOCK=0
2474+
RVCOPSTATE.S.M.ERR_STUCK=0
2475+
RVCOPSTATE.S.M.ERR_DUST_BIN_MISSING=0
2476+
RVCOPSTATE.S.M.ERR_DUST_BIN_FULL=0
2477+
RVCOPSTATE.S.M.ERR_WATER_TANK_EMPTY=0
2478+
RVCOPSTATE.S.M.ERR_WATER_TANK_MISSING=0
2479+
RVCOPSTATE.S.M.ERR_WATER_TANK_LID_OPEN=0
2480+
RVCOPSTATE.S.M.ERR_MOP_CLEANING_PAD_MISSING=0
24802481

24812482
#Events
24822483
RVCOPSTATE.S.E00=1
@@ -2496,6 +2497,7 @@ RVCOPSTATE.S.C01.Rsp=0
24962497
RVCOPSTATE.S.C02.Rsp=0
24972498
RVCOPSTATE.S.C03.Rsp=1
24982499
RVCOPSTATE.S.C04.Tx=1
2500+
RVCOPSTATE.S.C128.Rsp=1
24992501
RVCOPSTATE.C.C00.Tx=1
25002502
RVCOPSTATE.C.C01.Tx=1
25012503
RVCOPSTATE.C.C02.Tx=1

src/python_testing/TC_RVCOPSTATE_2_1.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
2323
from mobly import asserts
2424

25-
# This test requires several additional command line arguments
26-
# run with
27-
# --int-arg PIXIT_ENDPOINT:<endpoint>
28-
2925

3026
class TC_RVCOPSTATE_2_1(MatterBaseTest):
27+
def __init__(self, *args):
28+
super().__init__(*args)
29+
self.endpoint = None
3130

3231
async def read_mod_attribute_expect_success(self, endpoint, attribute):
3332
cluster = Clusters.Objects.RvcOperationalState
@@ -54,12 +53,8 @@ def TC_RVCOPSTATE_2_1(self) -> list[str]:
5453

5554
@async_test_body
5655
async def test_TC_RVCOPSTATE_2_1(self):
57-
58-
asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params,
59-
"PIXIT_ENDPOINT must be included on the command line in "
60-
"the --int-arg flag as PIXIT_ENDPOINT:<endpoint>")
61-
62-
self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT']
56+
self.endpoint = self.matter_test_config.endpoint
57+
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
6358

6459
attributes = Clusters.RvcOperationalState.Attributes
6560

@@ -108,8 +103,7 @@ async def test_TC_RVCOPSTATE_2_1(self):
108103

109104
defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum
110105
if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue]
111-
defined_states.extend(state.value for state in Clusters.RvcOperationalState.Enums.OperationalStateEnum
112-
if state is not Clusters.RvcOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue)
106+
defined_states.extend(state.value for state in Clusters.RvcOperationalState.Enums.OperationalStateEnum)
113107

114108
for state in operational_state_list:
115109
in_range = (0x80 <= state.operationalStateID <= 0xBF)
@@ -172,8 +166,7 @@ async def test_TC_RVCOPSTATE_2_1(self):
172166
# Defined Errors
173167
defined_errors = [error.value for error in Clusters.OperationalState.Enums.ErrorStateEnum
174168
if error is not Clusters.OperationalState.Enums.ErrorStateEnum.kUnknownEnumValue]
175-
defined_errors.extend(error.value for error in Clusters.RvcOperationalState.Enums.ErrorStateEnum
176-
if error is not Clusters.RvcOperationalState.Enums.ErrorStateEnum.kUnknownEnumValue)
169+
defined_errors.extend(error.value for error in Clusters.RvcOperationalState.Enums.ErrorStateEnum)
177170

178171
in_range = (0x80 <= operational_error.errorStateID <= 0xBF)
179172
asserts.assert_true(operational_error.errorStateID in defined_errors

src/python_testing/TC_RVCOPSTATE_2_3.py

+15-22
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches
2424
from mobly import asserts
2525

26-
# This test requires several additional command line arguments
27-
# run with
28-
# --int-arg PIXIT_ENDPOINT:<endpoint>
29-
3026

3127
# Takes an OpState or RvcOpState state enum and returns a string representation
3228
def state_enum_to_text(state_enum):
@@ -82,20 +78,20 @@ def pics_TC_RVCOPSTATE_2_3(self) -> list[str]:
8278
class TC_RVCOPSTATE_2_3(MatterBaseTest):
8379

8480
def __init__(self, *args):
85-
super().__init__(args)
86-
self.endpoint = 0
81+
super().__init__(*args)
82+
self.endpoint = None
8783

8884
async def read_mod_attribute_expect_success(self, endpoint, attribute):
8985
cluster = Clusters.Objects.RvcOperationalState
9086
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
9187

92-
async def send_pause_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.Pause:
88+
async def send_pause_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse:
9389
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcOperationalState.Commands.Pause(), endpoint=self.endpoint)
9490
asserts.assert_true(type_matches(ret, Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse),
9591
"Unexpected return type for Pause")
9692
return ret
9793

98-
async def send_resume_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.Resume:
94+
async def send_resume_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse:
9995
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcOperationalState.Commands.Resume(), endpoint=self.endpoint)
10096
asserts.assert_true(type_matches(ret, Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse),
10197
"Unexpected return type for Resume")
@@ -108,23 +104,23 @@ async def read_operational_state_with_check(self, step_number, expected_state):
108104
endpoint=self.endpoint, attribute=Clusters.RvcOperationalState.Attributes.OperationalState)
109105
logging.info("OperationalState: %s" % operational_state)
110106
asserts.assert_equal(operational_state, expected_state,
111-
"OperationalState(%s) should be %s" % operational_state, state_enum_to_text(expected_state))
107+
"OperationalState(%s) should be %s" % (operational_state, state_enum_to_text(expected_state)))
112108

113109
# Sends the Pause command and checks that the returned error matches the expected_error
114110
async def send_pause_cmd_with_check(self, step_number, expected_error):
115111
self.print_step(step_number, "Send Pause command")
116-
ret = self.send_pause_cmd()
112+
ret = await self.send_pause_cmd()
117113
asserts.assert_equal(ret.commandResponseState.errorStateID, expected_error,
118-
"errorStateID(%s) should be %s" % ret.commandResponseState.errorStateID,
119-
error_enum_to_text(expected_error))
114+
"errorStateID(%s) should be %s" % (ret.commandResponseState.errorStateID,
115+
error_enum_to_text(expected_error)))
120116

121117
# Sends the Resume command and checks that the returned error matches the expected_error
122118
async def send_resume_cmd_with_check(self, step_number, expected_error):
123119
self.print_step(step_number, "Send Pause command")
124-
ret = self.send_resume_cmd()
120+
ret = await self.send_resume_cmd()
125121
asserts.assert_equal(ret.commandResponseState.errorStateID, expected_error,
126-
"errorStateID(%s) should be %s" % ret.commandResponseState.errorStateID,
127-
error_enum_to_text(expected_error))
122+
"errorStateID(%s) should be %s" % (ret.commandResponseState.errorStateID,
123+
error_enum_to_text(expected_error)))
128124

129125
# Prints the instruction and waits for a user input to continue
130126
def print_instruction(self, step_number, instruction):
@@ -134,18 +130,15 @@ def print_instruction(self, step_number, instruction):
134130
@async_test_body
135131
async def test_TC_RVCOPSTATE_2_3(self):
136132

137-
asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params,
138-
"PIXIT_ENDPOINT must be included on the command line in "
139-
"the --int-arg flag as PIXIT_ENDPOINT:<endpoint>")
140-
141-
self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT']
133+
self.endpoint = self.matter_test_config.endpoint
134+
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
142135

143136
asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0003"), "RVCOPSTATE.S.A0003 must be supported")
144137
asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0004"), "RVCOPSTATE.S.A0004 must be supported")
145138
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C00.Rsp"), "RVCOPSTATE.S.C00.Rsp must be supported")
146139
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C03.Rsp"), "RVCOPSTATE.S.C03.Rsp must be supported")
147140
# This command SHALL be supported by an implementation if any of the other commands are supported (6.5)
148-
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Rsp"), "RVCOPSTATE.S.C04.Rsp must be supported")
141+
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Tx"), "RVCOPSTATE.S.C04.Tx must be supported")
149142

150143
attributes = Clusters.RvcOperationalState.Attributes
151144
op_states = Clusters.OperationalState.Enums.OperationalStateEnum
@@ -208,7 +201,7 @@ async def test_TC_RVCOPSTATE_2_3(self):
208201
attribute=attributes.OperationalState)
209202
logging.info("OperationalState: %s" % operational_state)
210203
asserts.assert_equal(operational_state, old_opstate_dut,
211-
"OperationalState(%s) should be the state before pause (%s)" % operational_state, old_opstate_dut)
204+
"OperationalState(%s) should be the state before pause (%s)" % (operational_state, old_opstate_dut))
212205

213206
await self.send_resume_cmd_with_check(13, op_errors.kNoError)
214207

src/python_testing/TC_RVCOPSTATE_2_4.py

+10-16
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches
2222
from mobly import asserts
2323

24-
# This test requires several additional command line arguments
25-
# run with
26-
# --int-arg PIXIT_ENDPOINT:<endpoint>
27-
2824

2925
# Takes an OpState or RvcOpState state enum and returns a string representation
3026
def state_enum_to_text(state_enum):
@@ -79,14 +75,14 @@ def pics_TC_RVCOPSTATE_2_4(self) -> list[str]:
7975

8076
class TC_RVCOPSTATE_2_4(MatterBaseTest):
8177
def __init__(self, *args):
82-
super().__init__(args)
83-
self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT']
78+
super().__init__(*args)
79+
self.endpoint = None
8480

8581
async def read_mod_attribute_expect_success(self, endpoint, attribute):
8682
cluster = Clusters.Objects.RvcOperationalState
8783
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
8884

89-
async def send_go_home_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.GoHome:
85+
async def send_go_home_cmd(self) -> Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse:
9086
ret = await self.send_single_cmd(cmd=Clusters.Objects.RvcOperationalState.Commands.GoHome(), endpoint=self.endpoint)
9187
asserts.assert_true(type_matches(ret, Clusters.Objects.RvcOperationalState.Commands.OperationalCommandResponse),
9288
"Unexpected return type for GoHome")
@@ -95,10 +91,10 @@ async def send_go_home_cmd(self) -> Clusters.Objects.RvcOperationalState.Command
9591
# Sends the GoHome command and checks that the returned error matches the expected_error
9692
async def send_go_home_cmd_with_check(self, step_number, expected_error):
9793
self.print_step(step_number, "Send GoHome command")
98-
ret = self.send_go_home_cmd()
94+
ret = await self.send_go_home_cmd()
9995
asserts.assert_equal(ret.commandResponseState.errorStateID, expected_error,
100-
"errorStateID(%s) should be %s" % ret.commandResponseState.errorStateID,
101-
error_enum_to_text(expected_error))
96+
"errorStateID(%s) should be %s" % (ret.commandResponseState.errorStateID,
97+
error_enum_to_text(expected_error)))
10298

10399
# Prints the step number, reads the operational state attribute and checks if it matches with expected_state
104100
async def read_operational_state_with_check(self, step_number, expected_state):
@@ -107,7 +103,7 @@ async def read_operational_state_with_check(self, step_number, expected_state):
107103
endpoint=self.endpoint, attribute=Clusters.RvcOperationalState.Attributes.OperationalState)
108104
logging.info("OperationalState: %s" % operational_state)
109105
asserts.assert_equal(operational_state, expected_state,
110-
"OperationalState(%s) should be %s" % operational_state, state_enum_to_text(expected_state))
106+
"OperationalState(%s) should be %s" % (operational_state, state_enum_to_text(expected_state)))
111107

112108
# Prints the instruction and waits for a user input to continue
113109
def print_instruction(self, step_number, instruction):
@@ -116,13 +112,11 @@ def print_instruction(self, step_number, instruction):
116112

117113
@async_test_body
118114
async def test_TC_RVCOPSTATE_2_4(self):
119-
120-
asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params,
121-
"PIXIT_ENDPOINT must be included on the command line in "
122-
"the --int-arg flag as PIXIT_ENDPOINT:<endpoint>")
115+
self.endpoint = self.matter_test_config.endpoint
116+
asserts.assert_false(self.endpoint is None, "--endpoint <endpoint> must be included on the command line in.")
123117

124118
asserts.assert_true(self.check_pics("RVCOPSTATE.S.A0004"), "RVCOPSTATE.S.A0004 must be supported")
125-
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Rsp"), "RVCOPSTATE.S.C04.Rsp must be supported")
119+
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C04.Tx"), "RVCOPSTATE.S.C04.Tx must be supported")
126120
asserts.assert_true(self.check_pics("RVCOPSTATE.S.C128.Rsp"), "RVCOPSTATE.S.C128.Rsp must be supported")
127121

128122
op_states = Clusters.OperationalState.Enums.OperationalStateEnum

0 commit comments

Comments
 (0)