• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 THERMAL_SRV_SUBSCRIBER_H
17 #define THERMAL_SRV_SUBSCRIBER_H
18 
19 #include <deque>
20 #include <memory>
21 #include <mutex>
22 #include <time.h>
23 #include "thermal_sensor_info.h"
24 #include "thermal_observer.h"
25 
26 namespace OHOS {
27 namespace PowerMgr {
28 class ThermalServiceSubscriber {
29 public:
30     ThermalServiceSubscriber();
31     ~ThermalServiceSubscriber() = default;
32     bool Init();
33     void OnTemperatureChanged(TypeTempMap typeTempMap);
34     void SetHistoryTypeTempMap(TypeTempMap typeTempMap);
GetRateCount()35     uint32_t GetRateCount() const
36     {
37         return rateCount_;
38     }
GetSensorsRate()39     const std::map<std::string, std::deque<double>>& GetSensorsRate()
40     {
41         return sensorsRateMap_;
42     }
GetSubscriberInfo()43     TypeTempMap& GetSubscriberInfo()
44     {
45         return typeTempMap_;
46     }
47 private:
48     double GetThermalRiseRate(const std::deque<int32_t> &tempQueue);
49 
50     TypeTempMap typeTempMap_;
51     uint32_t historyCount_ {0};
52     uint32_t rateCount_ {3};
53     std::map<std::string, std::deque<int32_t>> typeHistoryMap_;
54     std::map<std::string, std::deque<double>> sensorsRateMap_;
55     std::mutex mutex_;
56 };
57 } // namespace PowerMgr
58 } // namespace OHOS
59 
60 #endif //  THERMAL_SRV_SUBSCRIBER_H