1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PROTECTOR_THERMAL_ZONE_INFO_H
17 #define PROTECTOR_THERMAL_ZONE_INFO_H
18 
19 #include <string>
20 #include <vector>
21 #include <stdint.h>
22 #include <iosfwd>
23 #include "thermal_sensor_provision.h"
24 
25 namespace OHOS {
26 namespace PowerMgr {
27 struct ThermalZoneInfoItem {
28     uint32_t level;
29     int32_t threshold;
30     int32_t thresholdClr;
31 };
32 
33 class ProtectorThermalZoneInfo {
34 public:
35     ProtectorThermalZoneInfo() = default;
36     ~ProtectorThermalZoneInfo() = default;
37     void Dump();
38     void UpdateThermalLevel(int32_t temp);
GetThermalLevel()39     uint32_t GetThermalLevel()
40     {
41         return latestLevel_;
42     }
43     void SetThermalZoneItem(std::vector<ThermalZoneInfoItem> &tzItemList);
44     void SetDesc(bool desc);
45     void SetInterval(int32_t interval);
46     int32_t GetInterval() const;
47     void SetMultiple(int32_t multiple);
48     int32_t GetMultiple() const;
49     std::string GetPath() const;
50     void SetPath(const std::string &path);
51 private:
52     void AscJudgment(int32_t curTemp, uint32_t &level);
53     void DescJudgment(int32_t curTemp, uint32_t &level);
54     void HandleDescNextUpTemp(uint32_t &level, int32_t curTemp);
55     void HandleDescCurDownTemp(uint32_t &level, int32_t curTemp);
56     void HandleDescMaxSizeTemp(uint32_t &level, int32_t curTemp);
57     void HandleDescMinSizeTemp(uint32_t &level, int32_t curTemp);
58     void HandleAscNextUpTemp(uint32_t &level, int32_t curTemp);
59     void HandleAscCurDownTemp(uint32_t &level, int32_t curTemp);
60     void HandleAscMaxSizeTemp(uint32_t &level, int32_t curTemp);
61     void HandleAscMinSizeTemp(uint32_t &level, int32_t curTemp);
62     bool desc_ {false};
63     std::string path_;
64     uint32_t latestLevel_ {0};
65     int32_t interval_;
66     int32_t multiple_;
67     std::vector<ThermalZoneInfoItem> tzItemList_;
68 };
69 } // namespace PowerMgr
70 } // namespace OHOS
71 #endif // PROTECTOR_THERMAL_ZONE_INFO_H