Skip to content

Commit

Permalink
update the status field of progress elements at the end of a clean. (p…
Browse files Browse the repository at this point in the history
…roject-chip#34919)

* update the status field of progress elements at the end of a clean.

* Added some style suggestions from the review of PR 34887.

* update the readme.

* Restyled by prettier-markdown

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and austina-csa committed Aug 12, 2024
1 parent 9b138a8 commit 5488f5e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
10 changes: 10 additions & 0 deletions examples/rvc-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,13 @@ PICS`SEAR.S.M.VALID_STATE_FOR_SELECT_AREAS=1`. PIXIT: `` Example command:

Example command:
`./scripts/tests/run_python_test.py --script src/python_testing/TC_SEAR_1_4.py --script-args "--storage-path admin_storage.json --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1`

#### TC 1.5

Example command:
`./scripts/tests/run_python_test.py --script src/python_testing/TC_SEAR_1_5.py --script-args "--storage-path admin_storage.json --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1"`

#### TC 1.6

Example command:
`./scripts/tests/run_python_test.py --script src/python_testing/TC_SEAR_1_6.py --script-args "--storage-path admin_storage.json --PICS examples/rvc-app/rvc-common/pics/rvc-app-pics-values --endpoint 1`
6 changes: 6 additions & 0 deletions examples/rvc-app/rvc-common/include/rvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ class RvcDevice
void HandleClearErrorMessage();

void HandleResetMessage();

/**
* Updates the Service area progress elements when an activity has ended.
* Sets any remaining Operating or Pending states to Skipped.
*/
void UpdateServiceAreaProgressOnExit();
};

} // namespace Clusters
Expand Down
23 changes: 23 additions & 0 deletions examples/rvc-app/rvc-common/src/rvc-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ void RvcDevice::HandleRvcRunChangeToMode(uint8_t newMode, ModeBase::Commands::Ch
mRunModeInstance.UpdateCurrentMode(newMode);
mOperationalStateInstance.SetOperationalState(to_underlying(RvcOperationalState::OperationalStateEnum::kSeekingCharger));
response.status = to_underlying(ModeBase::StatusCode::kSuccess);

UpdateServiceAreaProgressOnExit();
return;
}
break;
Expand Down Expand Up @@ -311,6 +313,7 @@ void RvcDevice::HandleActivityCompleteEvent()

mServiceAreaInstance.SetCurrentArea(DataModel::NullNullable);
mServiceAreaInstance.SetEstimatedEndTime(DataModel::NullNullable);
UpdateServiceAreaProgressOnExit();
}

void RvcDevice::HandleAreaCompletedEvent()
Expand Down Expand Up @@ -404,3 +407,23 @@ void RvcDevice::HandleResetMessage()
mServiceAreaInstance.SetCurrentArea(DataModel::NullNullable);
mServiceAreaInstance.SetEstimatedEndTime(DataModel::NullNullable);
}

void RvcDevice::UpdateServiceAreaProgressOnExit()
{
if (!mServiceAreaInstance.HasFeature(ServiceArea::Feature::kProgressReporting))
{
return;
}

uint32_t i = 0;
ServiceArea::Structs::ProgressStruct::Type progressElement;
while (mServiceAreaDelegate.GetProgressElementByIndex(i, progressElement))
{
if (progressElement.status == ServiceArea::OperationalStatusEnum::kOperating ||
progressElement.status == ServiceArea::OperationalStatusEnum::kPending)
{
mServiceAreaInstance.SetProgressStatus(progressElement.areaID, ServiceArea::OperationalStatusEnum::kSkipped);
}
i++;
}
}
4 changes: 2 additions & 2 deletions examples/rvc-app/rvc-common/src/rvc-service-area-delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ bool RvcServiceAreaDelegate::IsValidSelectAreasSet(const Commands::SelectAreas::
}
}

// If there are less than 2 supported maps, any combination of areas is valid.
// If there is 1 or 0 supported maps, any combination of areas is valid.
if (!GetInstance()->HasFeature(Feature::kMaps) || GetNumberOfSupportedMaps() <= 1)
{
return true;
}

// Check that all the areas are in the same map.
// Check that all the requested areas are in the same map.
auto newAreasIter = req.newAreas.begin();
newAreasIter.Next();

Expand Down

0 comments on commit 5488f5e

Please sign in to comment.