1 /* 2 * Copyright (c) 2021-2022 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 BATTERY_STATS_PARSER_H 17 #define BATTERY_STATS_PARSER_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 #include <cstdint> 23 #include <functional> 24 #include <cstdint> 25 #include <iosfwd> 26 27 #include "stats_log.h" 28 29 namespace OHOS { 30 namespace PowerMgr { 31 class BatteryStatsParser { 32 public: BatteryStatsParser()33 explicit BatteryStatsParser() 34 { 35 STATS_HILOGI(COMP_SVC, "BatteryStatsParser instance is created"); 36 } 37 ~BatteryStatsParser() = default; 38 double GetAveragePowerMa(std::string type); 39 double GetAveragePowerMa(std::string type, uint16_t level); 40 uint16_t GetClusterNum(); 41 uint16_t GetSpeedNum(uint16_t cluster); 42 bool Init(); 43 private: 44 bool LoadAveragePowerFromFile(const std::string& path); 45 std::map<std::string, double> averageMap_; 46 std::map<std::string, std::vector<double>> averageVecMap_; 47 uint16_t clusterNum_ = 0; 48 std::vector<uint16_t> speedNum_; 49 }; 50 } // namespace PowerMgr 51 } // namespace OHOS 52 #endif // BATTERY_STATS_PARSER_H