/* * * Copyright (c) 2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include namespace chip { namespace app { namespace Clusters { namespace OperationalState { // This is an application level delegate to handle operational state commands according to the specific business logic. class OperationalStateDelegate : public Delegate { public: /** * Get the countdown time. This attribute is not used in this application. * @return The current countdown time. */ app::DataModel::Nullable GetCountdownTime() override { return {}; }; /** * Get the list of supported operational states. * Fills in the provided GenericOperationalState with the state at index `index` if there is one, * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of states. * @param index The index of the state, with 0 representing the first state. * @param operationalState The GenericOperationalState is filled. */ CHIP_ERROR GetOperationalStateAtIndex(size_t index, GenericOperationalState & operationalState) override; /** * Get the list of supported operational phases. * Fills in the provided MutableCharSpan with the phase at index `index` if there is one, * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of phases. * * If CHIP_ERROR_NOT_FOUND is returned for index 0, that indicates that the PhaseList attribute is null * (there are no phases defined at all). * * @param index The index of the phase, with 0 representing the first phase. * @param operationalPhase The MutableCharSpan is filled. */ CHIP_ERROR GetOperationalPhaseAtIndex(size_t index, MutableCharSpan & operationalPhase) override; // command callback /** * Handle Command Callback in application: Pause * @param[out] get operational error after callback. */ void HandlePauseStateCallback(GenericOperationalError & err) override; /** * Handle Command Callback in application: Resume * @param[out] get operational error after callback. */ void HandleResumeStateCallback(GenericOperationalError & err) override; /** * Handle Command Callback in application: Start * @param[out] get operational error after callback. */ void HandleStartStateCallback(GenericOperationalError & err) override; /** * Handle Command Callback in application: Stop * @param[out] get operational error after callback. */ void HandleStopStateCallback(GenericOperationalError & err) override; private: const GenericOperationalState rvcOpStateList[4] = { GenericOperationalState(to_underlying(OperationalStateEnum::kStopped)), GenericOperationalState(to_underlying(OperationalStateEnum::kRunning)), GenericOperationalState(to_underlying(OperationalStateEnum::kPaused)), GenericOperationalState(to_underlying(OperationalStateEnum::kError)), }; app::DataModel::List mOperationalStateList = Span(rvcOpStateList); const Span mOperationalPhaseList; }; void Shutdown(); } // namespace OperationalState } // namespace Clusters } // namespace app } // namespace chip