/src/connectedhomeip/examples/energy-management-app/energy-management-common/water-heater/include/WhmManufacturer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * |
3 | | * Copyright (c) 2024 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 <DEMManufacturerDelegate.h> |
22 | | #include <WhmDelegate.h> |
23 | | #include <WhmInstance.h> |
24 | | |
25 | | namespace chip { |
26 | | namespace app { |
27 | | namespace Clusters { |
28 | | namespace WaterHeaterManagement { |
29 | | |
30 | | /** |
31 | | * The WhmManufacturer example class |
32 | | * |
33 | | * Helps with handling the test triggers. |
34 | | */ |
35 | | |
36 | | class WhmManufacturer : public DeviceEnergyManagement::DEMManufacturerDelegate |
37 | | { |
38 | | public: |
39 | 1 | WhmManufacturer(WaterHeaterManagementInstance * whmInstance) { mWhmInstance = whmInstance; } |
40 | | |
41 | 0 | WaterHeaterManagementInstance * GetWhmInstance() { return mWhmInstance; } |
42 | | |
43 | | WaterHeaterManagementDelegate * GetWhmDelegate() |
44 | 1 | { |
45 | 1 | if (mWhmInstance) |
46 | 1 | { |
47 | 1 | return mWhmInstance->GetDelegate(); |
48 | 1 | } |
49 | | |
50 | 0 | return nullptr; |
51 | 1 | } |
52 | | |
53 | | /** |
54 | | * @brief Called at start up to apply hardware settings |
55 | | */ |
56 | | CHIP_ERROR Init(); |
57 | | |
58 | | /** |
59 | | * @brief Called at shutdown |
60 | | */ |
61 | | CHIP_ERROR Shutdown(); |
62 | | |
63 | | /** |
64 | | * @brief Called to determine which heating sources to use, |
65 | | */ |
66 | | BitMask<WaterHeaterHeatSourceBitmap> DetermineHeatingSources(); |
67 | | |
68 | | /** |
69 | | * @brief Turn the heating of the water tank on. |
70 | | * |
71 | | * @param emergencyBoost Indicates that the consumer wants the water to be heated as quickly as practicable. This MAY cause |
72 | | * multiple heat sources to be activated (e.g. a heat pump and direct electric heating element). |
73 | | * @return An error if a problem occurs turning the heating on |
74 | | */ |
75 | | Protocols::InteractionModel::Status TurnHeatingOn(bool emergencyBoost); |
76 | | |
77 | | /** |
78 | | * @brief Turn the heating of the water tank off. |
79 | | * |
80 | | * @return An error if a problem occurs turning the heating off |
81 | | */ |
82 | | Protocols::InteractionModel::Status TurnHeatingOff(); |
83 | | |
84 | | /** |
85 | | * @brief Called to handle a boost command. |
86 | | * |
87 | | * @param duration Indicates the time period in seconds for which |
88 | | * the BOOST state is activated before it |
89 | | * automatically reverts to the previous mode |
90 | | * (e.g. OFF, MANUAL or TIMED). |
91 | | * |
92 | | * @param oneShot Indicates whether the BOOST state should be |
93 | | * automatically canceled once the hot water has |
94 | | * first reached the set point temperature (or the |
95 | | * TemporarySetpoint temperature, if specified) |
96 | | * for the TargetPercentage (if specified). |
97 | | * |
98 | | * @param emergencyBoost Indicates that the consumer wants the water to |
99 | | * be heated as quickly as practicable. This MAY |
100 | | * cause multiple heat sources to be activated |
101 | | * (e.g. a heat pump and direct electric heating |
102 | | * element). |
103 | | * |
104 | | * @param temporarySetpoint Indicates the target temperature to which to |
105 | | * heat the hot water for this Boost command. It |
106 | | * SHALL be used instead of the normal set point |
107 | | * temperature whilst the BOOST state is active. |
108 | | * |
109 | | * @param targetPercentage If the tank supports the TankPercent feature, |
110 | | * this field indicates the amount of water that |
111 | | * SHALL be heated by this Boost command before |
112 | | * the heater is switched off. |
113 | | * |
114 | | * @param targetReheat If the tank supports the TankPercent feature, |
115 | | * and the heating by this Boost command has |
116 | | * ceased because the TargetPercentage of the |
117 | | * water in the tank has been heated to the set |
118 | | * point (or TemporarySetpoint if included), this |
119 | | * field indicates the percentage to which the hot |
120 | | * water in the tank SHALL be allowed to fall |
121 | | * before again beginning to reheat it. |
122 | | * |
123 | | * @return Success if the boost command is successful; otherwise return the |
124 | | * appropriate error. |
125 | | */ |
126 | | Protocols::InteractionModel::Status BoostCommandStarted(uint32_t duration, Optional<bool> oneShot, |
127 | | Optional<bool> emergencyBoost, Optional<int16_t> temporarySetpoint, |
128 | | Optional<chip::Percent> targetPercentage, |
129 | | Optional<chip::Percent> targetReheat); |
130 | | |
131 | | /** |
132 | | * @brief Called when the Boost command has been cancelled. |
133 | | * |
134 | | * @return It should report SUCCESS if successful and FAILURE otherwise. |
135 | | */ |
136 | | Protocols::InteractionModel::Status BoostCommandCancelled(); |
137 | | |
138 | | /** |
139 | | * @brief Called when a boost command has completed. |
140 | | */ |
141 | | void BoostCommandFinished(); |
142 | | |
143 | | /* Implement the DEMManufacturerDelegate interface */ |
144 | | |
145 | | /** |
146 | | * @brief The PowerAdjustEnd event needs to report the approximate energy used by the ESA during the session. |
147 | | */ |
148 | | int64_t GetApproxEnergyDuringSession() override; |
149 | | |
150 | | private: |
151 | | WaterHeaterManagementInstance * mWhmInstance; |
152 | | }; |
153 | | |
154 | | /** @brief Helper function to return the singleton WhmManufacturer instance |
155 | | * |
156 | | * This is needed by the WhmManufacturer class to support TestEventTriggers |
157 | | * which are called outside of any class context. This allows the WhmManufacturer |
158 | | * class to return the relevant Delegate instance in which to invoke the test |
159 | | * events on. |
160 | | * |
161 | | * This function is typically found in main.cpp or wherever the singleton is created. |
162 | | */ |
163 | | WhmManufacturer * GetWhmManufacturer(); |
164 | | |
165 | | } // namespace WaterHeaterManagement |
166 | | } // namespace Clusters |
167 | | } // namespace app |
168 | | } // namespace chip |