/src/connectedhomeip/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * |
3 | | * Copyright (c) 2023 Project CHIP Authors |
4 | | * All rights reserved. |
5 | | * |
6 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | | * you may not use this file except in compliance with the License. |
8 | | * You may obtain a copy of the License at |
9 | | * |
10 | | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | | * |
12 | | * Unless required by applicable law or agreed to in writing, software |
13 | | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | | * See the License for the specific language governing permissions and |
16 | | * limitations under the License. |
17 | | */ |
18 | | |
19 | | #pragma once |
20 | | |
21 | | #include <app-common/zap-generated/cluster-objects.h> |
22 | | #include <app/clusters/operational-state-server/operational-state-server.h> |
23 | | |
24 | | #include <protocols/interaction_model/StatusCode.h> |
25 | | |
26 | | namespace chip { |
27 | | namespace app { |
28 | | namespace Clusters { |
29 | | |
30 | | namespace OvenCavityOperationalState { |
31 | | |
32 | | // This is an application level delegate to handle operational state commands according to the specific business logic. |
33 | | class OvenCavityOperationalStateDelegate : public OperationalState::Delegate |
34 | | { |
35 | | private: |
36 | | inline static const Clusters::OperationalState::GenericOperationalState opStateList[] = { |
37 | | OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)), |
38 | | OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)), |
39 | | OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)), |
40 | | OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kError)) |
41 | | }; |
42 | | |
43 | | Span<const OperationalState::GenericOperationalState> mOperationalStateList = |
44 | | Span<const OperationalState::GenericOperationalState>(opStateList); |
45 | | Span<const CharSpan> mOperationalPhaseList; |
46 | | |
47 | | public: |
48 | | /** |
49 | | * Get the countdown time. This attribute is not supported in our example app. |
50 | | * @return Null. |
51 | | */ |
52 | 0 | DataModel::Nullable<uint32_t> GetCountdownTime() override { return DataModel::NullNullable; }; |
53 | | |
54 | | /** |
55 | | * Fills in the provided GenericOperationalState with the state at index `index` if there is one, |
56 | | * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of states. |
57 | | * Note: This is used by the SDK to populate the operational state list attribute. If the contents of this list changes, |
58 | | * the device SHALL call the Instance's ReportOperationalStateListChange method to report that this attribute has changed. |
59 | | * @param index The index of the state, with 0 representing the first state. |
60 | | * @param operationalState The GenericOperationalState is filled. |
61 | | */ |
62 | | CHIP_ERROR GetOperationalStateAtIndex(size_t index, |
63 | | Clusters::OperationalState::GenericOperationalState & operationalState) override; |
64 | | |
65 | | /** |
66 | | * Fills in the provided MutableCharSpan with the phase at index `index` if there is one, |
67 | | * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of phases. |
68 | | * Note: This is used by the SDK to populate the phase list attribute. If the contents of this list changes, the |
69 | | * device SHALL call the Instance's ReportPhaseListChange method to report that this attribute has changed. |
70 | | * @param index The index of the phase, with 0 representing the first phase. |
71 | | * @param operationalPhase The MutableCharSpan is filled. |
72 | | */ |
73 | | CHIP_ERROR GetOperationalPhaseAtIndex(size_t index, MutableCharSpan & operationalPhase) override; |
74 | | |
75 | | // command callback |
76 | | /** |
77 | | * Handle Command Callback in application: Pause |
78 | | * @param[out] get operational error after callback. |
79 | | */ |
80 | | void HandlePauseStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; |
81 | | |
82 | | /** |
83 | | * Handle Command Callback in application: Resume |
84 | | * @param[out] get operational error after callback. |
85 | | */ |
86 | | void HandleResumeStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; |
87 | | |
88 | | /** |
89 | | * Handle Command Callback in application: Start |
90 | | * @param[out] get operational error after callback. |
91 | | */ |
92 | | void HandleStartStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; |
93 | | |
94 | | /** |
95 | | * Handle Command Callback in application: Stop |
96 | | * @param[out] get operational error after callback. |
97 | | */ |
98 | | void HandleStopStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; |
99 | | }; |
100 | | |
101 | | Instance * GetOperationalStateInstance(); |
102 | | |
103 | | void Shutdown(); |
104 | | |
105 | | } // namespace OvenCavityOperationalState |
106 | | } // namespace Clusters |
107 | | } // namespace app |
108 | | } // namespace chip |